[PATCH] D40735: [LLD][ELF] InX::BssRelRo should check section contents before marking relro

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 08:55:30 PST 2017


peter.smith created this revision.
Herald added a subscriber: emaste.

When a linker script is used with a pattern like { *(.bss .bss.*) } the InX::BssRelRo section will match against .bss.*. We want to make sure that when InX::BssRelRo hasn't created any .bss.rel.ro InputSections we don't report the .bss OutputSection as relro. We also want to give an error message if relro and non relro bss is placed within the same OutputSection.

This is an attempt at fixing the problem that motivated r318924 (https://reviews.llvm.org/D40364) in a way that doesn't need to check for empty or zero sized sections. The Synthetic Sections InX::BssRelRo and InX::Bss behave differently to other SyntheticSections in that they act as a proxy for creating .bss.rel.ro or .bss InputSections for copy relocations in their parent OutputSections. This means that they are always removed by removeUnusedSyntheticSections() and always have a zero size. This patch attempts to do the following:

- Move the name test before the InX::BssRelRo so that if it matches into an existing OutputSection that is already relro we are relro.
- If the OutputSection name is .bss.rel.ro then this is strong statement of intent like .data.rel.ro then we are relro.
- If all the InputSections in the parent OutputSection are .bss.rel.ro then we are relro.
- If none of the InputSections in the parent OutputSection are .bss.rel.ro then we are not relro.
- If there are both relro and non-relro InputSections then give an error message.


https://reviews.llvm.org/D40735

Files:
  ELF/Writer.cpp
  test/ELF/relro-copyrel-bss-script-error.s
  test/ELF/relro-copyrel-bss-script.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40735.125150.patch
Type: text/x-patch
Size: 5315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/b9567fe4/attachment.bin>


More information about the llvm-commits mailing list