[lld] 8d80139 - [lld/mac] fix test failure after 24979e111
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 1 13:35:44 PDT 2021
Author: Nico Weber
Date: 2021-06-01T16:35:25-04:00
New Revision: 8d80139cccf449a3227e0614098cf713ad1b0e73
URL: https://github.com/llvm/llvm-project/commit/8d80139cccf449a3227e0614098cf713ad1b0e73
DIFF: https://github.com/llvm/llvm-project/commit/8d80139cccf449a3227e0614098cf713ad1b0e73.diff
LOG: [lld/mac] fix test failure after 24979e111
If there is an error reading the dylib, we shouldn't try
to load its reexports.
Caught e.g. by https://lab.llvm.org/buildbot/#/builders/36/builds/8946
Added:
Modified:
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.h
Removed:
################################################################################
diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index d7ab5583f744..93bb8f07b738 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -222,7 +222,8 @@ Optional<DylibFile *> macho::loadDylib(MemoryBufferRef mbref,
// reference might become invalid after parseReexports() -- so copy the
// pointer it refers to before going on.
newFile = file;
- newFile->parseReexports(**result);
+ if (newFile->exportingFile)
+ newFile->parseReexports(**result);
} else {
assert(magic == file_magic::macho_dynamically_linked_shared_lib ||
magic == file_magic::macho_dynamically_linked_shared_lib_stub ||
@@ -233,7 +234,8 @@ Optional<DylibFile *> macho::loadDylib(MemoryBufferRef mbref,
// parseLoadCommands() can also recursively call loadDylib(). See comment
// in previous block for why this means we must copy `file` here.
newFile = file;
- newFile->parseLoadCommands(mbref, umbrella);
+ if (newFile->exportingFile)
+ newFile->parseLoadCommands(mbref, umbrella);
}
return newFile;
}
diff --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index fa31fe370318..321ea0e6774f 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -150,7 +150,7 @@ class DylibFile : public InputFile {
static bool classof(const InputFile *f) { return f->kind() == DylibKind; }
StringRef dylibName;
- DylibFile *exportingFile;
+ DylibFile *exportingFile = nullptr;
uint32_t compatibilityVersion = 0;
uint32_t currentVersion = 0;
int64_t ordinal = 0; // Ordinal numbering starts from 1, so 0 is a sentinel
More information about the llvm-commits
mailing list