diff options
| author | pho@cielonegro.org <unknown> | 2010-11-30 12:33:55 +0000 |
|---|---|---|
| committer | pho@cielonegro.org <unknown> | 2010-11-30 12:33:55 +0000 |
| commit | f9597b672c50fec048cfd0eebbf172ae21217fef (patch) | |
| tree | 8fa735753d77c66f3fdc4e7525960c456c514ff5 | |
| parent | 819909d2bc253ed1630880f82276176432b17803 (diff) | |
| download | haskell-f9597b672c50fec048cfd0eebbf172ae21217fef.tar.gz | |
rts/Linker.c (machoGetMisalignment):
Use fseek(3) instead of rewind(3) to move the file position indicator back to the initial position. Otherwise we can't use this function in loadArchive().
| -rw-r--r-- | rts/Linker.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index 5f8ce13ea3..a0e578e4de 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -5328,21 +5328,24 @@ static int machoGetMisalignment( FILE * f ) { struct mach_header header; int misalignment; - - fread(&header, sizeof(header), 1, f); - rewind(f); + + { + int n = fread(&header, sizeof(header), 1, f); + if (n != 1) { + barf("machoGetMisalignment: can't read the Mach-O header"); + } + } + fseek(f, -sizeof(header), SEEK_CUR); #if x86_64_HOST_ARCH || powerpc64_HOST_ARCH if(header.magic != MH_MAGIC_64) { - errorBelch("Bad magic. Expected: %08x, got: %08x.\n", - MH_MAGIC_64, header->magic); - return 0; + barf("Bad magic. Expected: %08x, got: %08x.", + MH_MAGIC_64, header.magic); } #else if(header.magic != MH_MAGIC) { - errorBelch("Bad magic. Expected: %08x, got: %08x.\n", - MH_MAGIC, header->magic); - return 0; + barf("Bad magic. Expected: %08x, got: %08x.", + MH_MAGIC, header.magic); } #endif |
