[all-commits] [llvm/llvm-project] c10218: [ELF] Synthesize STT_FILE if necessary (#209087)
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Jul 15 10:28:19 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c102184cbdcb8467ce1caf384ecd4e36d97fa37c
https://github.com/llvm/llvm-project/commit/c102184cbdcb8467ce1caf384ecd4e36d97fa37c
Author: Fangrui Song <i at maskray.me>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M lld/ELF/SyntheticSections.cpp
M lld/ELF/SyntheticSections.h
M lld/ELF/Writer.cpp
M lld/test/ELF/local-symbols-order.s
M lld/test/ELF/lto/parallel-internalize.ll
M lld/test/ELF/ppc64-local-entry.s
M lld/test/ELF/relocatable-comdat-multiple.s
M lld/test/ELF/relocatable-comdat2.s
M lld/test/ELF/relocatable-discard-locals.s
M lld/test/ELF/relocatable-gc.s
M lld/test/ELF/relocatable.s
M lld/test/ELF/strtab-nodedup.s
Log Message:
-----------
[ELF] Synthesize STT_FILE if necessary (#209087)
lld groups local symbols in .symtab by input file, appending a symbol
converted to STB_LOCAL (hidden visibility, version script `local:`, or
--exclude-libs) to its file's group. The nearest preceding STT_FILE then
claims the symbol, but the attribution can be wrong: the file may
contain multiple STT_FILE symbols (-r output), or lack an STT_FILE for
the symbol's unit.
```
FILE LOCAL DEFAULT ABS a.c
NOTYPE LOCAL DEFAULT 7 a_local
FILE LOCAL DEFAULT ABS b.c
NOTYPE LOCAL DEFAULT 7 b_local
NOTYPE LOCAL DEFAULT 7 a_localized
```
Follow GNU ld:
- If the output contains an STT_FILE symbol, place at the end of the
local part, after a synthetic STT_FILE with an empty name, every local
that cannot be attributed to a file: symbols converted to STB_LOCAL,
linker-synthesized symbols such as `_DYNAMIC`, and range-extension
thunks (parented to the internal file, which has no STT_FILE).
- For -r output, synthesize an STT_FILE named after the input file for
an input that outputs local symbols but no STT_FILE, so that its locals
are not attributed to a preceding file. We use the basename instead of
the full name for local determinism (#47367).
GNU ld synthesizes this per-input STT_FILE for executable and
shared-object output as well. Restrict it to -r for now to minimize test
updates.
Close #47367 and #191478
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