Now that MachoFile has classof(), we can use dyn_cast instead which
is actually the only safe way to handle this.
Turns out this actually manifests as a bug as we were incorrectly
casting instances which weren't MachoFile in to a MachoFile.
Unfortunately, there's no reliable way of checking for this as it
requires that the file we are looking for has a 0 at exactly the byte
we need for the load of subsectionsViaSymbols.
llvm-svn: 259413
}
void Util::processAtomAttributes(const DefinedAtom *atom) {
- auto *machoFile = static_cast<const mach_o::MachOFile *>(&atom->file());
// If the file doesn't use subsections via symbols, then make sure we don't
// add that flag to the final output file if we have a relocatable file.
- if (!machoFile->subsectionsViaSymbols())
- _subsectionsViaSymbols = false;
+ if (auto *machoFile = dyn_cast<mach_o::MachOFile>(&atom->file()))
+ if (!machoFile->subsectionsViaSymbols())
+ _subsectionsViaSymbols = false;
}
void Util::assignAtomToSection(const DefinedAtom *atom) {