[PATCH] D82828: [ELF] Don't resolve a relocation in .debug_line referencing an ICF folded symbol to the tombstone value
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 14:05:02 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6ad78fe0503: [ELF] Don't resolve a relocation in .debug_line referencing an ICF folded… (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82828/new/
https://reviews.llvm.org/D82828
Files:
lld/ELF/InputSection.cpp
lld/test/ELF/debug-dead-reloc-icf.s
Index: lld/test/ELF/debug-dead-reloc-icf.s
===================================================================
--- lld/test/ELF/debug-dead-reloc-icf.s
+++ lld/test/ELF/debug-dead-reloc-icf.s
@@ -10,6 +10,9 @@
# CHECK: Contents of section .debug_info:
# CHECK-NEXT: 0000 {{[0-9a-f]+}}000 00000000 ffffffff ffffffff
+# CHECK: Contents of section .debug_line:
+# CHECK-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000
+# CHECK-SAME: [[ADDR]] 00000000
.globl _start
_start:
@@ -22,3 +25,11 @@
.section .debug_info
.quad .text+8
.quad .text.1+8
+
+## .debug_line contributions associated with folded-in functions will describe
+## different lines to the canonical function. Leaving a tombstone value would
+## prevent users from setting breakpoints on the folded-in functions.
+## Instead resolve the relocation to the folded .text.1 to .text
+.section .debug_line
+ .quad .text
+ .quad .text.1
Index: lld/ELF/InputSection.cpp
===================================================================
--- lld/ELF/InputSection.cpp
+++ lld/ELF/InputSection.cpp
@@ -856,6 +856,7 @@
const bool isDebug = isDebugSection(*this);
const bool isDebugLocOrRanges =
isDebug && (name == ".debug_loc" || name == ".debug_ranges");
+ const bool isDebugLine = isDebug && name == ".debug_line";
for (const RelTy &rel : rels) {
RelType type = rel.getType(config->isMips64EL);
@@ -926,12 +927,15 @@
// If the referenced symbol is discarded (made Undefined), or the
// section defining the referenced symbol is garbage collected,
// sym.getOutputSection() is nullptr. `ds->section->repl != ds->section`
- // catches the ICF folded case.
+ // catches the ICF folded case. However, resolving a relocation in
+ // .debug_line to -1 would stop debugger users from setting breakpoints on
+ // the folded-in function, so exclude .debug_line.
//
// For pre-DWARF-v5 .debug_loc and .debug_ranges, -1 is a reserved value
// (base address selection entry), so -2 is used.
auto *ds = dyn_cast<Defined>(&sym);
- if (!sym.getOutputSection() || (ds && ds->section->repl != ds->section)) {
+ if (!sym.getOutputSection() ||
+ (ds && ds->section->repl != ds->section && !isDebugLine)) {
target->relocateNoSym(bufLoc, type,
isDebugLocOrRanges ? UINT64_MAX - 1 : UINT64_MAX);
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82828.274913.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200701/fbe2fec0/attachment.bin>
More information about the llvm-commits
mailing list