Introduce native support for MacOS ARM64

There's a new program named ape/ape-m1.c which will be used to build an
embeddable binary that can load ape and elf executables. The support is
mostly working so far, but still chasing down ABI issues.
This commit is contained in:
Justine Tunney 2023-05-18 19:05:08 -07:00
parent b852650c08
commit 1422e96b4e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
757 changed files with 2988 additions and 1321 deletions

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_BASE,7,7,0,7,0,7,0
.syscon auxv,AT_BASE,7,7,7,7,0,7,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_EGID,14,14,0,0,0,2002,0
.syscon auxv,AT_EGID,14,14,14,0,0,2002,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_ENTRY,9,9,0,9,0,9,0
.syscon auxv,AT_ENTRY,9,9,9,9,0,9,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_EUID,12,12,0,0,0,2000,0
.syscon auxv,AT_EUID,12,12,12,0,0,2000,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_GID,13,13,0,0,0,2003,0
.syscon auxv,AT_GID,13,13,13,0,0,2003,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_HWCAP,16,16,0,0,0,0,0
.syscon auxv,AT_HWCAP,16,16,16,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_HWCAP2,26,26,0,0,0,0,0
.syscon auxv,AT_HWCAP2,26,26,26,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_PAGESZ,6,6,0,6,0,6,0
.syscon auxv,AT_PAGESZ,6,6,6,6,0,6,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_PHDR,3,3,0,3,0,3,0
.syscon auxv,AT_PHDR,3,3,3,3,0,3,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_PHENT,4,4,0,4,0,4,0
.syscon auxv,AT_PHENT,4,4,4,4,0,4,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_PHNUM,5,5,0,5,0,5,0
.syscon auxv,AT_PHNUM,5,5,5,5,0,5,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_RANDOM,25,25,0,16,0,0,0
.syscon auxv,AT_RANDOM,25,25,25,16,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_SECURE,23,23,0,0,0,0,0
.syscon auxv,AT_SECURE,23,23,23,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_UID,11,11,0,0,0,2001,0
.syscon auxv,AT_UID,11,11,11,0,0,2001,0

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EACCES,13,13,13,13,13,13,5
#ifdef __x86_64__
.yoink kDos2Errno.EACCES
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EADDRINUSE,98,98,48,48,48,48,10048
#ifdef __x86_64__
.yoink kDos2Errno.EADDRINUSE
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EADDRNOTAVAIL,99,99,49,49,49,49,10049
#ifdef __x86_64__
.yoink kDos2Errno.EADDRNOTAVAIL
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EAGAIN,11,11,35,35,35,35,10035
#ifdef __x86_64__
.yoink kDos2Errno.EAGAIN
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EBADF,9,9,9,9,9,9,6
#ifdef __x86_64__
.yoink kDos2Errno.EBADF
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNABORTED,103,103,53,53,53,53,10053
#ifdef __x86_64__
.yoink kDos2Errno.ECONNABORTED
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNREFUSED,111,111,61,61,61,61,10061
#ifdef __x86_64__
.yoink kDos2Errno.ECONNREFUSED
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNRESET,104,104,54,54,54,54,10054
#ifdef __x86_64__
.yoink kDos2Errno.ECONNRESET
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EDQUOT,122,122,69,69,69,69,1816
#ifdef __x86_64__
.yoink kDos2Errno.EDQUOT
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EEXIST,17,17,17,17,17,17,183
#ifdef __x86_64__
.yoink kDos2Errno.EEXIST
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EFAULT,14,14,14,14,14,14,487
#ifdef __x86_64__
.yoink kDos2Errno.EFAULT
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EHOSTUNREACH,113,113,65,65,65,65,10065
#ifdef __x86_64__
.yoink kDos2Errno.EHOSTUNREACH
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EINPROGRESS,115,115,36,36,36,36,10036
#ifdef __x86_64__
.yoink kDos2Errno.EINPROGRESS
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EINTR,4,4,4,4,4,4,10004
#ifdef __x86_64__
.yoink kDos2Errno.EINTR
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EINVAL,22,22,22,22,22,22,87
#ifdef __x86_64__
.yoink kDos2Errno.EINVAL
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EISCONN,106,106,56,56,56,56,10056
#ifdef __x86_64__
.yoink kDos2Errno.EISCONN
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EMSGSIZE,90,90,40,40,40,40,10040
#ifdef __x86_64__
.yoink kDos2Errno.EMSGSIZE
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENAMETOOLONG,36,36,63,63,63,63,10063
#ifdef __x86_64__
.yoink kDos2Errno.ENAMETOOLONG
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENETDOWN,100,100,50,50,50,50,10050
#ifdef __x86_64__
.yoink kDos2Errno.ENETDOWN
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENETUNREACH,101,101,51,51,51,51,10051
#ifdef __x86_64__
.yoink kDos2Errno.ENETUNREACH
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOENT,2,2,2,2,2,2,2
#ifdef __x86_64__
.yoink kDos2Errno.ENOENT
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOMEM,12,12,12,12,12,12,14
#ifdef __x86_64__
.yoink kDos2Errno.ENOMEM
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOSYS,38,38,78,78,78,78,1
#ifdef __x86_64__
.yoink kDos2Errno.ENOSYS
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOTEMPTY,39,39,66,66,66,66,145
#ifdef __x86_64__
.yoink kDos2Errno.ENOTEMPTY
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOTSUP,95,95,45,45,91,86,10045
#ifdef __x86_64__
.yoink kDos2Errno.ENOTSUP
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EPIPE,32,32,32,32,32,32,109
#ifdef __x86_64__
.yoink kDos2Errno.EPIPE
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ETIMEDOUT,110,110,60,60,60,60,1460
#ifdef __x86_64__
.yoink kDos2Errno.ETIMEDOUT
#endif

