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

Just something I noticed while debugging arm relocations...

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D97078
This commit is contained in:
Jez Ng 2021-02-23 21:41:52 -05:00
parent 59f0e4627a
commit e5d780e049
2 changed files with 9 additions and 7 deletions

View File

@ -203,15 +203,15 @@ static InputSection *findContainingSubsection(SubsectionMap &map,
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 @@ void ObjFile::parseRelocations(const section_64 &sec,
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");

View File

@ -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: