diff options
| author | Pete Cooper <peter_cooper@apple.com> | 2016-02-01 21:42:17 +0000 |
|---|---|---|
| committer | Pete Cooper <peter_cooper@apple.com> | 2016-02-01 21:42:17 +0000 |
| commit | d714fc75cd8430bec3ceb8acfee15dadd972e67e (patch) | |
| tree | 55a00fc2fa25ea35ecacb45bdd09bb1b86690c34 | |
| parent | dbdb1d6eaf928a6820e0212105a7c8f695a168d1 (diff) | |
| download | bcm5719-llvm-d714fc75cd8430bec3ceb8acfee15dadd972e67e.tar.gz bcm5719-llvm-d714fc75cd8430bec3ceb8acfee15dadd972e67e.zip | |
Use dyn_cast instead of static_cast.
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
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 122b5405b86..22cdede640f 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -377,11 +377,11 @@ void Util::processDefinedAtoms(const lld::File &atomFile) { } 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) { |

