[PATCH] D55864: [elfabi] Write program headers, .dynamic, .dynstr, and .shstrtab

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 09:28:55 PDT 2019


MaskRay added a comment.

Is llvm-elfabi used to create interface shared objects? Do you use it to create real(runnable) modules?

If not and if section/segment specification is not required, it can be very simple.
You just need the symbol table and very little other information.
There is one place in lld that checks if the symbol is in a readonly segment (`addCopyRelSymbol`).
1 PT_LOAD(RWX) + 1 PT_GNU_RELRO works just fine. You don't even need PT_TLS - `STT_TLS` symbols can be placed in an arbitrary section. Linkers and various binutils don't validate `PT_TLS`.

> Using a TLS nobits saves space

The best layout I can think of is:
`PT_LOAD(PT_GNU_RELRO(.data.rel.ro PT_TLS(.tdata | .tbss) .bss.rel.ro) | .data .bss)`

Currently lld has (`.tbss` cannot really be SHT_NOBITS due to `.data.rel.ro`):
`PT_LOAD(PT_GNU_RELRO(PT_TLS(.tdata .tbss) | .data.rel.ro .bss.rel.ro) | .data .bss)`

There is much to say on this topic.

> (note that .dynamic is sometimes read only and sometimes writeable)

Do you mean ld.lld -z rodynamic (D33251 <https://reviews.llvm.org/D33251> http://lists.llvm.org/pipermail/llvm-dev/2017-May/113258.html)? (`.dynamic` is in the PT_GNU_RELRO region)


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

https://reviews.llvm.org/D55864





More information about the llvm-commits mailing list