]> Cypherpunks repositories - gostls13.git/commitdiff
libmach: accept OS X binary generated by external linker
authorArnaud Ysmal <arnaud.ysmal@gmail.com>
Tue, 10 Sep 2013 18:50:34 +0000 (11:50 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 10 Sep 2013 18:50:34 +0000 (11:50 -0700)
Fixes cpu subtype check when using external linker which sets the CPU_SUBTYPE_LIB64 bit (1<<31).
Fixes #6197.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13248046

src/libmach/executable.c
src/libmach/macho.h

index 91c0cbe76b1f33a49cac31bf3d871540ddf44a40..eae14441a01c3eb4b39363862db5635e380515ba 100644 (file)
@@ -1076,7 +1076,7 @@ machdotout(int fd, Fhdr *fp, ExecHdr *hp)
                        return 0;
                }
 
-               if (mp->cpusubtype != MACH_CPU_SUBTYPE_X86) {
+               if (mp->cpusubtype != MACH_CPU_SUBTYPE_X86 && mp->cpusubtype != MACH_CPU_SUBTYPE_X86_64) {
                        werrstr("bad MACH cpu subtype - not amd64");
                        return 0;
                }
index df039d0485b69066c14845c18171bba981aeb655..9dfea5a85c0f92c3d24ec1866f889351e8e66abb 100644 (file)
@@ -87,6 +87,7 @@ enum {
        MACH_CPU_TYPE_X86_64 = (1<<24)|7,
        MACH_CPU_TYPE_X86 = 7,
        MACH_CPU_SUBTYPE_X86 = 3,
+       MACH_CPU_SUBTYPE_X86_64 = (1<<31)|3,
        MACH_EXECUTABLE_TYPE = 2,
        MACH_SEGMENT_32 = 1,    /* 32-bit mapped segment */
        MACH_SEGMENT_64 = 0x19, /* 64-bit mapped segment */