Index: ELF/GdbIndex.cpp =================================================================== --- ELF/GdbIndex.cpp +++ ELF/GdbIndex.cpp @@ -17,6 +17,7 @@ #include "GdbIndex.h" #include "Memory.h" #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h" +#include "llvm/Object/Decompressor.h" #include "llvm/Object/ELFObjectFile.h" using namespace llvm; @@ -33,6 +34,8 @@ .Case(".debug_ranges", &RangeSection) .Case(".debug_line", &LineSection) .Default(nullptr)) { + if (Decompressor::isCompressedELFSection(Sec->Flags, Sec->Name)) + Sec->uncompress(); M->Data = toStringRef(Sec->Data); M->Sec = Sec; continue; Index: test/ELF/compressed-debug-conflict.test =================================================================== --- /dev/null +++ test/ELF/compressed-debug-conflict.test @@ -0,0 +1,181 @@ +# REQUIRES: x86 +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld %t.o %t.o -o %tout 2>&1 | FileCheck %s + +# CHECK: error: duplicate symbol: main +# CHECK-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2) +# CHECK-NEXT: >>> +# CHECK-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2) +# CHECK-NEXT: >>> + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Content: 5589E55031C0C745FC0000000083C4045DC3 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 636C616E672076657273696F6E20362E302E3020287472756E6B203331343730382920286C6C766D2F7472756E6B2033313437313529002F746D702F726564756365642E63002F746D70006D61696E00696E74006D79696E7400 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101250E1305030E10171B0EB44219110112060000022E00110112064018030E3A0B3B0B49133F1900000316004913030E3A0B3B0B0000042400030E3E0B0B0B000000 + - Name: .debug_info + Type: SHT_PROGBITS + Flags: [ SHF_COMPRESSED ] + AddressAlign: 0x0000000000000001 + Content: 010000004E00000001000000789CF362606060610001164610C9C3800E84809809C6600C05B11899AC8124B31B54051323D80456160600373F0173 + - Name: .rel.debug_info + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_info + Relocations: + - Offset: 0x0000000000000006 + Symbol: .debug_abbrev + Type: R_386_32 + - Offset: 0x000000000000000C + Symbol: '' + Type: R_386_32 + - Offset: 0x0000000000000012 + Symbol: '' + Type: R_386_32 + - Offset: 0x0000000000000016 + Symbol: .debug_line + Type: R_386_32 + - Offset: 0x000000000000001A + Symbol: '' + Type: R_386_32 + - Offset: 0x000000000000001E + Symbol: .text + Type: R_386_32 + - Offset: 0x0000000000000027 + Symbol: .text + Type: R_386_32 + - Offset: 0x0000000000000031 + Symbol: '' + Type: R_386_32 + - Offset: 0x0000000000000040 + Symbol: '' + Type: R_386_32 + - Offset: 0x0000000000000047 + Symbol: '' + Type: R_386_32 + - Name: .debug_ranges + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 170000000200000000004E000000260000006D61696E0000000000 + - Name: .rel.debug_pubnames + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_pubnames + Relocations: + - Offset: 0x0000000000000006 + Symbol: .debug_info + Type: R_386_32 + - Name: .debug_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 200000000200000000004E0000003B0000006D79696E740046000000696E740000000000 + - Name: .rel.debug_pubtypes + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_pubtypes + Relocations: + - Offset: 0x0000000000000006 + Symbol: .debug_info + Type: R_386_32 + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 00636C616E672076657273696F6E20362E302E3020287472756E6B203331343730382920286C6C766D2F7472756E6B203331343731352900 + - Name: .note.GNU-stack + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: 10000000FFFFFFFF04000400017C080C0404880114000000000000000000000012000000410E088502420D05 + - Name: .rel.debug_frame + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_frame + Relocations: + - Offset: 0x0000000000000018 + Symbol: .debug_frame + Type: R_386_32 + - Offset: 0x000000000000001C + Symbol: .text + Type: R_386_32 + - Name: .debug_line + Type: SHT_PROGBITS + Flags: [ SHF_COMPRESSED ] + AddressAlign: 0x0000000000000001 + Content: 010000006D00000001000000789CCB64606060620802928C8CBFF97881242323880344FA25B9050C2042BF28B52035B1042BC5C050949A529A9C9AA2970CD20411D4CB009A0904AC6052985580EB04132BD0680001C8172D + - Name: .rel.debug_line + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_line + Relocations: + - Offset: 0x000000000000005F + Symbol: .text + Type: R_386_32 +Symbols: + Local: + - Name: reduced.c + Type: STT_FILE + - Section: .debug_str + - Section: .debug_str + Value: 0x0000000000000037 + - Section: .debug_str + Value: 0x0000000000000046 + - Section: .debug_str + Value: 0x000000000000004B + - Section: .debug_str + Value: 0x0000000000000050 + - Section: .debug_str + Value: 0x0000000000000054 + - Name: .text + Type: STT_SECTION + Section: .text + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_frame + Type: STT_SECTION + Section: .debug_frame + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + Global: + - Name: main + Type: STT_FUNC + Section: .text + Size: 0x0000000000000012 +...