[all-commits] [llvm/llvm-project] ce1484: [ELF] Support placing .lbss/.lrodata/.ldata after ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Feb 20 13:53:42 PST 2024


  Branch: refs/heads/users/MaskRay/spr/main.elf-place-lbsslrodataldata-after-bss
  Home:   https://github.com/llvm/llvm-project
  Commit: ce1484089c1271b386a7fe720194796b6263244f
      https://github.com/llvm/llvm-project/commit/ce1484089c1271b386a7fe720194796b6263244f
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-02-20 (Tue, 20 Feb 2024)

  Changed paths:
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/Writer.cpp
    M lld/docs/ld.lld.1
    M lld/test/ELF/lto/codemodel.ll
    M lld/test/ELF/x86-64-section-layout.s

  Log Message:
  -----------
  [ELF] Support placing .lbss/.lrodata/.ldata after .bss (#81224)

https://reviews.llvm.org/D150510 places .lrodata before .rodata to
minimize the number of permission transitions in the memory image.
However, this layout is less ideal for -fno-pic code (which is still
important).

Small code model -fno-pic code has R_X86_64_32S relocations with a range
of `[0,2**31)` (if we ignore the negative area). Placing `.lrodata`
earlier exerts relocation pressure on such code. Non-x86 64-bit
architectures generally have a similar `[0,2**31)` limitation if they
don't use PC-relative relocations.

If we place .lrodata later, we will need one extra PT_LOAD. Two layouts
are appealing:

* .bss/.lbss/.lrodata/.ldata (GNU ld)
* .bss/.ldata/.lbss/.lrodata

The GNU ld layout has the nice property that there is only one BSS
(except .tbss/.relro_padding). Add -z lrodata-after-bss to support
this layout.

Since a read-only PT_LOAD segment (for large data sections) may appear
after RW PT_LOAD segments. The placement of `_etext` has to be adjusted.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list