[all-commits] [llvm/llvm-project] 26ddf4: [ELF] Change .debug_names tombstone value to UINT3...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Dec 21 18:59:26 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 26ddf4eee2a009147faa3000c55d7822c2087dce
https://github.com/llvm/llvm-project/commit/26ddf4eee2a009147faa3000c55d7822c2087dce
Author: Fangrui Song <i at maskray.me>
Date: 2023-12-21 (Thu, 21 Dec 2023)
Changed paths:
M lld/ELF/InputSection.cpp
M lld/test/ELF/debug-dead-reloc-32.s
M lld/test/ELF/debug-dead-reloc.s
Log Message:
-----------
[ELF] Change .debug_names tombstone value to UINT32_MAX/UINT64_MAX (#74686)
`clang -g -gpubnames -fdebug-types-section` now emits .debug_names
section with references to local type unit entries defined in COMDAT
.debug_info sections.
```
.section .debug_info,"G", at progbits,5657452045627120676,comdat
.Ltu_begin0:
...
.section .debug_names,"", at progbits
...
// DWARF32
.long .Ltu_begin0 # Type unit 0
// DWARF64
// .long .Ltu_begin0 # Type unit 0
```
When `.Ltu_begin0` is relative to a non-prevailing .debug_info section,
the relocation resolves to 0, which is a valid offset within the
.debug_info section.
```
cat > a.cc <<e
struct A { int x; };
inline A foo() { return {1}; }
int main() { foo(); }
e
cat > b.cc <<e
struct A { int x; };
inline A foo() { return {1}; }
void use() { foo(); }
e
clang++ -g -gpubnames -fdebug-types-section -fuse-ld=lld a.cc b.cc -o old
```
```
% llvm-dwarfdump old
...
Local Type Unit offsets [
LocalTU[0]: 0x00000000
]
...
Local Type Unit offsets [
LocalTU[0]: 0x00000000 // indistinguishable from a valid offset within .debug_info
]
```
https://dwarfstd.org/issues/231013.1.html proposes that we use a
tombstone value instead to inform consumers. This patch implements the
idea. The second LocalTU entry will now use 0xffffffff.
https://reviews.llvm.org/D84825 has a TODO that we should switch the
tombstone value for most `.debug_*` sections to UINT64_MAX. We have
postponed the change for more than three years for consumers to migrate.
At some point we shall make the change, so that .debug_names is no long
different from other debug section that is not .debug_loc/.debug_ranges.
Co-authored-by: Alexander Yermolovich <ayermolo at meta.com>
More information about the All-commits
mailing list