[PATCH] D97078: [lld-macho] Use full input file name in invalid relocation error message

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 19:02:52 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5d780e049c2: [lld-macho] Use full input file name in invalid relocation error message (authored by int3).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97078/new/

https://reviews.llvm.org/D97078

Files:
  lld/MachO/InputFiles.cpp
  lld/test/MachO/invalid/invalid-relocation-pcrel.yaml


Index: lld/test/MachO/invalid/invalid-relocation-pcrel.yaml
===================================================================
--- lld/test/MachO/invalid/invalid-relocation-pcrel.yaml
+++ lld/test/MachO/invalid/invalid-relocation-pcrel.yaml
@@ -1,8 +1,10 @@
 # REQUIRES: x86
-# RUN: yaml2obj %s -o %t.o
-# RUN: not %lld -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o
+# RUN: rm -rf %t; mkdir %t
+# RUN: yaml2obj %s -o %t/test.o
+# RUN: llvm-ar rcs %t/test.a %t/test.o
+# RUN: not %lld -o /dev/null %t/test.a 2>&1 | FileCheck %s
 #
-# CHECK: error: UNSIGNED relocation must not be PC-relative at offset 1 of __TEXT,__text in [[FILE]]
+# CHECK: error: UNSIGNED relocation must not be PC-relative at offset 1 of __TEXT,__text in {{.*}}test.a(test.o)
 
 !mach-o
 FileHeader:
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -203,15 +203,15 @@
   return it->second;
 }
 
-static bool validateRelocationInfo(MemoryBufferRef mb, const section_64 &sec,
+static bool validateRelocationInfo(InputFile *file, const section_64 &sec,
                                    relocation_info rel) {
   const TargetInfo::RelocAttrs &relocAttrs = target->getRelocAttrs(rel.r_type);
   bool valid = true;
-  auto message = [relocAttrs, mb, sec, rel, &valid](const Twine &diagnostic) {
+  auto message = [relocAttrs, file, sec, rel, &valid](const Twine &diagnostic) {
     valid = false;
     return (relocAttrs.name + " relocation " + diagnostic + " at offset " +
             std::to_string(rel.r_address) + " of " + sec.segname + "," +
-            sec.sectname + " in " + mb.getBufferIdentifier())
+            sec.sectname + " in " + toString(file))
         .str();
   };
 
@@ -273,7 +273,7 @@
       relInfo = relInfos[++i];
     }
     assert(i < relInfos.size());
-    if (!validateRelocationInfo(mb, sec, relInfo))
+    if (!validateRelocationInfo(this, sec, relInfo))
       continue;
     if (relInfo.r_address & R_SCATTERED)
       fatal("TODO: Scattered relocations not supported");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97078.325959.patch
Type: text/x-patch
Size: 2083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/b37e5774/attachment.bin>


More information about the llvm-commits mailing list