From patchwork Thu Feb 21 01:37:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 12120 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 28054446D36 for ; Thu, 21 Feb 2019 03:44:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B86F68AC8A; Thu, 21 Feb 2019 03:44:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C438E68A3D7 for ; Thu, 21 Feb 2019 03:44:37 +0200 (EET) Received: by mail-qk1-f196.google.com with SMTP id x9so3371490qkf.0 for ; Wed, 20 Feb 2019 17:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=1Y/P+qdABtXlSFr7qTW9IQbg8KbBao+DYnYSXSraJ9M=; b=hzALWWQaqImV3pAKBNhOfNRX9xxnt33ebz0BcaQQ9NQ4RBHClY9Hpt2kd3CgRsFc+X J1rpOXN3eMQnsrkQ7A8m7qpXd/MlKEv5y2vJRel6LkEm9FW3KNNJU7WLFSII5OPnia9k 4ZaBwEpSSjS9zkPwjt/eypoHICCE6NZxGHsiNdS9LRqfsT76KoIv5b8m7FqX48YbOSXU XD3a8vmMgyvNqOJIq15xvYTmnOg1vr0YOnIAAWeZeKlhK/uyuTLXpbMG9kPSEEVeU7pi UwhfXYKZrP/SNjRK62RadZPyIlguMXyJ2s/DHZtJ53wiDz0WZXQITX+02f1LwRrcm6mm uU2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=1Y/P+qdABtXlSFr7qTW9IQbg8KbBao+DYnYSXSraJ9M=; b=j+oQLWJnqYPfCrGLdFBoZwrKDm58z+yY5n22mkfh3w4ApCZ6bqjHfI6iDvVW5TbEar 38fPqsvG8hW6HbF6g1CFFqf8HFCJYQk8mreXfd4CpUF+pX/X4J2rGqM9mB299UFsaS1R oUqzKjbvQ6GRCyyUM8VTZjXlNtKI0wG/Y5z3XeS2NLJUO9abekEZWvR4HJH58cQg5SmJ MHT37Sx0B3oJ+DGQvpHM5FrfCXlk5LYTsDCCRoPMZVLNzbRd1gcIxAnTtRnwMEZ1RN6f ciFuSpQPl8xznlS1YaaHzoDr12yF3UBOfxsdYuiEUA8KgjZdgIqAhjfVcJDiYriK5AYA CC0Q== X-Gm-Message-State: AHQUAuZ/5jamJfJgR4TRQwc7KvLvwiMlrq53rI6eQiKObxN4UEHn49d9 eIAXDpXpbab6SO1X6Fxu2fqMhyuKq4uWtb5aQCc/U37jTNVq0DI3 X-Google-Smtp-Source: AHgI3IaeS80ZkKb4IWce0pbMcmFrcavVp04XO2UmVhovc4Pm3cSjQniC90GhvyvHbn0T7H3B5YPwzZWfpCAuPTCpqaI= X-Received: by 2002:a37:9b8d:: with SMTP id d135mr20739818qke.212.1550713066557; Wed, 20 Feb 2019 17:37:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Thu, 21 Feb 2019 09:37:33 +0800 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] avutil/mem: Mark DECLARE_ASM_ALIGNED as visibility("hidden") for __GNUC__ 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Sorry if this doesn't attach to the correct thread as I didn't subscribe to this list and don't know the Message-ID of the thread. > The word "also" indicates here that this should be an independent patch. I added `#if defined(__GNUC__) && !(defined(_WIN32) || defined(__CYGWIN__))`, not `#if (defined(__GNUC__) || defined(__clang__)) && !(defined(_WIN32) || defined(__CYGWIN__))`. For consistency I removed the defined(__clang__) below. If that change should be an independent one, here is the amended version without the removal of defined(__clang__) Inline asm code assumes these DECLARE_ASM_ALIGNED declared global constants are non-preemptive, e.g. libavcodec/x86/cabac.h "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t" On ELF platforms, if -Wl,-Bsymbolic -Wl,--version-script,libavcodec/libavcodec.ver are removed from the linker command line, the symbol will be considered preemptive and fail to link to a DSO: ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol ff_h264_cabac_tables; recompile with -fPIC It is better to express the intention explicitly and mark such global constants hidden (non-preemptive). It also improves portability as no linker magic is required. DECLARE_ASM_CONST uses the "static" specifier to indicate internal linkage. The visibility annotation is unnecessary. Signed-off-by: Fangrui Song --- libavutil/mem.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v #elif defined(_MSC_VER) #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v diff --git a/libavutil/mem.h b/libavutil/mem.h index 5fb1a02dd9..9afeed0b43 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -100,6 +100,12 @@ * @param v Name of the variable */ +#if defined(__GNUC__) && !(defined(_WIN32) || defined(__CYGWIN__)) + #define DECLARE_HIDDEN __attribute__ ((visibility ("hidden"))) +#else + #define DECLARE_HIDDEN +#endif + #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v @@ -110,7 +116,7 @@ #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v #elif defined(__GNUC__) || defined(__clang__) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) DECLARE_HIDDEN v