OSDN Git Service

linker: Make platform text relocations denial optional
authorAdrian DC <radian.dc@gmail.com>
Sat, 27 Aug 2016 13:09:36 +0000 (15:09 +0200)
committerSteve Kondik <shade@chemlab.org>
Tue, 4 Oct 2016 00:18:05 +0000 (17:18 -0700)
 * Use the TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS := true
    configuration to allow a device to use legacy proprietary
    libraries like camera on non-user build variants

 * Partial revert "Remove textrels support for platform libs"
    commit 8068786ae67835291521e52f39c695e40f3ad20d.

Change-Id: I994ab1a600a0b237b496ceebe2dd54febc28a6bd

linker/Android.mk
linker/linker.cpp

index 4a4ca5c..7221d12 100644 (file)
@@ -54,6 +54,14 @@ ifeq ($(TARGET_IS_64_BIT),true)
 LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
 endif
 
+ifeq ($(TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS),true)
+ifeq ($(user_variant),user)
+$(error Do not enable text relocations on user builds)
+else
+LOCAL_CPPFLAGS += -DTARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS
+endif
+endif
+
 # We need to access Bionic private headers in the linker.
 LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
 
index 38ccab5..c3c87a2 100644 (file)
@@ -3989,7 +3989,12 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t&
   if (has_text_relocations) {
     // Fail if app is targeting sdk version > 22
 #if !defined(__i386__) // ffmpeg says that they require text relocations on x86
+#if defined(TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS)
+    if (get_application_target_sdk_version() != __ANDROID_API__
+        && get_application_target_sdk_version() > 22) {
+#else
     if (get_application_target_sdk_version() > 22) {
+#endif
       PRINT("%s: has text relocations", get_realpath());
       DL_ERR("%s: has text relocations", get_realpath());
       return false;