diff --git a/lld/MachO/Arch/ARM64.cpp b/lld/MachO/Arch/ARM64.cpp --- a/lld/MachO/Arch/ARM64.cpp +++ b/lld/MachO/Arch/ARM64.cpp @@ -624,7 +624,8 @@ auto isValidOffset = [&](uint64_t offset) { if (offset < sectionAddr || offset >= sectionAddr + section->getSize()) { - error("linker optimization hint spans multiple sections"); + error(toString(&obj) + + ": linker optimization hint spans multiple sections"); return false; } return true; diff --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h --- a/lld/MachO/InputFiles.h +++ b/lld/MachO/InputFiles.h @@ -269,6 +269,8 @@ void handleLDHideSymbol(StringRef name, StringRef originalName); void checkAppExtensionSafety(bool dylibIsAppExtensionSafe) const; void parseExportedSymbols(uint32_t offset, uint32_t size); + void loadReexport(StringRef path, DylibFile *umbrella, + const llvm::MachO::InterfaceFile *currentTopLevelTapi); llvm::DenseSet hiddenSymbols; }; diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -1648,11 +1648,12 @@ return false; } -static void loadReexport(StringRef path, DylibFile *umbrella, +void DylibFile::loadReexport(StringRef path, DylibFile *umbrella, const InterfaceFile *currentTopLevelTapi) { DylibFile *reexport = findDylib(path, umbrella, currentTopLevelTapi); if (!reexport) - error("unable to locate re-export with install name " + path); + error(toString(this) + ": unable to locate re-export with install name " + + path); } DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella, @@ -1676,7 +1677,7 @@ } else if (!isBundleLoader) { // macho_executable and macho_bundle don't have LC_ID_DYLIB, // so it's OK. - error("dylib " + toString(this) + " missing LC_ID_DYLIB load command"); + error(toString(this) + ": dylib missing LC_ID_DYLIB load command"); return; } @@ -1705,8 +1706,8 @@ if (dyldInfo && exportsTrie) { // It's unclear what should happen in this case. Maybe we should only error // out if the two load commands refer to different data? - error("dylib " + toString(this) + - " has both LC_DYLD_INFO_ONLY and LC_DYLD_EXPORTS_TRIE"); + error(toString(this) + + ": dylib has both LC_DYLD_INFO_ONLY and LC_DYLD_EXPORTS_TRIE"); return; } else if (dyldInfo) { parseExportedSymbols(dyldInfo->export_off, dyldInfo->export_size); @@ -2003,13 +2004,14 @@ VersionTuple start; if (start.tryParse(startVersion)) { - warn("failed to parse start version, symbol '" + originalName + - "' ignored"); + warn(toString(this) + ": failed to parse start version, symbol '" + + originalName + "' ignored"); return; } VersionTuple end; if (end.tryParse(endVersion)) { - warn("failed to parse end version, symbol '" + originalName + "' ignored"); + warn(toString(this) + ": failed to parse end version, symbol '" + + originalName + "' ignored"); return; } if (config->platformInfo.minimum < start || @@ -2022,7 +2024,8 @@ if (!compatVersion.empty()) { VersionTuple cVersion; if (cVersion.tryParse(compatVersion)) { - warn("failed to parse compatibility version, symbol '" + originalName + + warn(toString(this) + + ": failed to parse compatibility version, symbol '" + originalName + "' ignored"); return; } @@ -2061,7 +2064,8 @@ std::tie(condition, installName) = name.split('$'); VersionTuple version; if (!condition.consume_front("os") || version.tryParse(condition)) - warn("failed to parse os version, symbol '" + originalName + "' ignored"); + warn(toString(this) + ": failed to parse os version, symbol '" + + originalName + "' ignored"); else if (version == config->platformInfo.minimum) this->installName = saver().save(installName); } @@ -2076,7 +2080,7 @@ std::tie(minVersion, symbolName) = name.split('$'); VersionTuple versionTup; if (versionTup.tryParse(minVersion)) { - warn("Failed to parse hidden version, symbol `" + originalName + + warn(toString(this) + ": failed to parse hidden version, symbol `" + originalName + "` ignored."); return; } diff --git a/lld/test/MachO/invalid/invalid-loh.s b/lld/test/MachO/invalid/invalid-loh.s --- a/lld/test/MachO/invalid/invalid-loh.s +++ b/lld/test/MachO/invalid/invalid-loh.s @@ -1,9 +1,10 @@ # REQUIRES: aarch64 +# RUN: rm -rf %t; mkdir -p %t -# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o -# RUN: not %lld -arch arm64 %t.o -o /dev/null 2>&1 | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/test.o +# RUN: not %lld -arch arm64 %t/test.o -o /dev/null 2>&1 | FileCheck %s -# CHECK: error: linker optimization hint spans multiple sections +# CHECK: error: {{.*}}test.o: linker optimization hint spans multiple sections .globl _main _main: diff --git a/lld/test/MachO/invalid/no-id-dylink.yaml b/lld/test/MachO/invalid/no-id-dylink.yaml --- a/lld/test/MachO/invalid/no-id-dylink.yaml +++ b/lld/test/MachO/invalid/no-id-dylink.yaml @@ -3,7 +3,7 @@ # RUN: yaml2obj %s -o %t/libnoid.dylib # RUN: echo ".globl _main; .text; _main: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/no-id-dylink.o # RUN: not %lld -o %t/no-id-dylink -L%t -lnoid %t/no-id-dylink.o 2>&1 | FileCheck %s -# CHECK: error: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command +# CHECK: error: {{.*}}libnoid.dylib: dylib missing LC_ID_DYLIB load command ## This YAML file was originally generated from linking the following source ## input with ld64 and passing the resulting binary through obj2yaml: diff --git a/lld/test/MachO/link-search-at-executable-path.s b/lld/test/MachO/link-search-at-executable-path.s --- a/lld/test/MachO/link-search-at-executable-path.s +++ b/lld/test/MachO/link-search-at-executable-path.s @@ -20,7 +20,7 @@ ## It also doesn't help if the needed reexport isn't next to the library. # RUN: not %lld -lSystem %t/main.o %t/libbar.dylib -o %t/test 2>&1 | FileCheck --check-prefix=ERR %s -# ERR: error: unable to locate re-export with install name @executable_path/libfoo.dylib +# ERR: error: {{.*}}libbar.dylib: unable to locate re-export with install name @executable_path/libfoo.dylib #--- foo.s .globl _foo diff --git a/lld/test/MachO/special-symbol-ld-install-name.s b/lld/test/MachO/special-symbol-ld-install-name.s --- a/lld/test/MachO/special-symbol-ld-install-name.s +++ b/lld/test/MachO/special-symbol-ld-install-name.s @@ -23,7 +23,7 @@ # RUN: %no-fatal-warnings-lld -o %t/libfoo3.dylib %t/libLDInstallNameInvalid.tbd %t/foo.o -dylib \ # RUN: -platform_version macos 11.0.0 11.0.0 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s -# INVALID-VERSION: failed to parse os version, symbol '$ld$install_name$os11.a$/New' ignored +# INVALID-VERSION: libLDInstallNameInvalid.tbd(/Old): failed to parse os version, symbol '$ld$install_name$os11.a$/New' ignored ## Case 3: If there's another library that has '/New' as its original ## install_name, we should take current-version and compatibility-version from diff --git a/lld/test/MachO/special-symbol-ld-previous.s b/lld/test/MachO/special-symbol-ld-previous.s --- a/lld/test/MachO/special-symbol-ld-previous.s +++ b/lld/test/MachO/special-symbol-ld-previous.s @@ -59,9 +59,9 @@ # RUN: %no-fatal-warnings-lld -o %t/libfoo1.dylib %t/libLDPreviousInvalid.tbd %t/ref_xxx.o -dylib \ # RUN: -platform_version macos 11.0.0 11.0.0 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s -# INVALID-VERSION-DAG: failed to parse start version, symbol '$ld$previous$/New$1.2.3$1$3.a$14.0$$' ignored -# INVALID-VERSION-DAG: failed to parse end version, symbol '$ld$previous$/New$1.2.3$1$3.0$14.b$$' ignored -# INVALID-VERSION-DAG: failed to parse compatibility version, symbol '$ld$previous$/New$1.2.c$1$3.0$14.0$$' ignored +# INVALID-VERSION-DAG: libLDPreviousInvalid.tbd(/Old): failed to parse start version, symbol '$ld$previous$/New$1.2.3$1$3.a$14.0$$' ignored +# INVALID-VERSION-DAG: libLDPreviousInvalid.tbd(/Old): failed to parse end version, symbol '$ld$previous$/New$1.2.3$1$3.0$14.b$$' ignored +# INVALID-VERSION-DAG: libLDPreviousInvalid.tbd(/Old): failed to parse compatibility version, symbol '$ld$previous$/New$1.2.c$1$3.0$14.0$$' ignored #--- ref_xxx.s .long _xxx@GOTPCREL diff --git a/lld/test/MachO/sub-library.s b/lld/test/MachO/sub-library.s --- a/lld/test/MachO/sub-library.s +++ b/lld/test/MachO/sub-library.s @@ -58,7 +58,7 @@ # RUN: rm -f %t/libgoodbye.dylib # RUN: not %lld -o %t/sub-library -L%t -lsuper %t/sub-library.o 2>&1 \ # RUN: | FileCheck %s --check-prefix=MISSING-REEXPORT -DDIR=%t -# MISSING-REEXPORT: error: unable to locate re-export with install name [[DIR]]/libgoodbye.dylib +# MISSING-REEXPORT: error: {{.*}}libsuper.dylib: unable to locate re-export with install name [[DIR]]/libgoodbye.dylib ## We can match dylibs without extensions too.