Removed pointless code for OS X that checked for a fat Mach-O engine binary.
authorScott Ehlert <ds@alliedmods.net>
Thu Sep 26 15:21:07 2013 -0500 (2013-09-26)
changeset 2797674d15b15bc
parent 278 18fc23cf45d8
child 280 622b9760d7ae
Removed pointless code for OS X that checked for a fat Mach-O engine binary.

The only Mach-O header loaded in memory would be the one for the current (32-bit) architecture anyways. The fat header only applies when reading from disk.

(I'm not sure what I was thinking when I wrote this originally!)
metamod/engineinfo.cpp
     1.1 --- a/metamod/engineinfo.cpp	Thu Sep 26 15:06:51 2013 -0500
     1.2 +++ b/metamod/engineinfo.cpp	Thu Sep 26 15:21:07 2013 -0500
     1.3 @@ -23,7 +23,6 @@
     1.4  # include <CoreFoundation/CoreFoundation.h>
     1.5  # include <dlfcn.h>				// dladdr()
     1.6  # include <mach-o/loader.h>		// Mach-O structures
     1.7 -# include <mach-o/fat.h>		// Mach-O structures for fat binaries
     1.8  #endif /* _WIN32 */ 
     1.9  
    1.10  #include <string.h>				// strlen(), strrchr(), strcmp()
    1.11 @@ -388,35 +387,14 @@
    1.12  
    1.13  int EngineInfo::mhdr_machohdr( void* pMachoHdr )
    1.14  {
    1.15 -	fat_header* pFatHdr = (fat_header *)pMachoHdr;
    1.16  	mach_header* pHdr = (mach_header *)pMachoHdr;
    1.17 -	fat_arch* pFatArchs;
    1.18  	segment_command *pSegment;
    1.19  	section *pSection;
    1.20 -	uint32_t nArchs;
    1.21  	uint32_t nCmds;
    1.22  	uint32_t nSections;
    1.23  
    1.24  	if ( NULL == pMachoHdr ) return INVALID_ARG;
    1.25  
    1.26 -	// Check for fat binary first.
    1.27 -	// Note that fat_header and fat_arch are always stored in big-endian.
    1.28 -	if ( CFSwapInt32BigToHost( pFatHdr->magic ) == FAT_MAGIC ) {
    1.29 -		nArchs = CFSwapInt32BigToHost( pFatHdr->nfat_arch );
    1.30 -		pFatArchs = (fat_arch *) ((char *) pMachoHdr + sizeof(fat_header));
    1.31 -
    1.32 -		// Look for the 32-bit Mach-O header
    1.33 -		for (uint32_t i = 0; i < nArchs; i++) {
    1.34 -			if ( CFSwapInt32BigToHost( pFatArchs[i].cputype ) == CPU_TYPE_I386
    1.35 -				&& CFSwapInt32BigToHost ( pFatArchs[i].cpusubtype ) == CPU_SUBTYPE_I386_ALL ) {
    1.36 -
    1.37 -				pHdr = (mach_header *) ((char *) pMachoHdr + CFSwapInt32BigToHost( pFatArchs[i].offset ));
    1.38 -				break;
    1.39 -			}
    1.40 -		}
    1.41 -
    1.42 -	}
    1.43 -
    1.44  	// Find __TEXT segment and __text section
    1.45  	if ( pHdr->magic == MH_MAGIC
    1.46  		&& pHdr->filetype == MH_DYLIB ) {