[lld] 20b4704 - [ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like non-global symbols

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 25 23:46:52 PST 2021


Author: Fangrui Song
Date: 2021-12-25T23:46:47-08:00
New Revision: 20b4704da315f569d417a55313c61b792e568a07

URL: https://github.com/llvm/llvm-project/commit/20b4704da315f569d417a55313c61b792e568a07
DIFF: https://github.com/llvm/llvm-project/commit/20b4704da315f569d417a55313c61b792e568a07.diff

LOG: [ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like non-global symbols

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp
    lld/test/ELF/aarch64-movw-error.s
    lld/test/ELF/arm-adr-err-long.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 719386e2e71fc..5841c509aa67e 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -100,11 +100,11 @@ void elf::reportRangeError(uint8_t *loc, const Relocation &rel, const Twine &v,
                            int64_t min, uint64_t max) {
   ErrorPlace errPlace = getErrorPlace(loc);
   std::string hint;
-  if (rel.sym && !rel.sym->isLocal())
+  if (rel.sym && !rel.sym->isSection())
     hint = "; references " + lld::toString(*rel.sym);
   if (!errPlace.srcLoc.empty())
     hint += "\n>>> referenced by " + errPlace.srcLoc;
-  if (rel.sym && !rel.sym->isLocal())
+  if (rel.sym && !rel.sym->isSection())
     hint += getDefinedLocation(*rel.sym);
 
   if (errPlace.isec && errPlace.isec->name.startswith(".debug"))

diff  --git a/lld/test/ELF/aarch64-movw-error.s b/lld/test/ELF/aarch64-movw-error.s
index 03575b1fce264..a5bd2c9d88557 100644
--- a/lld/test/ELF/aarch64-movw-error.s
+++ b/lld/test/ELF/aarch64-movw-error.s
@@ -36,11 +36,11 @@ movn x0, #:prel_g1:.-0x100010000
 movn x0, #:prel_g2:.-0x1000100000000
 
 movz x0, #:tprel_g0: v1
-# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G0 out of range: 65552 is not in [-65536, 65535]
+# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G0 out of range: 65552 is not in [-65536, 65535]; references v1
 movz x0, #:tprel_g1: v2
-# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G1 out of range: 4295032848 is not in [-4294967296, 4294967295]
+# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G1 out of range: 4295032848 is not in [-4294967296, 4294967295]; references v2
 movz x0, #:tprel_g2: v3
-# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G2 out of range: 281479271743496 is not in [-281474976710656, 281474976710655]
+# CHECK: relocation R_AARCH64_TLSLE_MOVW_TPREL_G2 out of range: 281479271743496 is not in [-281474976710656, 281474976710655]; references v3
 
 .section .tbss,"awT", at nobits
 .balign 16

diff  --git a/lld/test/ELF/arm-adr-err-long.s b/lld/test/ELF/arm-adr-err-long.s
index a4aa86b6eb961..0fd6beaba5121 100644
--- a/lld/test/ELF/arm-adr-err-long.s
+++ b/lld/test/ELF/arm-adr-err-long.s
@@ -49,7 +49,7 @@ _start:
  .inst 0xe1c000d0 // ldrd r0, r1, [r0, #0]
  .reloc 32, R_ARM_ALU_PC_G0_NC, dat2
  .reloc 36, R_ARM_ALU_PC_G1_NC, dat2
-// CHECK: {{.*}}.s.tmp.o:(.text.1+0x28): relocation R_ARM_LDRS_PC_G2 out of range: 4056 is not in [0, 255]
+// CHECK: {{.*}}.s.tmp.o:(.text.1+0x28): relocation R_ARM_LDRS_PC_G2 out of range: 4056 is not in [0, 255]; references dat2
  .reloc 40, R_ARM_LDRS_PC_G2, dat2
 
  .section .text.2, "ax", %progbits


        


More information about the llvm-commits mailing list