[lld] [LLD] Tombstone LocalTU entry in .debug_names (PR #70701)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 16:33:20 PDT 2023


================
@@ -896,6 +893,16 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) {
       break;
     }
 
+  const uint64_t debugTombstone = StringSwitch<uint64_t>(name)
+                                      .Case(".debug_ranges", 1)
+                                      .Case(".debug_loc", 1)
+                                      .Case(".debug_names", llvm::maxUIntN(32))
+                                      .Default(0);
+  // If -z dead-reloc-in-nonalloc= is specified, respect it.
+  if (!tombstone && isDebug)
+    tombstone = debugTombstone;
+  else if (tombstone)
+    tombstone = SignExtend64<bits>(*tombstone);
----------------
ayermolo wrote:

It is the same as original logic. It would go into if condition if tombstone is specified, and always extend.
bits == 64
So at least on ELF64 this is no-op. So TBH I am not sure why it's there.

```
template <unsigned B> constexpr inline int64_t SignExtend64(uint64_t x) {
  static_assert(B > 0, "Bit width can't be 0.");
  static_assert(B <= 64, "Bit width out of range.");
  return int64_t(x << (64 - B)) >> (64 - B);
}
```

https://github.com/llvm/llvm-project/pull/70701


More information about the llvm-commits mailing list