summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugenis@google.com>2012-08-13 17:58:37 +0400
committerElliott Hughes <enh@google.com>2012-08-13 11:05:47 -0700
commit9181a5dcfe69199415c7aebf93524cc3dd6f8a6f (patch)
tree381d31f88ca04d15d5f83845b02cf1a04abc7ce6 /linker
parent20b94c0ce99ea3d2315535091c8bcd02f831d252 (diff)
downloadbionic-9181a5dcfe69199415c7aebf93524cc3dd6f8a6f.zip
bionic-9181a5dcfe69199415c7aebf93524cc3dd6f8a6f.tar.gz
bionic-9181a5dcfe69199415c7aebf93524cc3dd6f8a6f.tar.bz2
Fix module constructor order.
.preinit_array goes before the constructors of LD_PRELOAD-ed libraries. Change-Id: I1af32ce29eaf3ca4351ae8a0f7f5da5165853216
Diffstat (limited to 'linker')
-rw-r--r--linker/linker.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index a19fd45..59b7893 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1276,6 +1276,15 @@ static void call_array(unsigned *ctor, int count, int reverse)
}
}
+static void soinfo_call_preinit_constructors(soinfo *si)
+{
+ TRACE("[ %5d Calling preinit_array @ 0x%08x [%d] for '%s' ]\n",
+ pid, (unsigned)si->preinit_array, si->preinit_array_count,
+ si->name);
+ call_array(si->preinit_array, si->preinit_array_count, 0);
+ TRACE("[ %5d Done calling preinit_array for '%s' ]\n", pid, si->name);
+}
+
void soinfo_call_constructors(soinfo *si)
{
if (si->constructors_called)
@@ -1294,17 +1303,9 @@ void soinfo_call_constructors(soinfo *si)
// out above, the libc constructor will be called again (recursively!).
si->constructors_called = 1;
- if (si->flags & FLAG_EXE) {
- TRACE("[ %5d Calling preinit_array @ 0x%08x [%d] for '%s' ]\n",
- pid, (unsigned)si->preinit_array, si->preinit_array_count,
- si->name);
- call_array(si->preinit_array, si->preinit_array_count, 0);
- TRACE("[ %5d Done calling preinit_array for '%s' ]\n", pid, si->name);
- } else {
- if (si->preinit_array) {
- DL_ERR("shared library \"%s\" has a preinit_array table @ 0x%08x. "
- "This is INVALID.", si->name, (unsigned) si->preinit_array);
- }
+ if (!(si->flags & FLAG_EXE) && si->preinit_array) {
+ DL_ERR("shared library \"%s\" has a preinit_array table @ 0x%08x. "
+ "This is INVALID.", si->name, (unsigned) si->preinit_array);
}
if (si->dynamic) {
@@ -1897,6 +1898,8 @@ sanitize:
exit(-1);
}
+ soinfo_call_preinit_constructors(si);
+
for(i = 0; preloads[i] != NULL; i++) {
soinfo_call_constructors(preloads[i]);
}