[PATCH] D117216: updateDWARFObjectAddressRanges: nullify low pc
Vladislav Khmelevsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 05:51:32 PST 2022
yota9 created this revision.
yota9 added reviewers: maksfb, rafaelauler, Amir, ayermolo.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In case the case the DW_AT_ranges tag already exists for the object the
low pc values won't be updated and will be incorrect in
after-bolt binaries.
Due to the large test binary the test is prepared separately in
https://github.com/rafaelauler/bolt-tests/pull/8
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117216
Files:
bolt/lib/Rewrite/DWARFRewriter.cpp
Index: bolt/lib/Rewrite/DWARFRewriter.cpp
===================================================================
--- bolt/lib/Rewrite/DWARFRewriter.cpp
+++ bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -689,22 +689,27 @@
}
}
+ Optional<AttrInfo> 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<AttrInfo> AttrVal = findAttributeInfo(DIE, dwarf::DW_AT_ranges);
-
std::lock_guard<std::mutex> 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<AttrInfo> 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<AttrInfo> HighPCAttrInfo =
+ findAttributeInfo(DIE, dwarf::DW_AT_high_pc);
+ if (LowPCAttrInfo && HighPCAttrInfo) {
convertToRangesPatchAbbrev(*DIE.getDwarfUnit(), AbbreviationDecl,
AbbrevWriter, RangesBase);
convertToRangesPatchDebugInfo(DIE, DebugRangesOffset, DebugInfoPatcher,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117216.399641.patch
Type: text/x-patch
Size: 2091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/5fa15984/attachment.bin>
More information about the llvm-commits
mailing list