diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFUnit.cpp | 12 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Inputs/fission-ranges.cc | 17 | ||||
-rwxr-xr-x | llvm/test/DebugInfo/Inputs/fission-ranges.elf-x86_64 | bin | 0 -> 8693 bytes | |||
-rw-r--r-- | llvm/test/DebugInfo/llvm-symbolizer.test | 4 |
4 files changed, 30 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARFUnit.cpp index f5f5072b9d3..027827735cf 100644 --- a/llvm/lib/DebugInfo/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARFUnit.cpp @@ -225,8 +225,12 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { setBaseAddress(BaseAddr); AddrOffsetSectionBase = DieArray[0].getAttributeValueAsSectionOffset( this, DW_AT_GNU_addr_base, 0); - RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset( - this, DW_AT_GNU_ranges_base, 0); + // Users of old DWARF may not know about DW_AT_ranges_base, so it is ignored + // for skeleton CU DIE (e.g. DW_AT_ranges are *not* relative to it). + if (Version > 4) { + RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset( + this, DW_AT_GNU_ranges_base, 0); + } } setDIERelations(); @@ -272,7 +276,9 @@ bool DWARFUnit::parseDWO() { } // Share .debug_addr and .debug_ranges section with compile unit in .dwo DWOCU->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase); - DWOCU->setRangesSection(RangeSection, RangeSectionBase); + uint32_t DWORangesBase = DieArray[0].getAttributeValueAsSectionOffset( + this, DW_AT_GNU_ranges_base, 0); + DWOCU->setRangesSection(RangeSection, DWORangesBase); return true; } diff --git a/llvm/test/DebugInfo/Inputs/fission-ranges.cc b/llvm/test/DebugInfo/Inputs/fission-ranges.cc new file mode 100644 index 00000000000..a585bf9c008 --- /dev/null +++ b/llvm/test/DebugInfo/Inputs/fission-ranges.cc @@ -0,0 +1,17 @@ +static inline int inlined_f() { + volatile int x = 2; + return x; +} + +int main() { + return inlined_f(); +} + +// Build instructions: +// $ mkdir /tmp/dbginfo +// $ cp fission-ranges.cc /tmp/dbginfo/ +// $ cd /tmp/dbginfo +// $ gcc -gsplit-dwarf -O2 -fPIC fission-ranges.cc -c -o obj2.o +// $ clang -gsplit-dwarf -O2 -fsanitize=address -fPIC -Dmain=foo fission-ranges.cc -c -o obj1.o +// $ gcc obj1.o obj2.o -shared -o <output> +// $ objcopy --remove-section=.debug_aranges <output> diff --git a/llvm/test/DebugInfo/Inputs/fission-ranges.elf-x86_64 b/llvm/test/DebugInfo/Inputs/fission-ranges.elf-x86_64 Binary files differnew file mode 100755 index 00000000000..3d2fd79dd74 --- /dev/null +++ b/llvm/test/DebugInfo/Inputs/fission-ranges.elf-x86_64 diff --git a/llvm/test/DebugInfo/llvm-symbolizer.test b/llvm/test/DebugInfo/llvm-symbolizer.test index 6aa12876fa5..1ddfd9cf55c 100644 --- a/llvm/test/DebugInfo/llvm-symbolizer.test +++ b/llvm/test/DebugInfo/llvm-symbolizer.test @@ -17,6 +17,7 @@ RUN: echo "%p/Inputs/macho-universal 0x1f84" >> %t.input RUN: echo "%p/Inputs/macho-universal:i386 0x1f67" >> %t.input RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input +RUN: echo "%p/Inputs/fission-ranges.elf-x86_64 0x720" >> %t.input RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck %s @@ -90,6 +91,9 @@ CHECK: _Z3inci CHECK: main CHECK-NEXT: llvm-symbolizer-dwo-test.cc:11 +CHECK: main +CHECK-NEXT: {{.*}}fission-ranges.cc:6 + RUN: echo "unexisting-file 0x1234" > %t.input2 RUN: llvm-symbolizer < %t.input2 |