[PATCH] D94323: [dsymutil] Support finding relocations in debug_addr for DWARF5
Alexey Lapshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 14:14:50 PST 2021
avl added a comment.
If I understood correctly, It looks like this change is not enough to work properly for DWARF5.
Currently, relocation is checked using offsets to the attribute:
bool DwarfLinkerForBinary::AddressManager::hasLiveAddressRange(
const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
Optional<uint32_t> LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
if (!LowPcIdx)
return false;
uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
uint64_t LowPcOffset, LowPcEndOffset;
std::tie(LowPcOffset, LowPcEndOffset) =
getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
return hasValidRelocationAt(LowPcOffset, LowPcEndOffset, MyInfo); <<<< check relocation inside debug_info
}
i.e. we check whether relocation exists between LowPcOffset, LowPcEndOffset of dwarf::DW_AT_low_pc inside debug_info table.
If we would read relocations for "debug_addr" table instead of the "debug_info" table then we would check the wrong relocations. To work properly we would need to recognize offset inside "debug_addr". Something like this(I did not check whether it could be compiled or whether it is full enough):
Optional<uint32_t> LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
if (!LowPcIdx)
return false;
if ( Abbrev->getFormByIndex(*LowPcIdx) == DW_FORM_addr ) {
uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
uint64_t LowPcOffset, LowPcEndOffset;
std::tie(LowPcOffset, LowPcEndOffset) =
getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
return hasValidRelocationAt(LowPcOffset, LowPcEndOffset, MyInfo); <<<< check relocations inside debug_info
} else ( Abbrev->getFormByIndex(*LowPcIdx) == DW_FORM_addrx) {
Optional<DWARFFormValue> OffsetValue = DIE.find(dwarf::DW_AT_low_pc);
if (OffsetValue) {
uint64_t LowPcOffset = OffsetValue->getRawUValue();
uint64_t LowPcEndOffset = LowPcOffset + 4;
return hasValidRelocationAt(LowPcOffset, LowPcEndOffset, MyInfo); <<<< check relocations inside debug_addr
}
}
i.e. in case when we do "findValidRelocs(Section, Obj, DMO)" for "debug_addr" then we need to use other offsets(LowPcOffset/LowPcEndOffset) inside hasLiveMemoryLocation/hasLiveAddressRange.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94323/new/
https://reviews.llvm.org/D94323
More information about the llvm-commits
mailing list