[PATCH] D20024: [ELF] - Protect first entries of got.plt with RelRo.
H.J. Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 16:55:06 PDT 2016
On Fri, May 6, 2016 at 4:09 PM, Joerg Sonnenberger via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> On Fri, May 06, 2016 at 03:37:28PM -0700, Rui Ueyama wrote:
>> Does that mean the value the static linker writes to the first GOT slot
>> will be ignored?
>
> leaq _GLOBAL_OFFSET_TABLE_(%rip),%rax
> leaq _DYNAMIC(%rip),%rdi # &_DYNAMIC
> movq %rdi,%rbx
> subq (%rax),%rbx # relocbase
>
> ...and %rbx is then passed as argument to the self-relocation function.
> There are some possible other ways to do it, but they are more involved
> like parsing the aux vector. Given that this is very early startup code,
> less magic is better here.
Since the the link-time address of _DYNAMIC is stored in the first element
of the GOT as specified by the x86-64 psABI, one can use
movq _GLOBAL_OFFSET_TABLE_(%rip), %rax
to get the link-time address of _DYNAMIC.
--
H.J.
More information about the llvm-commits
mailing list