On Thu, Dec 12, 2024 at 9:41 AM David Anderson via Dwarf-discuss < dwarf-discuss@lists.dwarfstd.org> wrote:
> On 12/11/24 16:59, Alex via Dwarf-discuss wrote: > > ## Proposed Changes > > > > In Section 2.17 (Location Descriptions), replace the text on p. 53, line > 15: > > > > From: > > ``` > > Bounded range entries in a range list may not overlap. There is no > > requirement that the entries be ordered in any particular way. > > ``` > > Neither the proposal nor the html give a clear self-contained example > of the overlap case and I think that would be important to add. > Aggressive linker identical code folding is the main source of potentially overlapping CU ranges (within a single CU, or across two CUs) (& then combined with fragmented functions (what clang calls "-fbasic-block-sections", for instance) - causing one subprogram's ranges to overlap with itself or another subprogram's ranges (& then that causes overlapping at the CU level too)) eg: void f1() { } void f2() { } int main() { f1(); f2(); } $ clang++-tot test.cpp -g -ffunction-sections -fuse-ld=gold -Wl,--icf=all && llvm-dwarfdump-tot a.out | grep DW_AT_ranges -A3 DW_AT_ranges (indexed (0x0) rangelist = 0x00000010 [0x0000000000000670, 0x0000000000000676) [0x0000000000000670, 0x0000000000000676) [0x0000000000000680, 0x0000000000000692)) Admittedly, lld's icf doesn't have this result - it resolves one copy to an address, and the other copy is resolved to 0: $ clang++-tot test.cpp -g -ffunction-sections -fuse-ld=lld -Wl,--icf=all && llvm-dwarfdump-tot a.out | grep DW_AT_ranges -A3 DW_AT_ranges (indexed (0x0) rangelist = 0x00000010 [0x0000000000001700, 0x0000000000001706) [0x0000000000000000, 0x0000000000000006) [0x0000000000001710, 0x0000000000001722)) (& I'm not sure if/what support bfd ld has for ICF) Combine this with basic block sections (nodebug to simplify the DWARF output, but not necessary to reproduce the issue): __attribute__((nodebug)) void f1() { } void f2(bool b) { if (b) f1(); } void f3(bool b) { if (!b) f1(); } __attribute__((nodebug)) int main() { } CU ranges: DW_AT_ranges (indexed (0x2) rangelist = 0x0000002c [0x0000000000000680, 0x000000000000069f) [0x000000000000069f, 0x00000000000006a9) [0x00000000000006a9, 0x00000000000006af) [0x00000000000006b0, 0x00000000000006cf) [0x000000000000069f, 0x00000000000006a9) [0x00000000000006a9, 0x00000000000006af)) Subprogram ranges: f2: DW_AT_ranges (indexed (0x0) rangelist = 0x00000018 [0x0000000000000680, 0x000000000000069f) [0x000000000000069f, 0x00000000000006a9) [0x00000000000006a9, 0x00000000000006af)) f3: DW_AT_ranges (indexed (0x1) rangelist = 0x00000022 [0x00000000000006b0, 0x00000000000006cf) [0x000000000000069f, 0x00000000000006a9) [0x00000000000006a9, 0x00000000000006af))
-- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss