mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[ld.so] Call all image global ctors, not just libc
With the move to dynamic executables, crt0's _start was only ever calling libc's __init_libc, which only ran libc's init_array list. Now make crt0 itself (which is statically linked into every executable) call it's own init_array list and have ld.so call every other image's ctor lists.
This commit is contained in:
@@ -1,33 +1,6 @@
|
||||
#include <stddef.h>
|
||||
|
||||
using cb = void (*)(void);
|
||||
extern cb __preinit_array_start;
|
||||
extern cb __preinit_array_end;
|
||||
extern cb __init_array_start;
|
||||
extern cb __init_array_end;
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
run_ctor_list(cb *p, cb *end)
|
||||
{
|
||||
while (p && end && p < end) {
|
||||
if (p) (*p)();
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run_global_ctors()
|
||||
{
|
||||
run_ctor_list(&__preinit_array_start, &__preinit_array_end);
|
||||
run_ctor_list(&__init_array_start, &__init_array_end);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" void
|
||||
__init_libc()
|
||||
{
|
||||
run_global_ctors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user