From patchwork Thu Aug 15 18:00:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 14525 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 7764A448510 for ; Thu, 15 Aug 2019 21:00:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 505AA68A761; Thu, 15 Aug 2019 21:00:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 180E46801D9 for ; Thu, 15 Aug 2019 21:00:39 +0300 (EEST) Received: by mail-pf1-f202.google.com with SMTP id 191so2044993pfy.20 for ; Thu, 15 Aug 2019 11:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=8MuYb4bS8J0Mq8WolDVyONefR1tYlNTeDscV8WqdPRM=; b=G8Cg38W9OCfYCLiChd0r15pv9d6YidcYTcknNLhKVA2CB3LA1zzZHPyL6y8W+4RVfw 0fN+aAbpSlPKQgLOVvuNt6Ak94VjTyFYJ+1qaNuPq4Pt1byE+CSj7x+qXHwefUca4ufZ CSb/1j35ju5QN7D0FJ8gSnmKmJIuK9t41j9Swl1eVQ5HmcOBCk3HA7LHLx2rxnCO3OHh 8/JhlTJOOzR0AWVWFr6RHRaSxTnMHhwkB60WBVVr9llRIOT4ZZQesE7urtI/1oJA6saz S3MehcdMqXk/7C16Qnb70uuXZQSygtb6mjEHIfCDoHIEcHES5Y1AwCnkY9+VBUa6wAw4 IzWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=8MuYb4bS8J0Mq8WolDVyONefR1tYlNTeDscV8WqdPRM=; b=bBaQHRQX3lp6K1rMU9yfmL5AP7m+4N6pe2B+aXwYBA3VbwXs7wb1AWXIRuA8dA37BP uZhInowz1WGGayZytalKHlGIhBabLtc8N3ItzkMJdLGVzfMQlSukEWiBYANMuWietAeJ OC199V48U56Db7xRUDONEeSFBXe3HMKET1XYAg2D7oJda9FB1/h5GjZHcU8oHnTf/6Gw GvA57U8rd5yzPlah3mk4WUdGu2NbG6f1UvcxkAAn7NO+WeobwbnKy2PQ5cXS+pdbcYYq r70U7EmcFDblSlVPp2hUDM6U+l6E+NoHOGQFHfFg9Q5YeOCNl0K/lN5g+UDih+4/Bduc j2aA== X-Gm-Message-State: APjAAAUKV91euyXf1f/BOJu6L3ZNcQXJLnxSqHNpqU7kSAH6HC7EAX8x aUFr+3ScBoA695jFM6KN9UZdY5VLX/RTQsMHPtQfuteg7McC8LLQeY7+QbSvs/FPwfBhUaQOZUh +RHj9IaHxhEYYzDE/HQIb8JhPIQT49U0YHG3GeoP+aTBxUYUm8RktuAs= X-Google-Smtp-Source: APXvYqygAN6hli+C/B2CnpzIWg3NcrDj2TawMW0tkxbusSj8m1PhApWuUjT/MCoEovr15Ycy4Qd6Nw4= X-Received: by 2002:a63:f357:: with SMTP id t23mr4521042pgj.421.1565892036779; Thu, 15 Aug 2019 11:00:36 -0700 (PDT) Date: Thu, 15 Aug 2019 11:00:22 -0700 Message-Id: <20190815180022.129027-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog From: Peter Collingbourne To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] 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. --- 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