View file

@ -1,3 +1,5 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,EWOULDBLOCK,11,11,35,35,35,35,10035
#ifdef __x86_64__
.yoink kDos2Errno.EWOULDBLOCK
#endif

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_HWAP_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_HWAP_H_
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_HWCAP_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_HWCAP_H_
#ifdef __aarch64__
// Feature bits for getauxval(AT_HWCAP) on AARCH64 GNU/SystemD.
@ -58,4 +58,4 @@
#define HWCAP2_MTE (1 << 18)
#endif /* __aarch64__ */
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_HWAP_H_ */
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_HWCAP_H_ */

View file

@ -18,60 +18,61 @@
*/
#include "libc/dce.h"
#include "libc/macros.internal.h"
/* clang-format off */
// clang-format off
#ifdef __x86_64__
#define ENCODE .uleb128
.yoink _init_systemfive
#else
#define ENCODE .balign 8 ; .quad
#endif
.macro .syscon group:req name:req linux:req linux_aarch64:req xnu:req freebsd:req openbsd:req netbsd:req windows:req
#ifdef __x86_64__
.yoink _init_systemfive
.section .piro.bss.sort.syscon.2.\group\().\name,"aw",@nobits
.balign 8
\name: .quad 0
.endobj \name,globl
.previous
#if SupportsLinux() || SupportsMetal()
.section .sort.rodata.syscon.linux.2.\group\().\name,"a",@progbits
.uleb128 \linux
#ifdef __aarch64__
ENCODE \linux_aarch64
#else
ENCODE \linux
#endif
.previous
#endif
#if SupportsXnu()
.section .sort.rodata.syscon.xnu.2.\group\().\name,"a",@progbits
.uleb128 \xnu
ENCODE \xnu
.previous
#endif
#if SupportsFreebsd()
.section .sort.rodata.syscon.freebsd.2.\group\().\name,"a",@progbits
.uleb128 \freebsd
ENCODE \freebsd
.previous
#endif
#if SupportsOpenbsd()
.section .sort.rodata.syscon.openbsd.2.\group\().\name,"a",@progbits
.uleb128 \openbsd
ENCODE \openbsd
.previous
#endif
#if SupportsNetbsd()
.section .sort.rodata.syscon.netbsd.2.\group\().\name,"a",@progbits
.uleb128 \netbsd
ENCODE \netbsd
.previous
#endif
#if SupportsWindows()
.section .sort.rodata.syscon.windows.2.\group\().\name,"a",@progbits
.uleb128 \windows
ENCODE \windows
.previous
#endif
#else
.section .rodata,"a",@progbits
.balign 8
\name: .quad \linux_aarch64
.endobj \name,globl
.previous
#endif /* __x86_64__ */
.endm