DebugInfo: Use base address selection entries in debug_ranges to reduce…
Concern RaisedrL309526


DebugInfo: Use base address selection entries in debug_ranges to reduce relocations

(from comments in the test)
Group ranges in a range list that apply to the same section and use a base
address selection entry to reduce the number of relocations to one reloc per
section per range list. DWARF5 debug_rnglist will be more efficient than this
in terms of relocations, but it's still better than one reloc per entry in a
range list.

This is an object/executable size tradeoff - shrinking objects, but growing
the linked executable. In one large binary tested, total object size (not just
debug info) shrank by 16%, entirely relocation entries. Linked executable
grew by 4%. This was with compressed debug info in the objects, uncompressed
in the linked executable. Without compression in the objects, the win would be
smaller (the growth of debug_ranges itself would be more significant).


dblaikieJul 30 2017, 3:10 PM
rL309525: test: add an additional cfi_return_column test

Event Timeline

tberghammer raised a concern with this commit.Jul 30 2017, 4:47 PM
tberghammer added subscribers: llvm-commits, tberghammer.

Hi David,

This CL caused a regression in LLDB by generating some incorrect relocations for the debug info. To reproduce:

Compile the following source code using ToT clang (trunk 309523) for x86_64-unknown-linux-gnu with "clang -g -c -o ns2.cpp ns2.o"

inline int a() { return 1; }
void b() { a(); }
void c() {}

Running "objdump -W -r ns2.o" will show the following data:

Contents of the .debug_ranges section:

    Offset   Begin    End
    00000000 ffffffffffffffff 0000000000000000 (base address)
    00000000 0000000000000000 0000000000000016 
    00000000 0000000000000020 0000000000000026 
    00000000 0000000000000000 000000000000000b 
    00000000 <End of list>


OFFSET           TYPE              VALUE 
0000000000000008 R_X86_64_64       .text
0000000000000030 R_X86_64_64       .text._Z1av
0000000000000038 R_X86_64_64       .text._Z1av

Looking at the data it will apply both the base address entry and the relocation entry for the 4th row in the debug_ranges section what will mean they will end up with invalid values.

Note: As far as I can tell LLDB doesn't support these base address entries but that should be an easy fix on the LLDB side what I can take care of once clang emits the correct data.

This commit now has outstanding concerns.Jul 30 2017, 4:47 PM