From patchwork Wed Jul 13 21:14:38 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: 36786 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:6da0:b0:8b:e47:9dbf with SMTP id wl32csp610466pzb; Wed, 13 Jul 2022 14:14:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sscaYMoeOx1PeQEDcqrosCwRFsSCUZOqCu+aVlJ1MXz9PhPLpjNmFhMbR376GBlLe0O3OH X-Received: by 2002:a17:907:969f:b0:72b:7141:d6ef with SMTP id hd31-20020a170907969f00b0072b7141d6efmr5494574ejc.501.1657746891738; Wed, 13 Jul 2022 14:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657746891; cv=none; d=google.com; s=arc-20160816; b=XxygDys2SY2hSdUt+nNYw0fyKW67SPWvg1VHAC2k5GGqT5A5qXZT/Xqo0SmyIJyB6v hSICFzz342bVrXUTa2/UeMnq7eDcfNSdc5rt6BqRTIIUuF688TFUjcYQwE+Hios7vyar ozeM8CCl8sKU/7IR8KRzL5wBcYTUgyFl1CCKOPnZffhfv19l1dbduotmO8bNJllySPnY um2lA7CUcm+pAtPbkVSMg6aDngCEtp2eAYA63dPtFvMAPXtNvWC//KmwG9EkHQgvoBoB FUtsW82Daizp3m/tbFndXpfyzvF+wNhv2SlYLNR5cu2+2CjKz3UqUm6BW8LvI/qAO217 i6Kg== 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=dnILmYelsFlXqDYEveoBVdo+Z1bEQM2VDJaitOr+NRA=; b=vWlRdWPoEtTWMTK5Us47pGIsNhjFimehWf3Cf7vHZNC05/Z2I8ypOMYbZa/7sSmsd2 A5FaJsUbD3FCG2e3yy2ubTrCsQqby5lWyOZuE9F//R2Klg+wGbLw4GMKgYFdFsVwNH2q JxVQeoydlP5nUAFaGFatZBSyFO/NM5HO3HL5LimkSRVIpx7TEi6JMKhS5OFQ0f8dW2BV 3QCCuubrFTHU3o/fPbHGXJrquWnUUxWflkaasjyfbJ8lG/wWpOK8fHakUaxCFL+GjLs+ YBvOe/dktDEVAjf3O/rSLxFkbOjF/rz1SxuYP8Dw2fVls5ALrNb6rUIFhaa07vvZz0JF 8tNQ== 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=zv9pHaNt; 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 ap13-20020a17090735cd00b0072af3c24981si16028387ejc.425.2022.07.13.14.14.50; Wed, 13 Jul 2022 14:14:51 -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=zv9pHaNt; 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 7B96A68B9FE; Thu, 14 Jul 2022 00:14:47 +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 B7C2A68B84F for ; Thu, 14 Jul 2022 00:14:40 +0300 (EEST) Received: by mail-lj1-f176.google.com with SMTP id 19so14896405ljz.4 for ; Wed, 13 Jul 2022 14:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fUyHlu7JTPVqK70TT4d/x/EeH6vf406f+N6jKSaACQM=; b=zv9pHaNtF2YMtLJdGhRS70ZuQc4X8ONGF7bKCOmQX9zh/xvdjOx0QuY9EtD3WaBA+B 9N3epHcCLefVkbl8zsxZ/ao5tp+xeiXBCDXz67aRqmh2PlhDTg6wpttXEJUlVRledU51 QAJok3d9qFrIrC3jC0yIJ6rdrE3hUYWrLOuLH8fYKw7M/zqIGrgMI3yosSqZ5Nrhc6DN wTR3M3ED+JfM5jKGt6cglyOXtLkIKv5Ti9HJgoTA9d/DYuHReDZj+VYHC/3pNiIysyFZ SDAhY342s7pVH6tQOggOy32k/6L3XL1TZtHLFs+2oNTjo7e1Rp7mvuntWaWFAbCP/gVI YByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fUyHlu7JTPVqK70TT4d/x/EeH6vf406f+N6jKSaACQM=; b=P0YWRdn9/7zyglSBTbWGW9spip8tx4BiG6ABZHPTbxrpy0wBaIkvQqG0L3cNqEslII veEXqsYdUp3Pur/QKAz+0REyKmX6OthnDlxiwwyv5PzjmksL0wVM7QOw1RV3GgdmI//b wb5H45mklGGEX7/K7QA7hTyhIMQlMoyUqr/yDaWBKayJbFjPcZZELtsEdKbf3aHsg4L4 SBtmZSvgSSU96wQmeImhLIf8T11qIksPlxLLc4Trml0dgokkFVyNUImPfJbs9l58RK8d RfdJTltM2Z8atZ+loxyOrCmuAXg+CExd0ga9CILiJ74FQ9J/woT9kI6BkayHsuOnFws1 UrmA== X-Gm-Message-State: AJIora/+WB6JmicYG9GMNjDN0Gn/DSSN7Alu0u0ViRZCfdBLu5/34ux0 +agqnf8oWGUImDE8MEx8KKgS3YcuXHpU4Pzh X-Received: by 2002:a2e:9b0b:0:b0:25d:5ae6:4286 with SMTP id u11-20020a2e9b0b000000b0025d5ae64286mr2619613lji.148.1657746879859; Wed, 13 Jul 2022 14:14:39 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id u6-20020ac248a6000000b00489c8c6c055sm3003402lfg.50.2022.07.13.14.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 14:14:38 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Jul 2022 00:14:38 +0300 Message-Id: <20220713211438.3134725-1-martin@martin.st> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] 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: 8yCiSE7y0YNb 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ö --- Moved the attribute to libavutil/internal.h, renamed to a different namespace (not av_ prefixed), moved the attribute on ff_vp9_subpel_filters to the header, as suggested. --- libavcodec/aacsbrdata.h | 2 +- libavcodec/fft.h | 2 +- libavcodec/vp9dsp.h | 2 +- libavutil/internal.h | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index 7a11594c9b..b3899b3e5f 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -268,7 +268,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..b4066fe0d5 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -114,7 +114,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..13117fe9bc 100644 --- a/libavcodec/vp9dsp.h +++ b/libavcodec/vp9dsp.h @@ -120,7 +120,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/internal.h b/libavutil/internal.h index b44cbaaa7b..36afc4687f 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -61,6 +61,12 @@ #endif #endif +#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 + #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avutil) # define av_export_avutil __declspec(dllimport) #else