[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<>.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@219990 91177308-0d34-0410-b5e6-96231b3b80d8