From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 2/2] libavcodec: Set hidden visibility on global symbols accessed from x86_64 assembly
Date: Thu, 4 Aug 2022 14:51:43 +0200
Message-ID: <DB6PR0101MB2214C7CC226E704E2C2AC2F38F9F9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <20220727120000.3596575-1-thomas@gllm.fr>
Thomas Guillem:
> DECLARE_ALIGNED, DECLARE_ASM_ALIGNED, and DECLARE_ASM_CONST will include
> attribute_visibility_hidden.
>
> ld: error: relocation R_X86_64_PC32 cannot be used against symbol 'ff_h264_cabac_tables'; recompile with -fPIC
>>>> defined in /home/tom/work/git/vlc-android/vlc/contrib/x86_64-linux-android/lib/libavcodec.a(cabac.o)
>>>> referenced by cabac.h:187 (libavcodec/x86/cabac.h:187)
>>>> h264_cabac.o:(ff_h264_decode_mb_cabac) in archive /home/tom/work/git/vlc-android/vlc/contrib/x86_64-linux-android/lib/libavcodec.a
> ---
> libavcodec/ac3dsp.h | 3 +-
> libavcodec/cabac.h | 3 +-
> libavcodec/h263dsp.h | 3 +-
> libavcodec/x86/constants.h | 81 +++++++++++++++++++-------------------
> libavutil/mem.h | 6 +--
> libswscale/x86/rgb2rgb.c | 2 +-
> 6 files changed, 51 insertions(+), 47 deletions(-)
>
> diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
> index a23b11526e..f8c03a7c23 100644
> --- a/libavcodec/ac3dsp.h
> +++ b/libavcodec/ac3dsp.h
> @@ -23,12 +23,13 @@
> #define AVCODEC_AC3DSP_H
>
> #include <stdint.h>
> +#include "libavutil/internal.h"
>
> /**
> * Number of mantissa bits written for each bap value.
> * bap values with fractional bits are set to 0 and are calculated separately.
> */
> -extern const uint16_t ff_ac3_bap_bits[16];
> +extern const uint16_t attribute_visibility_hidden ff_ac3_bap_bits[16];
>
> typedef struct AC3DSPContext {
> /**
> diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
> index 38d06b2842..356aa368d0 100644
> --- a/libavcodec/cabac.h
> +++ b/libavcodec/cabac.h
> @@ -28,8 +28,9 @@
> #define AVCODEC_CABAC_H
>
> #include <stdint.h>
> +#include "libavutil/internal.h"
>
> -extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
> +extern const uint8_t attribute_visibility_hidden ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
> #define H264_NORM_SHIFT_OFFSET 0
> #define H264_LPS_RANGE_OFFSET 512
> #define H264_MLPS_STATE_OFFSET 1024
> diff --git a/libavcodec/h263dsp.h b/libavcodec/h263dsp.h
> index 1abea3ca8c..514a148fb1 100644
> --- a/libavcodec/h263dsp.h
> +++ b/libavcodec/h263dsp.h
> @@ -20,8 +20,9 @@
> #define AVCODEC_H263DSP_H
>
> #include <stdint.h>
> +#include "libavutil/internal.h"
>
> -extern const uint8_t ff_h263_loop_filter_strength[32];
> +extern const uint8_t attribute_visibility_hidden ff_h263_loop_filter_strength[32];
>
> typedef struct H263DSPContext {
> void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
> diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h
> index 85da38b7b9..c84b0d4324 100644
> --- a/libavcodec/x86/constants.h
> +++ b/libavcodec/x86/constants.h
> @@ -22,51 +22,52 @@
> #define AVCODEC_X86_CONSTANTS_H
>
> #include <stdint.h>
> +#include "libavutil/internal.h"
>
> #include "libavutil/x86/asm.h"
>
> -extern const ymm_reg ff_pw_1;
> -extern const ymm_reg ff_pw_2;
> -extern const xmm_reg ff_pw_3;
> -extern const ymm_reg ff_pw_4;
> -extern const xmm_reg ff_pw_5;
> -extern const xmm_reg ff_pw_8;
> -extern const xmm_reg ff_pw_9;
> -extern const uint64_t ff_pw_15;
> -extern const xmm_reg ff_pw_16;
> -extern const xmm_reg ff_pw_18;
> -extern const xmm_reg ff_pw_20;
> -extern const xmm_reg ff_pw_32;
> -extern const uint64_t ff_pw_42;
> -extern const uint64_t ff_pw_53;
> -extern const xmm_reg ff_pw_64;
> -extern const uint64_t ff_pw_96;
> -extern const uint64_t ff_pw_128;
> -extern const ymm_reg ff_pw_255;
> -extern const ymm_reg ff_pw_256;
> -extern const ymm_reg ff_pw_512;
> -extern const ymm_reg ff_pw_1023;
> -extern const ymm_reg ff_pw_1024;
> -extern const ymm_reg ff_pw_2048;
> -extern const ymm_reg ff_pw_4095;
> -extern const ymm_reg ff_pw_4096;
> -extern const ymm_reg ff_pw_8192;
> -extern const ymm_reg ff_pw_m1;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_1;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_2;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_3;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_4;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_5;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_8;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_9;
> +extern const uint64_t attribute_visibility_hidden ff_pw_15;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_16;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_18;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_20;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_32;
> +extern const uint64_t attribute_visibility_hidden ff_pw_42;
> +extern const uint64_t attribute_visibility_hidden ff_pw_53;
> +extern const xmm_reg attribute_visibility_hidden ff_pw_64;
> +extern const uint64_t attribute_visibility_hidden ff_pw_96;
> +extern const uint64_t attribute_visibility_hidden ff_pw_128;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_255;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_256;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_512;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_1023;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_1024;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_2048;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_4095;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_4096;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_8192;
> +extern const ymm_reg attribute_visibility_hidden ff_pw_m1;
>
> -extern const ymm_reg ff_pb_0;
> -extern const ymm_reg ff_pb_1;
> -extern const ymm_reg ff_pb_2;
> -extern const ymm_reg ff_pb_3;
> -extern const ymm_reg ff_pb_80;
> -extern const ymm_reg ff_pb_FE;
> -extern const uint64_t ff_pb_FC;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_0;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_1;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_2;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_3;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_80;
> +extern const ymm_reg attribute_visibility_hidden ff_pb_FE;
> +extern const uint64_t attribute_visibility_hidden ff_pb_FC;
>
> -extern const xmm_reg ff_ps_neg;
> +extern const xmm_reg attribute_visibility_hidden ff_ps_neg;
>
> -extern const ymm_reg ff_pd_1;
> -extern const ymm_reg ff_pd_16;
> -extern const ymm_reg ff_pd_32;
> -extern const ymm_reg ff_pd_8192;
> -extern const ymm_reg ff_pd_65535;
> +extern const ymm_reg attribute_visibility_hidden ff_pd_1;
> +extern const ymm_reg attribute_visibility_hidden ff_pd_16;
> +extern const ymm_reg attribute_visibility_hidden ff_pd_32;
> +extern const ymm_reg attribute_visibility_hidden ff_pd_8192;
> +extern const ymm_reg attribute_visibility_hidden ff_pd_65535;
>
This is total overkill; the visibility pragma exists for a reason.
> #endif /* AVCODEC_X86_CONSTANTS_H */
> diff --git a/libavutil/mem.h b/libavutil/mem.h
> index d91174196c..88fea4bfe7 100644
> --- a/libavutil/mem.h
> +++ b/libavutil/mem.h
> @@ -113,9 +113,9 @@
> #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__)
> - #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_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
> + #define DECLARE_ALIGNED(n,t,v) attribute_visibility_hidden t __attribute__ ((aligned (n))) v
> + #define DECLARE_ASM_ALIGNED(n,t,v) attribute_visibility_hidden t av_used __attribute__ ((aligned (n))) v
> + #define DECLARE_ASM_CONST(n,t,v) attribute_visibility_hidden static const t av_used __attribute__ ((aligned (n))) v
You can't simply change the semantics of public defines; furthermore,
attribute_visibility_hidden should not be public. If these macros are to
be changed, then you need to modify mem.h to only define them in case
HAVE_AV_CONFIG_H is not defined (HAVE_AV_CONFIG_H is defined when
building our libraries). Then the macros from mem_internal.h will be
used and these can be modified.
(Furthermore, adding the attribute to DECLARE_ASM_CONST is pointless, as
it is already static.)
> #elif defined(_MSC_VER)
> #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
> #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v
> diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
> index b325e5dbd5..100f608d04 100644
> --- a/libswscale/x86/rgb2rgb.c
> +++ b/libswscale/x86/rgb2rgb.c
> @@ -70,7 +70,7 @@ DECLARE_ASM_CONST(8, uint64_t, mul15_hi) = 0x0210021002100210ULL;
> DECLARE_ASM_CONST(8, uint64_t, mul16_mid) = 0x2080208020802080ULL;
>
> DECLARE_ALIGNED(8, extern const uint64_t, ff_bgr2YOffset);
> -DECLARE_ALIGNED(8, extern const uint64_t, ff_w1111);
> +attribute_visibility_hidden DECLARE_ALIGNED(8, extern const uint64_t, ff_w1111);
> DECLARE_ALIGNED(8, extern const uint64_t, ff_bgr2UVOffset);
>
> #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2022-08-04 12:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 12:00 Thomas Guillem
2022-08-04 11:20 ` Martin Storsjö
2022-08-04 12:51 ` Andreas Rheinhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DB6PR0101MB2214C7CC226E704E2C2AC2F38F9F9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git