From patchwork Wed Aug 21 18:55:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 14645 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A936F44A29E for ; Wed, 21 Aug 2019 22:27:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82B0A68A980; Wed, 21 Aug 2019 22:27:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD73468A42C for ; Wed, 21 Aug 2019 22:27:04 +0300 (EEST) Received: by mail-qt1-f201.google.com with SMTP id c22so3819217qta.8 for ; Wed, 21 Aug 2019 12:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wvthqOWOdBpCytG0lY9ZLOJtLNZcuDXPnWu/FWHEJMw=; b=r3+5boH1BCNHiXmGHznqGw4ZJXYJdN2sF7uNXyXf0MZIOUV7m6CVYDZpCNhpTlxBuB nPtMo0+Ofnu8sRBjIdSitAPX52DM4jxvrYcYIiRO8GjnbcSbjnnuReGQpR96qPRZgFww jJC3pw5CYsIwkqoMWbc+83mefW2yOn0wgmggXo7pKxzudbFe0Sh/hyK1+ex3zivH8Jmk hbH8+txpPiG8fwY9TLh5/ChRFoVRz2zM1eH5zgWpra9jrGxtCWPhiLMA9DiH1ILEWpMe ccpOg2MTvY5tR2jo/00KBOGCRpl3qEkJA/DhKY8pGRcdZDwE/E6XxIh70rf8SYbbL3Su 6brg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wvthqOWOdBpCytG0lY9ZLOJtLNZcuDXPnWu/FWHEJMw=; b=SS8tLmpL+3T2RvRT90qcjEZXLzbAUIY1m5yksrTKW84gfu/i37byehf+vGFNSvVXVY jSqtOMhoXoyiYXsTDLBS5VbYLULm4oQigs9dKAmTC/h2DsEmc/7LKQm9hDJwRSghRxZr AxFiTfsbS/E15FH95mrYtrlV6G9bCZFMDQ+TQxIhVTIRTM130JM9Jy6V4C14xeZ6f7s0 ozNJzXnPiFy3lrXbl1Kyh9QMvzErVCqucfbq+YIpIH4epkLFrqLJZVkqkYRqc+zJv55c ZrMbkRNQa84ktkVTeZxu88zeM+mt5wgy+9uKQAUruhr5bYoaIaT17JgZfbMwcLqz9VPz Q3qw== X-Gm-Message-State: APjAAAXVbZdw8uKdtgzgmR9bd7qfndSjK3ZZS+jTjqCVOBXCaOBQDHCL uRyyOhPzjYUdjPiYAV+LPfAFMnf2P7b652O6aCGoIpqJ+EZWnwTdJZHeP0aI4qfjsXbw3wDwUzj wpyo7OCj/bfw4bWOOgYrqOKFaxBRHKyEu5+u+w5AVDczhc6l1+GVjXDM= X-Google-Smtp-Source: APXvYqx+kKKbcOBqc94gbV7n2NY4eiMLFlSW4bJlTgjEoqSKeVLENqI7rBlsRJGzgyC/cvaht98c7Tg= X-Received: by 2002:a63:3fc9:: with SMTP id m192mr30919298pga.429.1566413737352; Wed, 21 Aug 2019 11:55:37 -0700 (PDT) Date: Wed, 21 Aug 2019 11:55:25 -0700 In-Reply-To: <20190815180022.129027-1-pcc@google.com> Message-Id: <20190821185525.144151-1-pcc@google.com> Mime-Version: 1.0 References: <20190815180022.129027-1-pcc@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog From: Peter Collingbourne To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2] Add assembly support for -fsanitize=hwaddress tagged globals. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Peter Collingbourne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" As of LLVM r368102, Clang will set a pointer tag in bits 56-63 of the address of a global when compiling with -fsanitize=hwaddress. This requires an adjustment to assembly code that takes the address of such globals: the code cannot use the regular R_AARCH64_ADR_PREL_PG_HI21 relocation to refer to the global, since the tag would take the address out of range. Instead, the code must use the non-checking (_NC) variant of the relocation (the link-time check is substituted by a runtime check). This change makes the necessary adjustment in the movrel macro, where it is needed when compiling with -fsanitize=hwaddress. Signed-off-by: Peter Collingbourne --- libavutil/aarch64/asm.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S index 5c329430fd..3ac2ba0d52 100644 --- a/libavutil/aarch64/asm.S +++ b/libavutil/aarch64/asm.S @@ -32,6 +32,10 @@ # define FUNC # #endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + .macro function name, export=0, align=2 .macro endfunc ELF .size \name, . - \name @@ -94,7 +98,11 @@ ELF .size \name, . - \name add \rd, \rd, :lo12:\val+(\offset) .endif #elif CONFIG_PIC +# if __has_feature(hwaddress_sanitizer) + adrp \rd, :pg_hi21_nc:\val+(\offset) +# else adrp \rd, \val+(\offset) +# endif add \rd, \rd, :lo12:\val+(\offset) #else ldr \rd, =\val+\offset