[v2] Android: gallium_dri: pass dri.sym to linker

Submitted by Rob Herring on Aug. 22, 2017, 4:32 p.m.

Details

Message ID 20170822163203.17911-1-robh@kernel.org
State New
Headers show
Series "Android: gallium_dri: pass dri.sym to linker" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Rob Herring Aug. 22, 2017, 4:32 p.m.
Pass the dri.sym version script to the linker. This ensures only
explicitly exported symbols are exported and shrinks the library by up
to 60KB.

HAVE_DLADDR also needs to be set so that __driDriverExtensions is defined.

We need to pass "--undefined-version" because the Android build system
sets --no-undefined-version by default and we get an error on
driver specific symbols if those drivers are disabled without the option.

Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 Android.common.mk                  | 1 +
 src/gallium/targets/dri/Android.mk | 7 +++++++
 2 files changed, 8 insertions(+)

Patch hide | download patch | download mbox

diff --git a/Android.common.mk b/Android.common.mk
index d29e2e29d6f6..b5942add7678 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -66,6 +66,7 @@  LOCAL_CFLAGS += \
 	-DHAVE___BUILTIN_CLZLL \
 	-DHAVE___BUILTIN_UNREACHABLE \
 	-DHAVE_PTHREAD=1 \
+	-DHAVE_DLADDR \
 	-DHAVE_DLOPEN \
 	-DHAVE_DL_ITERATE_PHDR \
 	-DMAJOR_IN_SYSMACROS \
diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk
index 150b2e368e51..2218f7869ce6 100644
--- a/src/gallium/targets/dri/Android.mk
+++ b/src/gallium/targets/dri/Android.mk
@@ -32,6 +32,13 @@  LOCAL_SRC_FILES := target.c
 
 LOCAL_CFLAGS :=
 
+# We need --undefined-version as some functions in dri.sym may be missing
+# depending on which drivers are enabled or not. Otherwise, we get the error:
+# "version script assignment of  to symbol FOO failed: symbol not defined"
+LOCAL_LDFLAGS := \
+	-Wl,--version-script=$(LOCAL_PATH)/dri.sym \
+	-Wl,--undefined-version
+
 LOCAL_SHARED_LIBRARIES := \
 	libdl \
 	liblog \