[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
This commit is contained in:
Nico Weber 2021-06-01 16:34:10 -04:00
parent ba95fa03ce
commit 8d80139ccc
2 changed files with 5 additions and 3 deletions

View File

@ -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;
}

View File

@ -150,7 +150,7 @@ public:
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