-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LLD] Tombstone LocalTU entry in .debug_names #70701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d2665cc
792155d
854a281
b716d70
19fa33e
a69878b
8e5c0b7
be18f4f
e25f409
03afbda
036dbef
1dfdf18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,6 @@ | |
| #include "llvm/Support/Compression.h" | ||
| #include "llvm/Support/Endian.h" | ||
| #include "llvm/Support/xxhash.h" | ||
| #include <algorithm> | ||
| #include <mutex> | ||
| #include <vector> | ||
|
|
||
| using namespace llvm; | ||
|
|
@@ -888,6 +886,7 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) { | |
| const bool isDebug = isDebugSection(*this); | ||
| const bool isDebugLocOrRanges = | ||
| isDebug && (name == ".debug_loc" || name == ".debug_ranges"); | ||
| const bool isDebugNames = isDebug && name == ".debug_names"; | ||
| const bool isDebugLine = isDebug && name == ".debug_line"; | ||
| std::optional<uint64_t> tombstone; | ||
| for (const auto &patAndValue : llvm::reverse(config->deadRelocInNonAlloc)) | ||
|
|
@@ -918,7 +917,8 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) { | |
| continue; | ||
|
|
||
| if (tombstone || | ||
| (isDebug && (type == target.symbolicRel || expr == R_DTPREL))) { | ||
| ((isDebug && (type == target.symbolicRel || expr == R_DTPREL))) || | ||
|
||
| isDebugNames) { | ||
| // Resolve relocations in .debug_* referencing (discarded symbols or ICF | ||
| // folded section symbols) to a tombstone value. Resolving to addend is | ||
| // unsatisfactory because the result address range may collide with a | ||
|
|
@@ -947,6 +947,22 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) { | |
| // | ||
| // TODO To reduce disruption, we use 0 instead of -1 as the tombstone | ||
| // value. Enable -1 in a future release. | ||
|
|
||
| if (isDebugNames && dyn_cast<Undefined>(&sym)) { | ||
| uint64_t maxVal = 0; | ||
| switch (type) { | ||
| case R_X86_64_64: | ||
| maxVal = llvm::maxUIntN(64); | ||
| break; | ||
| case R_X86_64_32: | ||
| maxVal = llvm::maxUIntN(32); | ||
| break; | ||
| default: | ||
| llvm_unreachable("Unsupported relocation type in .debug_names."); | ||
| } | ||
|
||
| target.relocateNoSym(bufLoc, type, SignExtend64<bits>(maxVal)); | ||
| continue; | ||
| } | ||
| auto *ds = dyn_cast<Defined>(&sym); | ||
| if (!sym.getOutputSection() || (ds && ds->folded && !isDebugLine)) { | ||
| // If -z dead-reloc-in-nonalloc= is specified, respect it. | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // REQUIRES: x86 | ||
|
||
| // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/dwarf5-64-debug-names-type-comdat-main.s -o %t.o | ||
| // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/dwarf5-64-debug-names-type-comdat-helper.s -o %t1.o | ||
| // RUN: ld.lld %t.o %t1.o -o %t1 | ||
| // RUN: llvm-readelf --relocs %t.o | FileCheck --check-prefix=RELOCMAIN %s | ||
| // RUN: llvm-dwarfdump --debug-names %t1 | FileCheck %s | ||
|
|
||
| // Test checks that LLD tombstones TU section that was de-duplicated using COMDAT to the maxium value. | ||
| // For some reason llvm-dwarfdump doesn't print out full 64bitt offset at the moment. | ||
| // Working around it by checking that relocation is 64 bit. | ||
|
|
||
| // RELOCMAIN: rela.debug_names | ||
| // RELOCMAIN-NEXT: Offset | ||
| // RELOCMAIN-NEXT: R_X86_64_64 | ||
| // RELOCMAIN-SAME: .debug_info + 0 | ||
| // RELOCMAIN-NEXT: R_X86_64_64 | ||
| // RELOCMAIN-SAME: .debug_info + 0 | ||
|
|
||
| // CHECK: LocalTU[0]: 0x00000000 | ||
| // CHECK: LocalTU[0]: 0xffffffffffffffff | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // REQUIRES: x86 | ||
|
||
| // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-type-comdat-main.s -o %t.o | ||
| // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-type-comdat-helper.s -o %t1.o | ||
| // RUN: ld.lld %t.o %t1.o -o %t1 | ||
| // RUN: llvm-dwarfdump --debug-names %t1 | FileCheck %s | ||
|
|
||
| // Test checks that LLD tombstones TU section that was de-duplicated using COMDAT to the maxium value. | ||
|
|
||
| // CHECK: LocalTU[0]: 0x00000000 | ||
| // CHECK: LocalTU[0]: 0xffffffff | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the headers. mutex is used by std::mutex in this file.