Fangrui Song 0edc8b59ab
[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
2025-05-21 09:19:47 -07:00
..
2024-08-30 10:50:56 -04:00
2023-08-21 09:11:51 -07:00
2024-01-22 09:09:46 -08:00
2024-07-28 12:38:10 -07:00
2024-06-14 23:20:50 -07:00
2023-07-25 17:06:07 +08:00
2023-07-25 17:06:07 +08:00
2024-11-23 12:46:35 -08:00
2023-07-18 17:57:31 -07:00
2024-11-29 13:00:36 -08:00
2024-07-31 12:57:23 -07:00