Android: gallium_dri: pass dri.sym to linker
authorRob Herring <robh@kernel.org>
Mon, 21 Aug 2017 19:27:42 +0000 (14:27 -0500)
committerRob Herring <robh@kernel.org>
Wed, 23 Aug 2017 00:02:12 +0000 (19:02 -0500)
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
src/gallium/targets/dri/Android.mk

index e5416c4e383970906072db25450d15193f519932..25ea8a3c490587e6a8d855edf5c60e1f6815bb6c 100644 (file)
@@ -64,6 +64,7 @@ LOCAL_CFLAGS += \
        -DHAVE___BUILTIN_CLZLL \
        -DHAVE___BUILTIN_UNREACHABLE \
        -DHAVE_PTHREAD=1 \
+       -DHAVE_DLADDR \
        -DHAVE_DLOPEN \
        -DHAVE_DL_ITERATE_PHDR \
        -DMAJOR_IN_SYSMACROS \
index 96b570ea11628bb2ba31bc4c897d449174911003..e40288c21b9442951d808b52edb77ffe9f255453 100644 (file)
@@ -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 \
        libglapi \