X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=inline;f=rts%2FLinker.c;h=beaf19e4a5d8a6fbf29526e79fc9e93dfc689ddb;hb=8ca5375714268a61d2549b02204bb44745cb4cbf;hp=3618fd481edbc232a497dd9b9283c635def591fb;hpb=971c88597b0972053975c9c99aa51764ab75b143;p=ghc-hetmet.git diff --git a/rts/Linker.c b/rts/Linker.c index 3618fd4..beaf19e 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1608,6 +1608,7 @@ loadObj( char *path ) #else FILE *f; #endif + IF_DEBUG(linker, debugBelch("loadObj %s\n", path)); initLinker(); /* debugBelch("loadObj %s\n", path ); */ @@ -1648,7 +1649,10 @@ loadObj( char *path ) # endif r = stat(path, &st); - if (r == -1) { return 0; } + if (r == -1) { + IF_DEBUG(linker, debugBelch("File doesn't exist\n")); + return 0; + } /* sigh, strdup() isn't a POSIX function, so do it the long way */ oc->fileName = stgMallocBytes( strlen(path)+1, "loadObj" ); @@ -1717,10 +1721,16 @@ loadObj( char *path ) # if defined(OBJFORMAT_MACHO) && (defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)) r = ocAllocateSymbolExtras_MachO ( oc ); - if (!r) { return r; } + if (!r) { + IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO failed\n")); + return r; + } # elif defined(OBJFORMAT_ELF) && (defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)) r = ocAllocateSymbolExtras_ELF ( oc ); - if (!r) { return r; } + if (!r) { + IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_ELF failed\n")); + return r; + } #endif /* verify the in-memory image */ @@ -1733,7 +1743,10 @@ loadObj( char *path ) # else barf("loadObj: no verify method"); # endif - if (!r) { return r; } + if (!r) { + IF_DEBUG(linker, debugBelch("ocVerifyImage_* failed\n")); + return r; + } /* build the symbol list for this image */ # if defined(OBJFORMAT_ELF) @@ -1745,7 +1758,10 @@ loadObj( char *path ) # else barf("loadObj: no getNames method"); # endif - if (!r) { return r; } + if (!r) { + IF_DEBUG(linker, debugBelch("ocGetNames_* failed\n")); + return r; + } /* loaded, but not resolved yet */ oc->status = OBJECT_LOADED; @@ -4023,11 +4039,17 @@ static int ocVerifyImage_MachO(ObjectCode* oc) struct mach_header *header = (struct mach_header*) image; #if x86_64_HOST_ARCH || powerpc64_HOST_ARCH - if(header->magic != MH_MAGIC_64) + if(header->magic != MH_MAGIC_64) { + errorBelch("%s: Bad magic. Expected: %08x, got: %08x.\n", + oc->fileName, MH_MAGIC_64, header->magic); return 0; + } #else - if(header->magic != MH_MAGIC) + if(header->magic != MH_MAGIC) { + errorBelch("%s: Bad magic. Expected: %08x, got: %08x.\n", + oc->fileName, MH_MAGIC, header->magic); return 0; + } #endif // FIXME: do some more verifying here return 1; @@ -4814,11 +4836,17 @@ static int machoGetMisalignment( FILE * f ) rewind(f); #if x86_64_HOST_ARCH || powerpc64_HOST_ARCH - if(header.magic != MH_MAGIC_64) + if(header.magic != MH_MAGIC_64) { + errorBelch("Bad magic. Expected: %08x, got: %08x.\n", + MH_MAGIC_64, header->magic); return 0; + } #else - if(header.magic != MH_MAGIC) + if(header.magic != MH_MAGIC) { + errorBelch("Bad magic. Expected: %08x, got: %08x.\n", + MH_MAGIC, header->magic); return 0; + } #endif misalignment = (header.sizeofcmds + sizeof(header))