diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 42ab48808f9a..fb48253b2ad2 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -1250,7 +1250,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj, continue; RelSecName = RelSecName.substr( - RelSecName.find_first_not_of("._")); // Skip . and _ prefixes. + RelSecName.find_first_not_of("._z")); // Skip . and _ prefixes. // TODO: Add support for relocations in other sections as needed. // Record relocations for the debug_info and debug_line sections. diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc b/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc index 966a465f9046..6c506381aa5d 100644 --- a/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc +++ b/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc @@ -22,6 +22,7 @@ int main() { // $ cp dwarfdump-test-zlib.cc /tmp/dbginfo // $ cd /tmp/dbginfo // $ clang++ -g dwarfdump-test-zlib.cc -Wl,--compress-debug-sections=zlib -o dwarfdump-test-zlib.elf-x86-64 +// $ clang++ -g dwarfdump-test-zlib.cc -Wa,--compress-debug-sections=zlib -c -o dwarfdump-test-zlib.o.elf-x86-64 // $ clang++ -g dwarfdump-test-zlib.cc -Wl,--compress-debug-sections=zlib-gnu -o dwarfdump-test-zlibgnu.elf-x86-64 // llvm-readobj -sections can be used to see that outputs really contain the compressed sections, also output in both -// cases is slightly smaller, that is because of compression. \ No newline at end of file +// cases is slightly smaller, that is because of compression. diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.o.elf-x86-64 b/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.o.elf-x86-64 new file mode 100644 index 000000000000..55f5cb0d157c Binary files /dev/null and b/llvm/test/DebugInfo/Inputs/dwarfdump-test-zlib.o.elf-x86-64 differ diff --git a/llvm/test/DebugInfo/dwarfdump-zlib.test b/llvm/test/DebugInfo/dwarfdump-zlib.test index d3ef806f3f87..82f29afdebde 100644 --- a/llvm/test/DebugInfo/dwarfdump-zlib.test +++ b/llvm/test/DebugInfo/dwarfdump-zlib.test @@ -1,6 +1,7 @@ REQUIRES: zlib RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-zlib.elf-x86-64 | FileCheck %s +RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-zlib.o.elf-x86-64 | FileCheck %s RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 | FileCheck %s CHECK: .debug_abbrev contents @@ -10,3 +11,7 @@ CHECK: .debug_abbrev contents // that sections names are properly shown in zlib-gnu style (without additional 'z' prefix). CHECK: .debug_info contents CHECK: 0x00000000: Compile Unit: length = 0x00000144 version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000148) + +// Also check that relocations in the .zdebug sections are handled correctly: +CHECK: DW_AT_ranges {{.*}} (0x00000000{{$}} +CHECK-NEXT: [0x