[clang-tools-extra] [lld] [llvm] [lld/ELF] Hint if R_X86_64_PC32 overflows and references a SHF_X86_64_LARGE section (PR #73045)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 14:21:47 PST 2024


================
@@ -105,6 +105,13 @@ void elf::reportRangeError(uint8_t *loc, const Relocation &rel, const Twine &v,
       hint = "; references '" + lld::toString(*rel.sym) + '\'';
     else if (auto *d = dyn_cast<Defined>(rel.sym))
       hint = ("; references section '" + d->section->name + "'").str();
+
+    if (config->emachine == EM_X86_64 && rel.type == R_X86_64_PC32 &&
+        rel.sym->getOutputSection() &&
+        (rel.sym->getOutputSection()->flags & SHF_X86_64_LARGE)) {
+      hint += "; a R_X86_64_PC32 relocation should not reference a section "
----------------
MaskRay wrote:

In the diagnostic the sentence can be more precise. Perhaps `; R_X86_64_PC32 should not reference a section marked `. In other messages we do use `R_*` to refer to a relocation of the type.

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


More information about the cfe-commits mailing list