@@ -568,7 +568,7 @@ void JITDebugInfoRegistry::libc_frames_t::libc_deregister_frame(const char *Entr
568
568
}
569
569
#endif
570
570
571
- static bool getObjUUID (llvm:: object::MachOObjectFile *obj, uint8_t uuid[16 ]) JL_NOTSAFEPOINT
571
+ static bool getObjUUID (const object::MachOObjectFile *obj, uint8_t uuid[16 ]) JL_NOTSAFEPOINT
572
572
{
573
573
for (auto Load : obj->load_commands ())
574
574
{
@@ -830,9 +830,6 @@ static objfileentry_t find_object_file(uint64_t fbase, StringRef fname) JL_NOTSA
830
830
std::string debuginfopath;
831
831
uint8_t uuid[16 ], uuid2[16 ];
832
832
if (isdarwin) {
833
- // Hide Darwin symbols (e.g. CoreFoundation) from non-Darwin systems.
834
- #ifdef _OS_DARWIN_
835
-
836
833
size_t msize = (size_t )(((uint64_t )-1 ) - fbase);
837
834
std::unique_ptr<MemoryBuffer> membuf = MemoryBuffer::getMemBuffer (
838
835
StringRef ((const char *)fbase, msize), " " , false );
@@ -843,14 +840,18 @@ static objfileentry_t find_object_file(uint64_t fbase, StringRef fname) JL_NOTSA
843
840
return entry;
844
841
}
845
842
846
- llvm:: object::MachOObjectFile *morigobj = (llvm:: object::MachOObjectFile*)
847
- origerrorobj.get ().get ();
843
+ const object::MachOObjectFile *morigobj = dyn_cast< const object::MachOObjectFile>(
844
+ origerrorobj.get ().get ()) ;
848
845
849
846
// First find the uuid of the object file (we'll use this to make sure we find the
850
847
// correct debug symbol file).
851
- if (!getObjUUID (morigobj, uuid))
848
+ if (!morigobj || ! getObjUUID (morigobj, uuid))
852
849
return entry;
853
850
851
+ // Hide Darwin symbols (e.g. CoreFoundation) from non-Darwin systems.
852
+ #ifndef _OS_DARWIN_
853
+ return entry;
854
+ #else
854
855
// On macOS, debug symbols are not contained in the dynamic library.
855
856
// Use DBGCopyFullDSYMURLForUUID from the private DebugSymbols framework
856
857
// to make use of spotlight to find the dSYM file. If that fails, lookup
@@ -906,6 +907,7 @@ static objfileentry_t find_object_file(uint64_t fbase, StringRef fname) JL_NOTSA
906
907
if (dsfmwkbundle) {
907
908
CFRelease (dsfmwkbundle);
908
909
}
910
+ #endif
909
911
910
912
if (objpath.empty ()) {
911
913
// Fall back to simple path relative to the dynamic library.
@@ -915,7 +917,6 @@ static objfileentry_t find_object_file(uint64_t fbase, StringRef fname) JL_NOTSA
915
917
debuginfopath += fname.substr (sep + 1 );
916
918
objpath = debuginfopath;
917
919
}
918
- #endif
919
920
}
920
921
else {
921
922
// On Linux systems we need to mmap another copy because of the permissions on the mmap'ed shared library.
@@ -974,15 +975,17 @@ static objfileentry_t find_object_file(uint64_t fbase, StringRef fname) JL_NOTSA
974
975
975
976
if (isdarwin) {
976
977
// verify the UUID matches
977
- if (!getObjUUID ((llvm::object::MachOObjectFile*)debugobj, uuid2) ||
978
- memcmp (uuid, uuid2, sizeof (uuid)) != 0 ) {
978
+ if (!isa<const object::MachOObjectFile>(debugobj) ||
979
+ !getObjUUID (cast<const object::MachOObjectFile>(debugobj), uuid2) ||
980
+ memcmp (uuid, uuid2, sizeof (uuid)) != 0 ) {
979
981
return entry;
980
982
}
981
983
}
982
984
983
985
int64_t slide = 0 ;
984
986
if (auto *OF = dyn_cast<const object::COFFObjectFile>(debugobj)) {
985
- assert (iswindows);
987
+ if (!iswindows) // the COFF parser accepts some garbage inputs (like empty files) that the other parsers correctly reject, so we can end up here even when we should not
988
+ return entry;
986
989
slide = OF->getImageBase () - fbase;
987
990
}
988
991
else {
0 commit comments