[PATCH] D153602: [DWARF] Adjust warning condition for .dwo sections with relocations
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 22 18:07:43 PDT 2023
MaskRay created this revision.
MaskRay added reviewers: debug-info, ayermolo, dblaikie, HaohaiWen.
Herald added a subscriber: hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
D106624 <https://reviews.llvm.org/D106624> added a .dwo warning (when there are relocations) that may fire for
non-debug sections, e.g. `.rodata.dwo` when there is a data symbol foo in
-fdata-sections mode. Adjust it to only warn for .debug sections.
While here, change the diagnostic to be more conventional
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages and use
the relocated section name instead of the relocation section name.
This change does not handle `.zdebug` (support was mostly removed from LLVM) or
`__debug` (Mach-O, no DWO support).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153602
Files:
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s
Index: llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s
===================================================================
--- llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s
+++ llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
# RUN: llvm-dwarfdump --debug-info %t.o | FileCheck %s
# RUN: llvm-dwarfdump --debug-info %t.o 2> %t.txt
-# RUN: cat %t.txt | FileCheck %s --check-prefix=PART2
+# RUN: FileCheck --input-file=%t.txt %s --check-prefix=PART2 --implicit-check-not=warning:
.section .debug_str.dwo,"MSe", at progbits,1
.dwo_producer:
@@ -33,6 +33,9 @@
.byte 0x00 # EOM(2)
.byte 0x00 # EOM(3)
+# PART2: warning: unexpected relocations for dwo section '.debug_abbrev.dwo'
+ .reloc ., R_X86_64_NONE, 0
+
.section .debug_info.dwo,"e", at progbits
# CHECK-LABEL: .debug_info.dwo
@@ -55,4 +58,10 @@
# CHECK: 0x00000014: DW_TAG_compile_unit
# CHECK-NEXT: DW_AT_producer ("Handmade DWO producer")
# CHECK-NEXT: DW_AT_name ("V5_dwo_compile_unit")
-# PART2: warning: Unexpected relocations for dwo section rela.debug_info.dwo
+# PART2: warning: unexpected relocations for dwo section '.debug_info.dwo'
+
+## No warning, even if their names end with ".dwo".
+ .section .rodata.dwo,"a"
+ .long ext
+ .section .foo.dwo,""
+ .long .dwo_producer
Index: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1887,10 +1887,6 @@
S.Data = Data;
}
- if (RelocatedSection != Obj.section_end() && Name.contains(".dwo"))
- HandleWarning(
- createError("Unexpected relocations for dwo section " + Name));
-
if (RelocatedSection == Obj.section_end() ||
(RelocAction == DWARFContext::ProcessDebugRelocations::Ignore))
continue;
@@ -1916,6 +1912,12 @@
if (!L && isa<MachOObjectFile>(&Obj))
continue;
+ if (!Section.relocations().empty() && Name.ends_with(".dwo") &&
+ RelSecName.startswith(".debug")) {
+ HandleWarning(createError("unexpected relocations for dwo section '" +
+ RelSecName + "'"));
+ }
+
RelSecName = RelSecName.substr(
RelSecName.find_first_not_of("._z")); // Skip . and _ prefixes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153602.533837.patch
Type: text/x-patch
Size: 2452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230623/2c85c939/attachment.bin>
More information about the llvm-commits
mailing list