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 <mask...@google.com> --- libavutil/mem.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 + #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 -- 2.20.1 -- 宋方睿 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel