From patchwork Sat Aug 27 19:33:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 37517 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp1042763pzh; Sat, 27 Aug 2022 12:33:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5q2rt6DUwASJMkYxmDvW+kHinuPgfJhB83HASL0Ju4WYqpYPTnYJKcRIdoGE3PJDOk4Mqj X-Received: by 2002:a17:907:284a:b0:73d:a818:5a2a with SMTP id el10-20020a170907284a00b0073da8185a2amr8700225ejc.159.1661628834062; Sat, 27 Aug 2022 12:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661628834; cv=none; d=google.com; s=arc-20160816; b=kvKKPCBQZv8ITO3XPoq6tdGsW3j5SCWT4R4ADohS2v7151mjJBA7DYscV0Kmd6Or7p tyPeZLmYXVBX/VRIS1/VIahcifNJVLGOBqFP9m/xTsSwu3t+KLb3l/tpQ5jPOo0Zy0gl 5QtSEYBK5ow/lFQGJSbnYgwJpgswwzczCWTm7sPEJr5BoIc/M2wa7x84dr318J0emdSW N+kLTeHmCJaMX/T6A8D0BaQ2WVOTzSjD6Y60dUMHl+eV3r4bpewt4F1LsdzZ7eioBVkZ 5l0E6rrjQti3ErV2YgPXm1+wOiWOKG9NlwBawxYW2eaIAH6RHAA8Urp2piBpTHa3fs+z d5IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=w9FJ1lQwFdMXnvQdfFGQudmynqcVfDFGKyANnG7ylHM=; b=lXBvrIR5Ha4BmkaST6T1+Uu6ODlU5OHWFnc2qcsLN3P1oE2wfJM1A439/1ohVvmnf8 bcS2TKn5dbmxGqhw4pMm5tQ1x6pFDjtqe38HVUtsGg4CPEGm3ZKghav9ILLGsKvImZT7 i4mdeSsDj+TLKSS0VBlBtprI5UR8YB4FPdQqyTqDLw9ptRyelD0zWaT1ibz3AsTBsFbw 7s8zBoN4/R2qmKzskG1n4bZMt1VRBdUBIHT25DdZcOdDcKTSE7nRUXMoPW04w14gajG8 Pj9vW4hNzGcjHYjWeNMBJH3hkUwtBmS17S/FK4VT55B38Y+lQ/yNoUDxd1a9m6ExWB1m ArCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=w3VKSRg9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j9-20020a05640211c900b0043e72fe84bdsi4390726edw.44.2022.08.27.12.33.53; Sat, 27 Aug 2022 12:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=w3VKSRg9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7422B68BA59; Sat, 27 Aug 2022 22:33:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A1B068B405 for ; Sat, 27 Aug 2022 22:33:42 +0300 (EEST) Received: by mail-lj1-f176.google.com with SMTP id k22so4507448ljg.2 for ; Sat, 27 Aug 2022 12:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=ekCDCcY+QWkUTFwRBFcJBQsw90cfIbRgoZ3sPviKd6s=; b=w3VKSRg9ra8kQdYFWR2kqjUP2ErdqdSiW3x4VzZKFIG+T4aG5Tc/wC9ltS+pcRQRl4 HPIdm1xHnXjhZJELvqc2xeVGCkRPPf4yhME3fzEUnEqSqXBqXrSkdYskFeuw34ElaMh+ 08nRnT0h6ZoQulmlG7IvUvXxy7e2gC2xxJ/UNa1cyYIa7ASaRAfzYYrIca+STrPaBRzs aeZ7bPzwGRDM3//L/gmfdGvOJJQBeInBwyOtnntUk5xrOHiIQyGABG5BsyCplM3LvEs6 aRKSC8SM3YHi2uT8P6tjYFHR/MHDp9ILBy+UQ0aUQAGiN428Ye0M7eT4Sv8HmaTf3rx9 QZHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=ekCDCcY+QWkUTFwRBFcJBQsw90cfIbRgoZ3sPviKd6s=; b=Fjb/ke/SBziSG/VtZr4RJFZL2ESVTYpxATSg1MkfdXwPJpiGvw3Kb5K4XeuBM561jf 5h/xXE4ohlocaukl7DqOvjFcQ3PfnwNW2QM9q10JV2N3b1t9Om85UIYWgqzjPzCrJpzp e3j/WTFMoKYk4zVEvLcrCb19hlJPd/B86pQqCVQECzS9kK2Z+30tmMFpXvRDto4aKaV3 9AkG8157KpBVpKA2Bxh8ewhV0nmWuEoSLl8Ss2+d2KX0xIbuSzhfDg5fGbw6M4cfj1+1 M/P14ghs1hY1jGGkJ6mhCYolJS+8/C6ami6bgdHpPzu4EKh1imB1OSGtGFs0keV12QCP c1FQ== X-Gm-Message-State: ACgBeo3FmVcFtgaHeEpm6QAD1W0ucKbQm6ig9uAHPpNuX5I7IOkXG0T3 tCyesxlQXETldP2+EphQv4IHohaLpmCIBYMZ X-Received: by 2002:a2e:92c4:0:b0:25d:9d30:5d61 with SMTP id k4-20020a2e92c4000000b0025d9d305d61mr3980760ljh.202.1661628821508; Sat, 27 Aug 2022 12:33:41 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id d1-20020a05651221c100b0048b0ef93248sm752076lft.62.2022.08.27.12.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 12:33:40 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 27 Aug 2022 22:33:40 +0300 Message-Id: <20220827193340.737970-1-martin@martin.st> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4] libavcodec: Set hidden visibility on global symbols accessed from AArch64 assembly X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: =?utf-8?q?Martin_Storsj=C3=B6?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0wofI/k7iA8g The AArch64 assembly accesses those symbols directly, without indirection via e.g. the GOT on ELF. In order for this not to require text relocations, those symbols need to be resolved fully at link time, i.e. those symbols can't be interposable. Normally, so far, this is achieved when linking shared libraries in two ways; we have a version script (libavcodec/libavcodec.v) which marks all symbols that don't start with av* as local. Additionally, we try to add -Wl,-Bsymbolic to the linker options if supported, making sure that such symbol references are resolved fully at link time, instead of making them interposable. When the libavcodec static library is linked into another shared library, there's no guarantee that it uses similar options (even though that would be favourable), which would end up requiring text relocations in the AArch64 assembly. Explicitly mark the symbols that are accessed from AArch64 assembly as hidden, so that they are resolved fully at link time even without the version script and -Wl,-Bsymbolic. Signed-off-by: Martin Storsjö --- v4: Moved the attribute definition to a new, standalone header (which only depends on libavutil/attributes.h). --- libavcodec/aacsbrdata.h | 3 ++- libavcodec/fft.h | 3 ++- libavcodec/vp9dsp.h | 3 ++- libavutil/attributes_internal.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 libavutil/attributes_internal.h diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index 7a11594c9b..7bb45b229e 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -29,6 +29,7 @@ #define AVCODEC_AACSBRDATA_H #include +#include "libavutil/attributes_internal.h" #include "libavutil/mem_internal.h" #include "aac_defines.h" @@ -268,7 +269,7 @@ static const int8_t sbr_offset[6][16] = { }; /* First eight entries repeated at end to simplify SIMD implementations. */ -const DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { +const attribute_visibility_hidden DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { {Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, {Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, {Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, diff --git a/libavcodec/fft.h b/libavcodec/fft.h index 706c9d07f5..d46e5a3f0b 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -29,6 +29,7 @@ #include #include "config.h" +#include "libavutil/attributes_internal.h" #include "libavutil/mem_internal.h" #if FFT_FLOAT @@ -114,7 +115,7 @@ void ff_init_ff_cos_tabs(int index); #endif #define COSTABLE(size) \ - COSTABLE_CONST DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] + COSTABLE_CONST attribute_visibility_hidden DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] extern COSTABLE(16); extern COSTABLE(32); diff --git a/libavcodec/vp9dsp.h b/libavcodec/vp9dsp.h index 700dd72de8..be0ac0b181 100644 --- a/libavcodec/vp9dsp.h +++ b/libavcodec/vp9dsp.h @@ -28,6 +28,7 @@ #include #include "libavcodec/vp9.h" +#include "libavutil/attributes_internal.h" typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, @@ -120,7 +121,7 @@ typedef struct VP9DSPContext { vp9_scaled_mc_func smc[5][N_FILTERS][2]; } VP9DSPContext; -extern const int16_t ff_vp9_subpel_filters[3][16][8]; +extern const int16_t attribute_visibility_hidden ff_vp9_subpel_filters[3][16][8]; void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact); diff --git a/libavutil/attributes_internal.h b/libavutil/attributes_internal.h new file mode 100644 index 0000000000..9d3d10b63e --- /dev/null +++ b/libavutil/attributes_internal.h @@ -0,0 +1,30 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_ATTRIBUTES_INTERNAL_H +#define AVUTIL_ATTRIBUTES_INTERNAL_H + +#include "attributes.h" + +#if (AV_GCC_VERSION_AT_LEAST(4,0) || defined(__clang__)) && (defined(__ELF__) || defined(__MACH__)) +# define attribute_visibility_hidden __attribute__((visibility("hidden"))) +#else +# define attribute_visibility_hidden +#endif + +#endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */