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

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Feb 20 14:00:02 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 78762357d449cfcd11426c8e152302a27f2e7d4d
      https://github.com/llvm/llvm-project/commit/78762357d449cfcd11426c8e152302a27f2e7d4d
  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

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.

Pull Request: https://github.com/llvm/llvm-project/pull/81224



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