From patchwork Wed Feb 20 09:13:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 12119 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 25978448CA7 for ; Wed, 20 Feb 2019 21:03:06 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A7A768A9A5; Wed, 20 Feb 2019 21:03:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0143268AB6F for ; Wed, 20 Feb 2019 11:21:05 +0200 (EET) Received: by mail-qt1-f193.google.com with SMTP id w4so26453851qtc.1 for ; Wed, 20 Feb 2019 01:21:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=8oTIVMpSxj5TvMGIDAUNv5Fnh5UiwfLbg/SeYTrJdvM=; b=flBcC91Pi7zF9e+3O5MwyEsnX19jdVCXxj0JKmMq1wSgkX1y9UdiaXAewi1ifm7Q4V yO0+4INY/gexd2KxyxOWs6Ih49duuTU14RkBBis7Q4K9L0m+/hEANZPQr0eWDcOlP0/k ql2N8bB9UQ1B/0XcOc6WGv2BCcE3Ztwu2u5w7dNiwyVHXDOZqk20++2QBYnGbi0Kwvg7 uvdukjrNiBiJ2QD2Rj8Dbbj5gRNgX+zrPqe0mmfucdb4rAmkMwa7R93cUMoaeKi4SmZc hBH6aSzuJKAipVpIDruqeWK/2QzJctRXX6Ys7OasDI4b1KeQhfDfXwpdLEq+sNZnbXal hofg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=8oTIVMpSxj5TvMGIDAUNv5Fnh5UiwfLbg/SeYTrJdvM=; b=msM9L0L2P8Fhj8gYHa76MgUebV0TL3/SpH0C+eig1obu+qvZZZ9FotMG3jA1+UEkod T9EO3d0peCZhtJZRyyQ5DV7UR9+tFxev2UfCfdEBmEKqcnP5JPt84Mh12fxO+ThyNJA/ SEA9dD06hhThhDIRrTGq6wmSLvdmtqQpKPN1gDX6pdXQLAxKhyDxcfL0fxQ4/wuy1R7I sJfi9+bwx5AFAeew7gnTNLOPicYWTcFrpX94RBTKqMJR+a7cATi98/FDaUxijN4mBRz0 W7DpuFvKErqX1D1sk6Rf7kzng3RJRxlg1slCu2UJxvFUtPd5v6YYJFl7J52NKXJb2CqZ Anng== X-Gm-Message-State: AHQUAuZZoDXtsKtDojomvjnhaWqrih9oPIwf8yVqUWmKqt1c4tPVSkGz 0sNMJ5eKKemll81Xbt6eX5Iz0zfsK6KSVbxKohinm4L0FRwf/JDV X-Google-Smtp-Source: AHgI3IYceF22s6aRXFsRE6MWaRXRfLsTdoy0uxKY9h69zqvWwBKmEJ8rNyTYdYQ6eITNRbH9wDHVgjjPulgG/DQJKzw= X-Received: by 2002:a0c:b701:: with SMTP id t1mr22143811qvd.179.1550654024706; Wed, 20 Feb 2019 01:13:44 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Wed, 20 Feb 2019 17:13:32 +0800 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Mailman-Approved-At: Wed, 20 Feb 2019 21:03:05 +0200 Subject: [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" 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. Also remove __clang__ as clang pretends to be gcc 4.2 and defines __GNUC__ Signed-off-by: Fangrui Song --- libavutil/mem.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) DECLARE_HIDDEN v #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..47abe2c8e9 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 @@ -108,9 +114,9 @@ #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v -#elif defined(__GNUC__) || defined(__clang__) +#elif defined(__GNUC__) #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