[libc] Properly call init functions and main through GOT
In the CRT startup code, when linked in a PIC executable, jumps to `__init_libj6`, `__init_libc`, `main`, and `exit` were not linked correctly. They needed a bit more support for looking up the GOT, and getting the symbol address out of it. Now libutil has a `got.inc` file for inclusion in asm code that needs to reference symbols from the GOT.
This commit is contained in:
7
src/libraries/util/include/util/got.inc
Normal file
7
src/libraries/util/include/util/got.inc
Normal file
@@ -0,0 +1,7 @@
|
||||
extern _GLOBAL_OFFSET_TABLE_
|
||||
|
||||
; Put the address of the given symbol in rax
|
||||
%macro lookup_GOT 1
|
||||
lea rax, [rel _GLOBAL_OFFSET_TABLE_]
|
||||
mov rax, [rax + %1 wrt ..got]
|
||||
%endmacro
|
||||
Reference in New Issue
Block a user