diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -689,22 +689,27 @@ } } + Optional LowPCAttrInfo = + findAttributeInfo(DIE, dwarf::DW_AT_low_pc); if (AbbreviationDecl->findAttributeIndex(dwarf::DW_AT_ranges)) { // Case 1: The object was already non-contiguous and had DW_AT_ranges. // In this case we simply need to update the value of DW_AT_ranges // and introduce DW_AT_GNU_ranges_base if required. Optional AttrVal = findAttributeInfo(DIE, dwarf::DW_AT_ranges); - std::lock_guard Lock(DebugInfoPatcherMutex); DebugInfoPatcher.addLE32Patch( AttrVal->Offset, DebugRangesOffset - DebugInfoPatcher.getRangeBase(), AttrVal->Size); - if (!RangesBase) + + if (!RangesBase) { + if (LowPCAttrInfo && + LowPCAttrInfo->V.getForm() != dwarf::DW_FORM_GNU_addr_index && + LowPCAttrInfo->V.getForm() != dwarf::DW_FORM_addrx) + DebugInfoPatcher.addLE64Patch(LowPCAttrInfo->Offset, 0); return; + } // Convert DW_AT_low_pc into DW_AT_GNU_ranges_base. - Optional LowPCAttrInfo = - findAttributeInfo(DIE, dwarf::DW_AT_low_pc); if (!LowPCAttrInfo) { errs() << "BOLT-ERROR: skeleton CU at 0x" << Twine::utohexstr(DIE.getOffset()) @@ -725,8 +730,9 @@ // Case 2: The object has both DW_AT_low_pc and DW_AT_high_pc emitted back // to back. Replace with new attributes and patch the DIE. - if (AbbreviationDecl->findAttributeIndex(dwarf::DW_AT_low_pc) && - AbbreviationDecl->findAttributeIndex(dwarf::DW_AT_high_pc)) { + Optional HighPCAttrInfo = + findAttributeInfo(DIE, dwarf::DW_AT_high_pc); + if (LowPCAttrInfo && HighPCAttrInfo) { convertToRangesPatchAbbrev(*DIE.getDwarfUnit(), AbbreviationDecl, AbbrevWriter, RangesBase); convertToRangesPatchDebugInfo(DIE, DebugRangesOffset, DebugInfoPatcher, diff --git a/bolt/test/AArch64/Inputs/go_dwarf.yaml b/bolt/test/AArch64/Inputs/go_dwarf.yaml new file mode 100644 --- /dev/null +++ b/bolt/test/AArch64/Inputs/go_dwarf.yaml @@ -0,0 +1,757 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_AARCH64 + Entry: 0x684 +ProgramHeaders: + - Type: PT_PHDR + Flags: [ PF_R ] + VAddr: 0x40 + Align: 0x8 + - Type: PT_INTERP + Flags: [ PF_R ] + FirstSec: .interp + LastSec: .interp + VAddr: 0x238 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .interp + LastSec: .eh_frame + Align: 0x10000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .init_array + LastSec: .bss + VAddr: 0x10D80 + Align: 0x10000 + - Type: PT_DYNAMIC + Flags: [ PF_W, PF_R ] + FirstSec: .dynamic + LastSec: .dynamic + VAddr: 0x10D90 + Align: 0x8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.ABI-tag + VAddr: 0x254 + Align: 0x4 + - Type: PT_GNU_EH_FRAME + Flags: [ PF_R ] + FirstSec: .eh_frame_hdr + LastSec: .eh_frame_hdr + VAddr: 0x834 + Align: 0x4 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .init_array + LastSec: .got + VAddr: 0x10D80 +Sections: + - Name: .interp + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x238 + AddressAlign: 0x1 + Content: 2F6C69622F6C642D6C696E75782D616172636836342E736F2E3100 + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x254 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 830E96AA27E1C3EA3B159A0423A4BACD7A141C3B + Type: NT_PRPSINFO + - Name: .note.ABI-tag + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x278 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: '00000000030000000700000000000000' + Type: NT_VERSION + - Name: .gnu.hash + Type: SHT_GNU_HASH + Flags: [ SHF_ALLOC ] + Address: 0x298 + Link: .dynsym + AddressAlign: 0x8 + Header: + SymNdx: 0x1 + Shift2: 0x0 + BloomFilter: [ 0x0 ] + HashBuckets: [ 0x0 ] + HashValues: [ ] + - Name: .dynsym + Type: SHT_DYNSYM + Flags: [ SHF_ALLOC ] + Address: 0x2B8 + Link: .dynstr + AddressAlign: 0x8 + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x3A8 + AddressAlign: 0x1 + - Name: .gnu.version + Type: SHT_GNU_versym + Flags: [ SHF_ALLOC ] + Address: 0x432 + Link: .dynsym + AddressAlign: 0x2 + Entries: [ 0, 0, 0, 0, 2, 2, 0, 2, 0, 2 ] + - Name: .gnu.version_r + Type: SHT_GNU_verneed + Flags: [ SHF_ALLOC ] + Address: 0x448 + Link: .dynstr + AddressAlign: 0x8 + Dependencies: + - Version: 1 + File: libc.so.6 + Entries: + - Name: GLIBC_2.17 + Hash: 110530967 + Flags: 0 + Other: 2 + - Name: .rela.dyn + Type: SHT_RELA + Flags: [ SHF_ALLOC ] + Address: 0x468 + Link: .dynsym + AddressAlign: 0x8 + Relocations: + - Offset: 0x10D80 + Type: R_AARCH64_RELATIVE + Addend: 1928 + - Offset: 0x10D88 + Type: R_AARCH64_RELATIVE + Addend: 1856 + - Offset: 0x10FC8 + Type: R_AARCH64_RELATIVE + Addend: 2064 + - Offset: 0x10FE8 + Type: R_AARCH64_RELATIVE + Addend: 1936 + - Offset: 0x10FF0 + Type: R_AARCH64_RELATIVE + Addend: 1632 + - Offset: 0x11008 + Type: R_AARCH64_RELATIVE + Addend: 69640 + - Offset: 0x10FD0 + Symbol: _ITM_deregisterTMCloneTable + Type: R_AARCH64_GLOB_DAT + - Offset: 0x10FD8 + Symbol: __cxa_finalize + Type: R_AARCH64_GLOB_DAT + - Offset: 0x10FE0 + Symbol: __gmon_start__ + Type: R_AARCH64_GLOB_DAT + - Offset: 0x10FF8 + Symbol: _ITM_registerTMCloneTable + Type: R_AARCH64_GLOB_DAT + - Name: .rela.plt + Type: SHT_RELA + Flags: [ SHF_ALLOC, SHF_INFO_LINK ] + Address: 0x558 + Link: .dynsym + AddressAlign: 0x8 + Info: .got + Relocations: + - Offset: 0x10F98 + Symbol: __cxa_finalize + Type: R_AARCH64_JUMP_SLOT + - Offset: 0x10FA0 + Symbol: __libc_start_main + Type: R_AARCH64_JUMP_SLOT + - Offset: 0x10FA8 + Symbol: __gmon_start__ + Type: R_AARCH64_JUMP_SLOT + - Offset: 0x10FB0 + Symbol: abort + Type: R_AARCH64_JUMP_SLOT + - Offset: 0x10FB8 + Symbol: printf + Type: R_AARCH64_JUMP_SLOT + - Name: .init + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x5D0 + AddressAlign: 0x4 + Content: FD7BBFA9FD03009139000094FD7BC1A8C0035FD6 + - Name: .plt + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x5F0 + AddressAlign: 0x10 + EntSize: 0x10 + Content: F07BBFA99000009011CA47F910423E9120021FD61F2003D51F2003D51F2003D59000009011CE47F910623E9120021FD69000009011D247F910823E9120021FD69000009011D647F910A23E9120021FD69000009011DA47F910C23E9120021FD69000009011DE47F910E23E9120021FD6 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x660 + AddressAlign: 0x8 + Content: FD7BBFA9A1D6811200000090FD03009100C02091F7FFFF9700008052FD7BC1A8C0035FD61D0080D21E0080D2E50300AAE10340F9E2230091E60300918000009000F847F98300009063F447F98400009084E447F9DBFFFF97E2FFFF978000009000F047F9400000B4DAFFFF17C0035FD6800000B000400091810000B0214000913F0000EBC00000548100009021E847F9610000B4F00301AA00021FD6C0035FD6800000B000400091810000B021400091210000CB22FC7FD3410C818BFF0781EB21FC4193C00000548200009042FC47F9620000B4F00302AA00021FD6C0035FD6FD7BBEA9FD030091F30B00F9930000B060424039400100358000009000EC47F9800000B4800000B0000440F9A9FFFF97D8FFFF972000805260420039F30B40F9FD7BC2A8C0035FD6DEFFFF171F2003D5FD7BBCA9FD030091F35301A99400009094223691F55B02A995000090B5023691940215CBF603002AF76303A9F70301AAF80302AA83FFFF97FF0F94EB6001005494FE4393130080D2A37A73F8E20318AA73060091E10317AAE003162A60003FD69F0213EB21FFFF54F35341A9F55B42A9F76343A9FD7BC4A8C0035FD61F2003D5C0035FD6 + - Name: .fini + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x814 + AddressAlign: 0x4 + Content: FD7BBFA9FD030091FD7BC1A8C0035FD6 + - Name: .rodata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x828 + AddressAlign: 0x8 + Content: 010002000000000025640A00 + - Name: .eh_frame_hdr + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x834 + AddressAlign: 0x4 + Content: 011B033B40000000070000002CFEFFFFBC0000009CFEFFFF58000000CCFEFFFF6C0000000CFFFFFF8000000054FFFFFFA40000005CFFFFFFDC000000DCFFFFFF10010000 + - Name: .eh_frame + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x878 + AddressAlign: 0x8 + Content: 1000000000000000017A520004781E011B0C1F0010000000180000003CFEFFFF3000000000000000100000002C00000058FEFFFF4000000000000000200000004000000084FEFFFF4800000000410E209D049E034293024EDEDDD30E000000001400000064000000A8FEFFFF0400000000000000000000001C0000007C00000068FDFFFF2400000000410E109D029E0147DEDD0E00000000300000009C00000078FEFFFF7C00000000410E409D089E0742930694054395049603459702980153DEDDD7D8D5D6D3D40E00000010000000D0000000C4FEFFFF040000000000000000000000 + - Name: .init_array + Type: SHT_INIT_ARRAY + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x10D80 + AddressAlign: 0x8 + EntSize: 0x8 + Offset: 0xD80 + Content: '8807000000000000' + - Name: .fini_array + Type: SHT_FINI_ARRAY + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x10D88 + AddressAlign: 0x8 + EntSize: 0x8 + Content: '4007000000000000' + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x10D90 + Link: .dynstr + AddressAlign: 0x8 + Entries: + - Tag: DT_NEEDED + Value: 0x1 + - Tag: DT_INIT + Value: 0x5D0 + - Tag: DT_FINI + Value: 0x814 + - Tag: DT_INIT_ARRAY + Value: 0x10D80 + - Tag: DT_INIT_ARRAYSZ + Value: 0x8 + - Tag: DT_FINI_ARRAY + Value: 0x10D88 + - Tag: DT_FINI_ARRAYSZ + Value: 0x8 + - Tag: DT_GNU_HASH + Value: 0x298 + - Tag: DT_STRTAB + Value: 0x3A8 + - Tag: DT_SYMTAB + Value: 0x2B8 + - Tag: DT_STRSZ + Value: 0x89 + - Tag: DT_SYMENT + Value: 0x18 + - Tag: DT_DEBUG + Value: 0x0 + - Tag: DT_PLTGOT + Value: 0x10F80 + - Tag: DT_PLTRELSZ + Value: 0x78 + - Tag: DT_PLTREL + Value: 0x7 + - Tag: DT_JMPREL + Value: 0x558 + - Tag: DT_RELA + Value: 0x468 + - Tag: DT_RELASZ + Value: 0xF0 + - Tag: DT_RELAENT + Value: 0x18 + - Tag: DT_FLAGS + Value: 0x8 + - Tag: DT_FLAGS_1 + Value: 0x8000001 + - Tag: DT_VERNEED + Value: 0x448 + - Tag: DT_VERNEEDNUM + Value: 0x1 + - Tag: DT_VERSYM + Value: 0x432 + - Tag: DT_RELACOUNT + Value: 0x6 + - Tag: DT_NULL + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 + - Name: .got + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x10F80 + AddressAlign: 0x8 + EntSize: 0x8 + Content: 000000000000000000000000000000000000000000000000F005000000000000F005000000000000F005000000000000F005000000000000F005000000000000900D0100000000001008000000000000000000000000000000000000000000000000000000000000900700000000000060060000000000000000000000000000 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x11000 + AddressAlign: 0x8 + Content: '00000000000000000810010000000000' + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x11010 + AddressAlign: 0x1 + Size: 0x8 + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 4743433A20285562756E747520392E332E302D31377562756E7475317E32302E30342920392E332E3000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: B100000004000000000008011F0000000C000000000C00000000000000600600000000000000000000029E0000000101059000000060060000000000008406000000000000019C9000000003610001020990000000CA6204050000000200900000006D00000005970000000600077806000000000000A900000008015009033008000000000000080151030B4AF10000090405696E74000A08A40000000B0108A30000000C9D0000000D0500000005000000020000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 011101250E130B030E1B0E5517110110170000022E013F19030E3A0B3B0B390B49131101120140189742190113000003340003083A0B3B0B390B49131C0D0000042E013F19030E3A0B3B0B271949133C19011300000505004913000006180000000789820101110131130000088A820100021891421800000924000B0B3E0B030800000A0F000B0B491300000B24000B0B3E0B030E00000C2600491300000D2E003F193C196E0E030E3A0B3B0B000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 5C0000000300290000000401FB0E0D0001010101000000010000010065782E63010000003C6275696C742D696E3E0000000000050C00090260060000000000000105051313050C0610050522050C2C050522050C1E0505140501210203000101 +Symbols: + - Name: .interp + Type: STT_SECTION + Section: .interp + Value: 0x238 + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x254 + - Name: .note.ABI-tag + Type: STT_SECTION + Section: .note.ABI-tag + Value: 0x278 + - Name: .gnu.hash + Type: STT_SECTION + Section: .gnu.hash + Value: 0x298 + - Name: .dynsym + Type: STT_SECTION + Section: .dynsym + Value: 0x2B8 + - Name: .dynstr + Type: STT_SECTION + Section: .dynstr + Value: 0x3A8 + - Name: .gnu.version + Type: STT_SECTION + Section: .gnu.version + Value: 0x432 + - Name: .gnu.version_r + Type: STT_SECTION + Section: .gnu.version_r + Value: 0x448 + - Name: .rela.dyn + Type: STT_SECTION + Section: .rela.dyn + Value: 0x468 + - Name: .rela.plt + Type: STT_SECTION + Section: .rela.plt + Value: 0x558 + - Name: .init + Type: STT_SECTION + Section: .init + Value: 0x5D0 + - Name: .plt + Type: STT_SECTION + Section: .plt + Value: 0x5F0 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x660 + - Name: .fini + Type: STT_SECTION + Section: .fini + Value: 0x814 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x828 + - Name: .eh_frame_hdr + Type: STT_SECTION + Section: .eh_frame_hdr + Value: 0x834 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x878 + - Name: .init_array + Type: STT_SECTION + Section: .init_array + Value: 0x10D80 + - Name: .fini_array + Type: STT_SECTION + Section: .fini_array + Value: 0x10D88 + - Name: .dynamic + Type: STT_SECTION + Section: .dynamic + Value: 0x10D90 + - Name: .got + Type: STT_SECTION + Section: .got + Value: 0x10F80 + - Name: .data + Type: STT_SECTION + Section: .data + Value: 0x11000 + - Name: .bss + Type: STT_SECTION + Section: .bss + Value: 0x11010 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: .debug_aranges + Type: STT_SECTION + Section: .debug_aranges + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_ranges + Type: STT_SECTION + Section: .debug_ranges + - Name: '/usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/Scrt1.o' + Type: STT_FILE + Index: SHN_ABS + - Name: '$d' + Section: .note.ABI-tag + Value: 0x278 + - Name: '$x' + Section: .text + Value: 0x684 + - Name: '$d (1)' + Section: .rodata + Value: 0x828 + - Name: '/usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/crti.o' + Type: STT_FILE + Index: SHN_ABS + - Name: '$x (1)' + Section: .text + Value: 0x6BC + - Name: call_weak_fn + Type: STT_FUNC + Section: .text + Value: 0x6BC + Size: 0x14 + - Name: '$x (2)' + Section: .init + Value: 0x5D0 + - Name: '$x (3)' + Section: .fini + Value: 0x814 + - Name: '/usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/crtn.o' + Type: STT_FILE + Index: SHN_ABS + - Name: '$x (4)' + Section: .init + Value: 0x5DC + - Name: '$x (5)' + Section: .fini + Value: 0x81C + - Name: ex.c + Type: STT_FILE + Index: SHN_ABS + - Name: '$d (2)' + Section: .rodata + Value: 0x830 + - Name: '$x (6)' + Section: .text + Value: 0x660 + - Name: '$d (3)' + Section: .eh_frame + Value: 0x8F0 + - Name: crtstuff.c + Type: STT_FILE + Index: SHN_ABS + - Name: '$x (7)' + Section: .text + Value: 0x6D0 + - Name: deregister_tm_clones + Type: STT_FUNC + Section: .text + Value: 0x6D0 + - Name: register_tm_clones + Type: STT_FUNC + Section: .text + Value: 0x700 + - Name: '$d (4)' + Section: .data + Value: 0x11008 + - Name: __do_global_dtors_aux + Type: STT_FUNC + Section: .text + Value: 0x740 + - Name: completed.9126 + Type: STT_OBJECT + Section: .bss + Value: 0x11010 + Size: 0x1 + - Name: '$d (5)' + Section: .fini_array + Value: 0x10D88 + - Name: __do_global_dtors_aux_fini_array_entry + Type: STT_OBJECT + Section: .fini_array + Value: 0x10D88 + - Name: frame_dummy + Type: STT_FUNC + Section: .text + Value: 0x788 + - Name: '$d (6)' + Section: .init_array + Value: 0x10D80 + - Name: __frame_dummy_init_array_entry + Type: STT_OBJECT + Section: .init_array + Value: 0x10D80 + - Name: '$d (7)' + Section: .eh_frame + Value: 0x88C + - Name: '$d (8)' + Section: .bss + Value: 0x11010 + - Name: elf-init.oS + Type: STT_FILE + Index: SHN_ABS + - Name: '$x (8)' + Section: .text + Value: 0x790 + - Name: '$d (9)' + Section: .eh_frame + Value: 0x910 + - Name: 'crtstuff.c (1)' + Type: STT_FILE + Index: SHN_ABS + - Name: '$d (10)' + Section: .eh_frame + Value: 0x958 + - Name: __FRAME_END__ + Type: STT_OBJECT + Section: .eh_frame + Value: 0x958 + - Type: STT_FILE + Index: SHN_ABS + - Name: __init_array_end + Section: .init_array + Value: 0x10D88 + - Name: _DYNAMIC + Type: STT_OBJECT + Index: SHN_ABS + Value: 0x10D90 + - Name: __init_array_start + Section: .init_array + Value: 0x10D80 + - Name: __GNU_EH_FRAME_HDR + Section: .eh_frame_hdr + Value: 0x834 + - Name: _GLOBAL_OFFSET_TABLE_ + Type: STT_OBJECT + Index: SHN_ABS + Value: 0x10FC0 + - Name: _init + Type: STT_FUNC + Section: .init + Value: 0x5D0 + - Name: '$x (9)' + Section: .plt + Value: 0x5F0 + - Name: __libc_csu_fini + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x810 + Size: 0x4 + - Name: _ITM_deregisterTMCloneTable + Binding: STB_WEAK + - Name: data_start + Section: .data + Binding: STB_WEAK + Value: 0x11000 + - Name: __bss_start__ + Section: .bss + Binding: STB_GLOBAL + Value: 0x11010 + - Name: '__cxa_finalize@@GLIBC_2.17' + Type: STT_FUNC + Binding: STB_WEAK + - Name: _bss_end__ + Section: .bss + Binding: STB_GLOBAL + Value: 0x11018 + - Name: _edata + Section: .data + Binding: STB_GLOBAL + Value: 0x11010 + - Name: _fini + Type: STT_FUNC + Section: .fini + Binding: STB_GLOBAL + Value: 0x814 + Other: [ STV_HIDDEN ] + - Name: __bss_end__ + Section: .bss + Binding: STB_GLOBAL + Value: 0x11018 + - Name: '__libc_start_main@@GLIBC_2.17' + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: __data_start + Section: .data + Binding: STB_GLOBAL + Value: 0x11000 + - Name: __gmon_start__ + Binding: STB_WEAK + - Name: __dso_handle + Type: STT_OBJECT + Section: .data + Binding: STB_GLOBAL + Value: 0x11008 + Other: [ STV_HIDDEN ] + - Name: 'abort@@GLIBC_2.17' + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: _IO_stdin_used + Type: STT_OBJECT + Section: .rodata + Binding: STB_GLOBAL + Value: 0x828 + Size: 0x4 + - Name: __libc_csu_init + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x790 + Size: 0x7C + - Name: _end + Section: .bss + Binding: STB_GLOBAL + Value: 0x11018 + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x684 + - Name: __end__ + Section: .bss + Binding: STB_GLOBAL + Value: 0x11018 + - Name: __bss_start + Section: .bss + Binding: STB_GLOBAL + Value: 0x11010 + - Name: main + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x660 + Size: 0x24 + - Name: __TMC_END__ + Type: STT_OBJECT + Section: .data + Binding: STB_GLOBAL + Value: 0x11010 + Other: [ STV_HIDDEN ] + - Name: _ITM_registerTMCloneTable + Binding: STB_WEAK + - Name: 'printf@@GLIBC_2.17' + Type: STT_FUNC + Binding: STB_GLOBAL +DynamicSymbols: + - Name: .init + Type: STT_SECTION + Section: .init + Value: 0x5D0 + - Name: .data + Type: STT_SECTION + Section: .data + Value: 0x11000 + - Name: _ITM_deregisterTMCloneTable + Binding: STB_WEAK + - Name: __cxa_finalize + Type: STT_FUNC + Binding: STB_WEAK + - Name: __libc_start_main + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: __gmon_start__ + Binding: STB_WEAK + - Name: abort + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: _ITM_registerTMCloneTable + Binding: STB_WEAK + - Name: printf + Type: STT_FUNC + Binding: STB_GLOBAL +DWARF: + debug_str: + - ex.c + - printf + - '/home/yota9/src/ex' + - 'GNU C17 9.3.0 -mlittle-endian -mabi=lp64 -g -O3 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection' + - main + - char + debug_aranges: + - Length: 0x2C + Version: 2 + CuOffset: 0x0 + AddressSize: 0x8 + Descriptors: + - Address: 0x660 + Length: 0x24 + debug_ranges: + - Offset: 0x0 + AddrSize: 0x8 + Entries: + - LowOffset: 0x0 + HighOffset: 0x24 +... diff --git a/bolt/test/AArch64/go_dwarf.test b/bolt/test/AArch64/go_dwarf.test new file mode 100644 --- /dev/null +++ b/bolt/test/AArch64/go_dwarf.test @@ -0,0 +1,53 @@ +# Check that the llvm-bolt update the dwarf information correctly in case: +# - DW_AT_low_pc is nullified in case the DW_AT_ranges tag already exists. +# - DW_AT_high_pc is in the form of DW_FORM_addr. + +RUN: yaml2obj %p/Inputs/go_dwarf.yaml &> %t.exe +RUN: llvm-bolt %t.exe -o %t.bolt -update-debug-sections + +# Check the original binary values. +RUN: llvm-dwarfdump -debug-info %t.exe |& \ +RUN: FileCheck %s -check-prefix=CHECKORIG + +CHECKORIG: DW_TAG_compile_unit +CHECKORIG-NEXT: DW_AT_producer +CHECKORIG-NEXT: DW_AT_language (DW_LANG_C99) +CHECKORIG-NEXT: DW_AT_name +CHECKORIG-NEXT: DW_AT_comp_dir +CHECKORIG-NEXT: DW_AT_ranges (0x00000000 +CHECKORIG-NEXT: [0x0000000000000660, 0x0000000000000684)) +CHECKORIG-NEXT: DW_AT_low_pc (0x0000000000000660) + +CHECKORIG: DW_TAG_subprogram +CHECKORIG-NEXT: DW_AT_external (true) +CHECKORIG-NEXT: DW_AT_name ("main") +CHECKORIG-NEXT: DW_AT_decl_file +CHECKORIG-NEXT: DW_AT_decl_line (1) +CHECKORIG-NEXT: DW_AT_decl_column (0x05) +CHECKORIG-NEXT: DW_AT_type (0x00000090 "int") +CHECKORIG-NEXT: DW_AT_low_pc (0x0000000000000660) +CHECKORIG-NEXT: DW_AT_high_pc (0x0000000000000684) + + +# Check the bolted binary. +RUN: llvm-dwarfdump -debug-info %t.bolt |& FileCheck %s + +CHECK: DW_TAG_compile_unit +CHECK-NEXT: DW_AT_producer +CHECK-NEXT: DW_AT_language (DW_LANG_C99) +CHECK-NEXT: DW_AT_name +CHECK-NEXT: DW_AT_comp_dir +CHECK-NEXT: DW_AT_ranges (0x00000010 +CHECK-NEXT: [0x0000000000000660, 0x0000000000000684)) +CHECK-NEXT: DW_AT_low_pc (0x0000000000000000) +CHECK-NEXT: DW_AT_stmt_list (0x00000000) + +CHECK: DW_TAG_subprogram +CHECK-NEXT: DW_AT_external (true) +CHECK-NEXT: DW_AT_name ("main") +CHECK-NEXT: DW_AT_decl_file +CHECK-NEXT: DW_AT_decl_line (1) +CHECK-NEXT: DW_AT_decl_column (0x05) +CHECK-NEXT: DW_AT_type (0x00000090 "int") +CHECK-NEXT: DW_AT_low_pc (0x0000000000000660) +CHECK-NEXT: DW_AT_high_pc (0x0000000000000684)