1From 0d88e15454b632d92404dd6a7181c58d9985e2a2 Mon Sep 17 00:00:00 2001 2From: Rahul Chaudhry <rahulchaudhry@google.com> 3Date: Tue, 9 May 2017 12:00:58 -0700 4Subject: [PATCH] Add visibility="protected" attribute for global variables 5 referenced in asm files. 6 7During aosp builds with binutils-2.27, we're seeing linker error 8messages of this form: 9libvpx.a(subpixel_mmx.o): relocation R_386_GOTOFF against preemptible 10symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared 11object 12 13subpixel_mmx.o is assembled from "vp8/common/x86/subpixel_mmx.asm". 14Other messages refer to symbol references from deblock_sse2.o and 15subpixel_sse2.o, also assembled from asm files. 16 17This change marks such symbols as having "protected" visibility. This 18satisfies the linker as the symbols are not preemptible from outside 19the shared library now, which I think is the original intent anyway. 20 21Change-Id: I2817f7a5f43041533d65ebf41aefd63f8581a452 22--- 23 vp8/common/x86/filter_x86.c | 3 ++- 24 vpx_dsp/deblock.c | 4 ++-- 25 vpx_ports/mem.h | 6 ++++++ 26 3 files changed, 10 insertions(+), 3 deletions(-) 27 28diff --git a/vp8/common/x86/filter_x86.c b/vp8/common/x86/filter_x86.c 29index 2405342f0..73435a7dd 100644 30--- a/vp8/common/x86/filter_x86.c 31+++ b/vp8/common/x86/filter_x86.c 32@@ -17,7 +17,8 @@ DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_4[8][8]) = { 33 { 32, 32, 32, 32, 96, 96, 96, 96 }, { 16, 16, 16, 16, 112, 112, 112, 112 } 34 }; 35 36-DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_8[8][16]) = { 37+DECLARE_PROTECTED(DECLARE_ALIGNED(16, const short, 38+ vp8_bilinear_filters_x86_8[8][16])) = { 39 { 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0 }, 40 { 112, 112, 112, 112, 112, 112, 112, 112, 16, 16, 16, 16, 16, 16, 16, 16 }, 41 { 96, 96, 96, 96, 96, 96, 96, 96, 32, 32, 32, 32, 32, 32, 32, 32 }, 42diff --git a/vpx_dsp/deblock.c b/vpx_dsp/deblock.c 43index a0db1e40c..3734ac251 100644 44--- a/vpx_dsp/deblock.c 45+++ b/vpx_dsp/deblock.c 46@@ -10,9 +10,9 @@ 47 #include <assert.h> 48 #include <stdlib.h> 49 #include "./vpx_dsp_rtcd.h" 50-#include "vpx/vpx_integer.h" 51+#include "vpx_ports/mem.h" 52 53-const int16_t vpx_rv[] = { 54+DECLARE_PROTECTED(const int16_t vpx_rv[]) = { 55 8, 5, 2, 2, 8, 12, 4, 9, 8, 3, 0, 3, 9, 0, 0, 0, 8, 3, 14, 56 4, 10, 1, 11, 14, 1, 14, 9, 6, 12, 11, 8, 6, 10, 0, 0, 8, 9, 0, 57 3, 14, 8, 11, 13, 4, 2, 9, 0, 3, 9, 6, 1, 2, 3, 14, 13, 1, 8, 58diff --git a/vpx_ports/mem.h b/vpx_ports/mem.h 59index bfef783b1..35751cef8 100644 60--- a/vpx_ports/mem.h 61+++ b/vpx_ports/mem.h 62@@ -23,6 +23,12 @@ 63 #define DECLARE_ALIGNED(n, typ, val) typ val 64 #endif 65 66+#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32) 67+#define DECLARE_PROTECTED(decl) decl __attribute__((visibility("protected"))) 68+#else 69+#define DECLARE_PROTECTED(decl) decl 70+#endif 71+ 72 #if HAVE_NEON && defined(_MSC_VER) 73 #define __builtin_prefetch(x) 74 #endif 75-- 762.15.1 77 78