LibC: Make _init and _fini weak symbols
These seem to be missing sometimes when making shared executables
This commit is contained in:
parent
a07cbabcb3
commit
4189a1c729
|
@ -19,7 +19,11 @@ _start:
|
||||||
call _init_libc
|
call _init_libc
|
||||||
|
|
||||||
# call global constructors
|
# call global constructors
|
||||||
call _init
|
movl $_init, %eax
|
||||||
|
testl %eax, %eax
|
||||||
|
jz 1f
|
||||||
|
call *%eax
|
||||||
|
1:
|
||||||
|
|
||||||
movl $__init_array_start, %ebx
|
movl $__init_array_start, %ebx
|
||||||
jmp 2f
|
jmp 2f
|
||||||
|
|
|
@ -20,7 +20,11 @@ _start:
|
||||||
call _init_libc
|
call _init_libc
|
||||||
|
|
||||||
# call global constructors
|
# call global constructors
|
||||||
call _init
|
movq $_init, %rax
|
||||||
|
testq %rax, %rax
|
||||||
|
jz 1f
|
||||||
|
call *%rax
|
||||||
|
1:
|
||||||
|
|
||||||
movq $__init_array_start, %rbx
|
movq $__init_array_start, %rbx
|
||||||
jmp 2f
|
jmp 2f
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
extern "C" char** environ;
|
extern "C" char** environ;
|
||||||
|
|
||||||
extern "C" void _fini();
|
extern "C" __attribute__((weak)) void _fini();
|
||||||
|
|
||||||
static void (*at_exit_funcs[64])();
|
static void (*at_exit_funcs[64])();
|
||||||
static uint32_t at_exit_funcs_count = 0;
|
static uint32_t at_exit_funcs_count = 0;
|
||||||
|
@ -34,7 +34,7 @@ void exit(int status)
|
||||||
at_exit_funcs[i - 1]();
|
at_exit_funcs[i - 1]();
|
||||||
fflush(nullptr);
|
fflush(nullptr);
|
||||||
__cxa_finalize(nullptr);
|
__cxa_finalize(nullptr);
|
||||||
_fini();
|
if (_fini) _fini();
|
||||||
_exit(status);
|
_exit(status);
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue