[PATCH] D22813: [ELF] Linkerscript: implement DATA_SEGMENT_RELRO_END.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 08:45:31 PDT 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, davide, evgeny777.
Herald added a subscriber: emaste.

Description says:

> 
> DATA_SEGMENT_RELRO_END(offset, exp)
> This defines the end of the PT_GNU_RELRO segment when `-z relro' option is used. When `-z relro' option is not present, DATA_SEGMENT_RELRO_END does nothing, otherwise DATA_SEGMENT_ALIGN is padded so that exp + offset is aligned to the most commonly used page boundary for particular target. If present in the linker script, it must always come in between DATA_SEGMENT_ALIGN and DATA_SEGMENT_END. Evaluates to the second argument plus any padding needed at the end of the PT_GNU_RELRO segment due to section alignment.
>             . = DATA_SEGMENT_RELRO_END(24, .);
(https://sourceware.org/binutils/docs/ld/Builtin-Functions.html)

This implementation is much simplier:
1) I do not touch DATA_SEGMENT_ALIGN, it do what it do now - just aligns to the page boundary.
2) When relro is disabled, then DATA_SEGMENT_RELRO_END is fully ignored (that is consistent with documentation).
3) When -z relro is enabled, then:
   a) Parameters of DATA_SEGMENT_RELRO_END is ignored. That should be correct as it is usually just a 24 bytes shift that allows to protect first 3 entries of got.plt with relro. (https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l146).
   b) DATA_SEGMENT_RELRO_END just aligns to the page boundary. That is what expected because all sections that are not affected by relro should be on another memory page.

So at fact the difference with documented behavior is that I do not pad DATA_SEGMENT_ALIGN. 3 entries of got.plt are uncovered by relro, but functionality is simple and equal to lld behavior for case when script is not given.

https://reviews.llvm.org/D22813

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/Inputs/shared.s
  test/ELF/linkerscript/linkerscript-data-segment-relro.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22813.65530.patch
Type: text/x-patch
Size: 4495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160726/c1b60433/attachment.bin>


More information about the llvm-commits mailing list