[PATCH] D75225: [ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand

Kees Cook via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 09:41:12 PDT 2020


kees added a comment.

In D75225#1896066 <https://reviews.llvm.org/D75225#1896066>, @MaskRay wrote:

> 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...)


Maybe by default? However, when building the kernel and the linker script has an explicit .text output section without an input .text.* pattern, ld.bfd does not collect them into the output .text section (they are just adjacent).


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