[PATCH] D63869: [ELF] Do not produce DT_JMPREL and DT_PLTGOT if .rela.plt is empty.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 06:55:41 PDT 2019


MaskRay added inline comments.


================
Comment at: test/ELF/empty-relaplt-dyntags.s:18
+## mentioned in the linker script. However, even in that case we should not
+## produce DT_JMPREL and DT_PLTGOT tags because this can cause a dynamic loader
+## to write into memory it considers reserved. In fact, as .got.plt is also
----------------
ikudrin wrote:
> MaskRay wrote:
> > > to write into memory it considers reserved
> > 
> > I don't think a dynamic linker should do this because DT_PLTRELSZ is zero.
> > 
> > I agree that 0 JMPREL should be omitted.
> > 
> >  0x0000000000000017 (JMPREL)             0x0                                                             
> >  0x0000000000000002 (PLTRELSZ)           0 (bytes)
> >  0x0000000000000003 (PLTGOT)             0x0
> That is why I posted the reproducer. I tested it on Ubuntu 18.04 with the fresh built `lld`.
You are right :) glibc writes the slots unconditionally

.got.plt[1] = _dl_runtime_resolve, .got.plt[2] = link_map

I have no more comments if you can fix the echo indentation and move the test under linkerscript

Empty .rela.plt is kept due to the isDiscardable() logic in LinkerScript.cpp


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63869/new/

https://reviews.llvm.org/D63869





More information about the llvm-commits mailing list