Last active
September 12, 2023 02:12
-
-
Save romainthomas/c10298387a921df730c1556c2ee9cecb to your computer and use it in GitHub Desktop.
Bionic's linker runs ELF constructors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mangled as __dl__ZL10call_arrayIPFviPPcS1_EEvPKcPT_mbS5_ in /system/bin/linker64 | |
template <typename F> | |
static void call_array(const char* array_name __unused, | |
F* functions, | |
size_t count, | |
bool reverse, | |
const char* realpath) { | |
if (functions == nullptr) { | |
return; | |
} | |
TRACE("[ Calling %s (size %zd) @ %p for '%s' ]", array_name, count, functions, realpath); | |
int begin = reverse ? (count - 1) : 0; | |
int end = reverse ? -1 : count; | |
int step = reverse ? -1 : 1; | |
for (int i = begin; i != end; i += step) { | |
TRACE("[ %s[%d] == %p ]", array_name, i, functions[i]); | |
call_function("function", functions[i], realpath); | |
} | |
TRACE("[ Done calling %s for '%s' ]", array_name, realpath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment