mirror of git://sourceware.org/git/glibc.git
riscv: add support for static PIE
In order to support static PIE the startup code must avoid relocations before __libc_start_main is called.
This commit is contained in:
parent
bcf2abd43b
commit
6edaa12b41
|
@ -50,7 +50,13 @@ ENTRY (ENTRY_POINT)
|
||||||
call load_gp
|
call load_gp
|
||||||
mv a5, a0 /* rtld_fini. */
|
mv a5, a0 /* rtld_fini. */
|
||||||
/* main may be in a shared library. */
|
/* main may be in a shared library. */
|
||||||
|
#if defined PIC && !defined SHARED
|
||||||
|
/* Avoid relocation in static PIE since _start is called before it
|
||||||
|
is relocated. */
|
||||||
|
lla a0, __wrap_main
|
||||||
|
#else
|
||||||
la a0, main
|
la a0, main
|
||||||
|
#endif
|
||||||
REG_L a1, 0(sp) /* argc. */
|
REG_L a1, 0(sp) /* argc. */
|
||||||
addi a2, sp, SZREG /* argv. */
|
addi a2, sp, SZREG /* argv. */
|
||||||
andi sp, sp, ALMASK /* Align stack. */
|
andi sp, sp, ALMASK /* Align stack. */
|
||||||
|
@ -62,6 +68,11 @@ ENTRY (ENTRY_POINT)
|
||||||
ebreak
|
ebreak
|
||||||
END (ENTRY_POINT)
|
END (ENTRY_POINT)
|
||||||
|
|
||||||
|
#if defined PIC && !defined SHARED
|
||||||
|
__wrap_main:
|
||||||
|
tail main@plt
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Dynamic links need the global pointer to be initialized prior to calling
|
/* Dynamic links need the global pointer to be initialized prior to calling
|
||||||
any shared library's initializers, so we use preinit_array to load it.
|
any shared library's initializers, so we use preinit_array to load it.
|
||||||
This doesn't cut it for static links, though, since the global pointer
|
This doesn't cut it for static links, though, since the global pointer
|
||||||
|
|
Loading…
Reference in New Issue