diff --git a/makefile b/makefile index 73efef11ca..791fa4d765 100755 --- a/makefile +++ b/makefile @@ -81,13 +81,13 @@ endif ifeq ($(platform),macosx) ifneq ($(filter arm arm64,$(arch)),) - x := $(error "please use 'arch=arm' or 'arch=arm64' 'platform=ios' to build for ios-arm") + x := $(error "please use ('arch=arm' or 'arch=arm64') 'platform=ios' to build for ios-arm") endif endif ifeq ($(platform),ios) - ifeq ($(filter arm i386,$(arch)),) - x := $(error "please specify 'arch=i386' or 'arch=arm' with 'platform=ios'") + ifeq ($(filter i386 arm arm64,$(arch)),) + x := $(error "please specify 'arch=i386', 'arch=arm', or 'arch=arm64' with 'platform=ios'") endif endif diff --git a/src/arm.S b/src/arm.S index 5d33b2cb58..8cf09b1de3 100644 --- a/src/arm.S +++ b/src/arm.S @@ -51,7 +51,7 @@ GLOBAL(vmNativeCall): mov w23, w6 // setup stack arguments if necessary - sub sp, sp, w20 // allocate stack + sub sp, sp, w20, uxtw // allocate stack mov x9, sp LOCAL(loop): cmp w3, wzr @@ -79,16 +79,16 @@ LOCAL(populateVFPs): LOCAL(doCall): blr x19 // call function - add sp, sp, w20 // deallocate stack + add sp, sp, w20, uxtw // deallocate stack cmp w23,#FLOAT_TYPE - bne LOCAL(double) + b.ne LOCAL(double) fmov w0,s0 b LOCAL(exit) LOCAL(double): cmp w23,#DOUBLE_TYPE - bne LOCAL(exit) + b.ne LOCAL(exit) fmov x0,d0 LOCAL(exit): diff --git a/src/avian/arm.h b/src/avian/arm.h index 9fbc83c474..c0309486a3 100644 --- a/src/avian/arm.h +++ b/src/avian/arm.h @@ -34,7 +34,11 @@ #define THREAD_STATE_IP(state) ((state).FIELD(pc)) #define THREAD_STATE_STACK(state) ((state).FIELD(sp)) +#if (defined __APPLE__) && (defined ARCH_arm64) +#define THREAD_STATE_THREAD(state) ((state).FIELD(x[19])) +#else #define THREAD_STATE_THREAD(state) ((state).FIELD(r[8])) +#endif #define THREAD_STATE_LINK(state) ((state).FIELD(lr)) #define IP_REGISTER(context) THREAD_STATE_IP(context->uc_mcontext->FIELD(ss)) diff --git a/src/tools/binary-to-object/main.cpp b/src/tools/binary-to-object/main.cpp index 1636d46dfd..ed984b12f5 100644 --- a/src/tools/binary-to-object/main.cpp +++ b/src/tools/binary-to-object/main.cpp @@ -50,20 +50,11 @@ bool writeObject(uint8_t* data, OutputStream* out, const char* startName, const char* endName, - const char* format, - const char* architecture, + Platform* platform, unsigned alignment, bool writable, bool executable) { - Platform* platform = Platform::getPlatform( - PlatformInfo(PlatformInfo::formatFromString(format), - PlatformInfo::archFromString(architecture))); - - if (!platform) { - fprintf(stderr, "unsupported platform: %s/%s\n", format, architecture); - return false; - } SymbolInfo symbols[] = {SymbolInfo(0, startName), SymbolInfo(size, endName)}; @@ -113,6 +104,19 @@ int main(int argc, const char** argv) } } + const char* format = argv[5]; + const char* architecture = argv[6]; + + Platform* platform = Platform::getPlatform( + PlatformInfo(PlatformInfo::formatFromString(format), + PlatformInfo::archFromString(architecture))); + + if (!platform) { + fprintf(stderr, "unsupported platform: %s/%s\n", format, architecture); + return 1; + } + + uint8_t* data = 0; unsigned size; int fd = open(argv[1], O_RDONLY); @@ -148,8 +152,7 @@ int main(int argc, const char** argv) &out, argv[3], argv[4], - argv[5], - argv[6], + platform, alignment, writable, executable); diff --git a/src/tools/object-writer/mach-o.cpp b/src/tools/object-writer/mach-o.cpp index 524407a381..c35a7058ac 100644 --- a/src/tools/object-writer/mach-o.cpp +++ b/src/tools/object-writer/mach-o.cpp @@ -33,10 +33,12 @@ #define CPU_TYPE_I386 7 #define CPU_TYPE_X86_64 (CPU_TYPE_I386 | CPU_ARCH_ABI64) #define CPU_TYPE_ARM 12 +#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64) #define CPU_SUBTYPE_I386_ALL 3 #define CPU_SUBTYPE_X86_64_ALL CPU_SUBTYPE_I386_ALL #define CPU_SUBTYPE_ARM_V7 9 +#define CPU_SUBTYPE_ARM_V8 13 namespace { @@ -157,6 +159,10 @@ class MachOPlatform : public Platform { cpuType = CPU_TYPE_ARM; cpuSubType = CPU_SUBTYPE_ARM_V7; break; + case PlatformInfo::Arm64: + cpuType = CPU_TYPE_ARM64; + cpuSubType = CPU_SUBTYPE_ARM_V8; + break; default: // should never happen (see MachOPlatform declarations at bottom) fprintf(stderr, "unsupported architecture: %d\n", info.arch); @@ -280,6 +286,7 @@ class MachOPlatform : public Platform { MachOPlatform darwinx86Platform(PlatformInfo::x86); MachOPlatform darwinArmPlatform(PlatformInfo::Arm); +MachOPlatform darwinArm64Platform(PlatformInfo::Arm64); MachOPlatform darwinx86_64Platform(PlatformInfo::x86_64); } // namespace