[PATCH] D155666: Do not emit a .debug_addr section if the DW_AT_addr_base is not set.

Shubham Sandeep Rastogi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 18:39:05 PDT 2023


rastogishubham created this revision.
rastogishubham added reviewers: avl, aprantl, JDevlieghere.
rastogishubham added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
rastogishubham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If the DW_AT_addr_base is not set, dsymutil should not copy any addrx attributes into the cloned DIE, which will result in no .debug_addr section being emitted.


https://reviews.llvm.org/D155666

Files:
  llvm/lib/DWARFLinker/DWARFLinker.cpp


Index: llvm/lib/DWARFLinker/DWARFLinker.cpp
===================================================================
--- llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1365,6 +1365,11 @@
   std::optional<uint64_t> Addr = AddrAttribute->getAsAddress();
   if (!Addr) {
     Linker.reportWarning("Cann't read address attribute value.", ObjFile);
+    // If the attribute is of form addrx* and the DW_AT_addr_base is not set, do
+    // not emit the .debug_addr section
+    if (AttrSpec.Form != dwarf::DW_FORM_addr &&
+        !AddrAttribute->getUnit()->getAddrOffsetSectionBase())
+      return 0;
     Addr = 0;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155666.541805.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/522a3a3b/attachment.bin>


More information about the llvm-commits mailing list