DebugInfo: Fix bug in addr+offset exprloc to use DWARFv5 addrx op instead of DWARFv4 GNU extension

This commit is contained in:
David Blaikie 2021-01-27 18:39:07 -08:00
parent 8a77056256
commit dd7297e1bf
2 changed files with 14 additions and 18 deletions

View File

@ -319,22 +319,18 @@ void DwarfUnit::addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label) {
const MCSymbol *Base = nullptr; const MCSymbol *Base = nullptr;
if (Label->isInSection() && DD->useAddrOffsetExpressions()) if (Label->isInSection() && DD->useAddrOffsetExpressions())
Base = DD->getSectionLabel(&Label->getSection()); Base = DD->getSectionLabel(&Label->getSection());
if (!Base) {
uint32_t Index = DD->getAddressPool().getIndex(Label); uint32_t Index = DD->getAddressPool().getIndex(Base ? Base : Label);
if (DD->getDwarfVersion() >= 5) {
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx); if (DD->getDwarfVersion() >= 5) {
addUInt(Die, dwarf::DW_FORM_addrx, Index); addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
} else { addUInt(Die, dwarf::DW_FORM_addrx, Index);
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index); } else {
addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index); addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
} addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
return;
} }
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index); if (Base && Base != Label) {
addUInt(Die, dwarf::DW_FORM_GNU_addr_index,
DD->getAddressPool().getIndex(Base));
if (Base != Label) {
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u); addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
addLabelDelta(Die, (dwarf::Attribute)0, Label, Base); addLabelDelta(Die, (dwarf::Attribute)0, Label, Base);
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus); addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);

View File

@ -51,20 +51,20 @@
; CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000 ".text") ; CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000 ".text")
; CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000010) ; CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000010)
; CHECK: DW_TAG_inlined_subroutine ; CHECK: DW_TAG_inlined_subroutine
; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x9, DW_OP_plus) ; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x9, DW_OP_plus)
; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000005) ; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000005)
; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = [[INL_RANGE:.*]] ; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = [[INL_RANGE:.*]]
; CHECK: DW_TAG_call_site ; CHECK: DW_TAG_call_site
; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000009 ".text") ; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000009 ".text")
; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x9, DW_OP_plus) ; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x9, DW_OP_plus)
; CHECK: DW_TAG_call_site ; CHECK: DW_TAG_call_site
; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000002) address = 0x000000000000000e ".text") ; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000002) address = 0x000000000000000e ".text")
; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0xe, DW_OP_plus) ; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xe, DW_OP_plus)
; CHECK: NULL ; CHECK: NULL
; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}} "f1" ; CHECK: DW_AT_name {{.*}} "f1"
; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_subprogram
; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x20, DW_OP_plus) ; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x20, DW_OP_plus)
; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000006) ; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000006)
; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = [[F5_RANGE:.*]] ; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = [[F5_RANGE:.*]]
; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_subprogram