ANDROID: Make musl libc soname configurable am: 109b21bd4f am: 088e55b1de am: fbfd5a74aa am: 6b77f992c8
Original change: https://android-review.googlesource.com/c/platform/external/musl/+/1956545
Change-Id: If5fffba205cedd1276aa2ee4162e90d4eb9c5940
diff --git a/Android.bp b/Android.bp
index 3338510..ac858ea 100644
--- a/Android.bp
+++ b/Android.bp
@@ -267,7 +267,10 @@
"libc_musl_defaults",
"libc_musl_ldso_sources",
],
- cflags: ["-fno-stack-protector"],
+ cflags: [
+ "-fno-stack-protector",
+ "-DLIBC_SONAME=libc_musl.so",
+ ],
}
// An attempt to compile the dynamic linker as a standalone library separate from libc_musl.so.
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index fdf3606..fd0d38e 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -24,6 +24,9 @@
#include "libc.h"
#include "dynlink.h"
+#define STRINGIFY(x) __STRINGIFY(x)
+#define __STRINGIFY(x) #x
+
#define malloc __libc_malloc
#define calloc __libc_calloc
#define realloc __libc_realloc
@@ -1128,7 +1131,7 @@
if (find_sym(&temp_dso, "__libc_start_main", 1).sym &&
find_sym(&temp_dso, "stdin", 1).sym) {
unmap_library(&temp_dso);
- return load_library("libc_musl.so", needed_by);
+ return load_library(STRINGIFY(LIBC_SONAME), needed_by);
}
/* Past this point, if we haven't reached runtime yet, ldso has
* committed either to use the mapped library or to abort execution.
@@ -1660,7 +1663,7 @@
ldso.base = base;
}
Ehdr *ehdr = (void *)ldso.base;
- ldso.name = ldso.shortname = "libc_musl.so";
+ ldso.name = ldso.shortname = STRINGIFY(LIBC_SONAME);
ldso.phnum = ehdr->e_phnum;
ldso.phdr = laddr(&ldso, ehdr->e_phoff);
ldso.phentsize = ehdr->e_phentsize;