diff options
author | Fangrui Song <i@maskray.me> | 2025-05-21 09:19:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-21 09:19:47 -0700 |
commit | 0edc8b59ab82c868cb76b5b7339916c21d0a35ee (patch) | |
tree | bf155b1ba6f599f7e9ab34ec791a48e0fd52b5c0 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 81b81354f8c117fab07823fef24b97b3a1f47834 (diff) | |
download | llvm-0edc8b59ab82c868cb76b5b7339916c21d0a35ee.zip llvm-0edc8b59ab82c868cb76b5b7339916c21d0a35ee.tar.gz llvm-0edc8b59ab82c868cb76b5b7339916c21d0a35ee.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions