[mach-o] Fix crash when -all_load used with dylibs
authorNick Kledzik <kledzik@apple.com>
Thu, 16 Oct 2014 23:42:42 +0000 (23:42 +0000)
committerNick Kledzik <kledzik@apple.com>
Thu, 16 Oct 2014 23:42:42 +0000 (23:42 +0000)
commit3a118aa3443d6a7da034e1bb9b3d7ae22adbe42d
treec73e92a029aa253fd0b5133f0e3ea7cf2745895e
parente02eca7a42d0957421219f812b92eb2fb558b6e3
[mach-o] Fix crash when -all_load used with dylibs

-all_load tells the darwin linker to immediately load all members of all
archives.  The code do that used reinterpret_cast<> instead of dyn_cast<>.
If the file was a dylib, the reinterpret_cast<> turned a pointer to a dylib
into a pointer to an archive...boom.

Added test case to reproduce the crash, simplified the code and used dyn_cast<>.

llvm-svn: 219990
lld/lib/Driver/DarwinInputGraph.cpp
lld/test/mach-o/force_load-dylib.yaml [new file with mode: 0644]