[PATCH] D20024: [ELF] - Protect first entries of got.plt with RelRo.

H.J. Lu via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 08:54:17 PDT 2016


On Mon, May 9, 2016 at 8:51 AM, H.J. Lu <hjl.tools at gmail.com> wrote:
> On Mon, May 9, 2016 at 8:46 AM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>> I was able to link and run the musl  dynamic linker with the patch that
>> stops setting got[0].
>>
>> So, Rui, what is your take on this? Should we leave that out of tree until
>> it is time to try to link glibc's dynamic linker?
>>
>
> If you do so, please state clearly that your linker doesn't follow
> x86-64 psABI which says:
>
> The tables first entry (number zero) is reserved to hold the address of the dy-
> namic structure, referenced with the symbol _DYNAMIC. This allows a program,
> such as the dynamic linker, to find its own dynamic structure without having yet
> processed its relocation entries. This is especially important for the dynamic
> linker, because it must initialize itself without relying on other
> programs to re-
> locate its memory image.

BTW, you also need to change the first entry of PLT to use
GOT[0] and GOT[1] instead of GOT[1] and GOT[2].

-- 
H.J.


More information about the llvm-commits mailing list