[all-commits] [llvm/llvm-project] 0edc8b: [ELF] Error if a section address is smaller than i...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed May 21 09:20:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0edc8b59ab82c868cb76b5b7339916c21d0a35ee
      https://github.com/llvm/llvm-project/commit/0edc8b59ab82c868cb76b5b7339916c21d0a35ee
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-05-21 (Wed, 21 May 2025)

  Changed paths:
    M lld/ELF/Writer.cpp
    M lld/docs/ReleaseNotes.rst
    M lld/test/ELF/linkerscript/out-of-order.s
    M lld/test/ELF/linkerscript/section-align2.test
    M lld/test/ELF/sectionstart.s
    M lld/test/ELF/ttext-tdata-tbss.s

  Log Message:
  -----------
  [ELF] Error if a section address is smaller than image base

When using `-no-pie` without a `SECTIONS` command, the linker uses the
target's default image base. If `-Ttext=` or `--section-start` specifies
an output section address below this base, the result is likely
unintended.

- With `--no-rosegment`, the PT_LOAD segment covering the ELF header cannot include `.text` if `.text`'s address is too low, causing an `error: output file too large`.
- With default `--rosegment`:
  - If a read-only section (e.g., `.rodata`) exists, a similar `error: output file too large` occurs.
  - Without read-only sections, the PT_LOAD segment covering the ELF header and program headers includes no sections, which is unusual and likely undesired. This also causes non-ascending PT_LOAD `p_vaddr` values related to the PT_LOAD that overlaps with PT_PHDR (#138584).

To prevent these issues, report an error if a section address is below
the image base and suggest `--image-base`. This check also applies when
`--image-base` is explicitly set but is skipped when a `SECTIONS`
command is used.

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



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