[ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand
authorFangrui Song <maskray@google.com>
Wed, 26 Feb 2020 02:00:13 +0000 (18:00 -0800)
committerFangrui Song <maskray@google.com>
Mon, 23 Mar 2020 17:30:06 +0000 (10:30 -0700)
commit9e33c096476ab5e02ab1c8442cc3cb4e32e29f17
tree3b255aafb41e24e1b82d0197ef2597bdd5790757
parent9607a119bd5e01ccbbe45c2a5ae6bfbdd219e6c5
[ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand

This behavior matches GNU ld and seems reasonable.

```
// If a SECTIONS command is not specified
.text.* -> .text
.rodata.* -> .rodata
.init_array.* -> .init_array
```

A proposed Linux feature CONFIG_FG_KASLR may depend on the GNU ld behavior.

Reword a comment about -z keep-text-section-prefix and a comment about
CommonSection (deleted by rL286234).

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D75225
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/data-commands-gc.s
lld/test/ELF/linkerscript/icf-output-sections.s
lld/test/ELF/linkerscript/linkorder.s
lld/test/ELF/linkerscript/linkorder2.s
lld/test/ELF/linkerscript/memory3.s
lld/test/ELF/linkerscript/orphan-report.s
lld/test/ELF/linkerscript/symbol-assign-many-passes2.test
lld/test/ELF/mips-npic-call-pic-script.s
lld/test/ELF/shuffle-sections-init-fini.s
lld/test/ELF/text-section-prefix.s