[PATCH] D75225: [ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 27 10:10:40 PST 2020
MaskRay added a comment.
In D75225#1895813 <https://reviews.llvm.org/D75225#1895813>, @kees wrote:
> > .text.* -> .text
>
> This is not accurate: ld.bfd will keep the .text.$foo names, but place them all after the .text (it does not merge them into .text). Currently, ld.lld seems to merge them into .text. FGKASLR depends on the non-merging behavior.
I think the description is correct. I have a line `// If a SECTIONS command is not specified` in the code block.
Here is GNU ld's internal linker script:
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
(As you can see, `-z keep-text-section-prefix` does less than what GNU ld does. One issue with GNU ld's internal linker script is that -ffunction-sections (typical when building a libc) will cause the function `exit` to be reordered before others...)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75225/new/
https://reviews.llvm.org/D75225
More information about the llvm-commits
mailing list