[lld-macho] Standardize error messages
Errors / warnings that originate from a particular file should be of the form `$file: $message`. Reviewed By: #lld-macho, keith Differential Revision: https://reviews.llvm.org/D140634
This commit is contained in:
parent
c10b0dfdc8
commit
0e8d4980a8
@ -624,7 +624,8 @@ void ARM64::applyOptimizationHints(uint8_t *outBuf, const ObjFile &obj) const {
|
||||
|
||||
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;
|
||||
|
||||
@ -1648,11 +1648,12 @@ static bool isImplicitlyLinked(StringRef path) {
|
||||
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 @@ DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella,
|
||||
} 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 @@ DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella,
|
||||
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 @@ void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) {
|
||||
|
||||
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 @@ void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) {
|
||||
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 @@ void DylibFile::handleLDInstallNameSymbol(StringRef name,
|
||||
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 @@ void DylibFile::handleLDHideSymbol(StringRef name, StringRef originalName) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -269,6 +269,8 @@ private:
|
||||
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<llvm::CachedHashStringRef> hiddenSymbols;
|
||||
};
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user