diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/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"); diff --git a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml b/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml --- a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml +++ b/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: