Mint APE Loader v1.5

This change ports APE Loader to Linux AARCH64, so that Raspberry Pi
users can run programs like redbean, without the executable needing
to modify itself. Progress has also slipped into this change on the
issue of making progress better conforming to user expectations and
industry standards regarding which symbols we're allowed to declare
This commit is contained in:
Justine Tunney 2023-07-26 13:54:49 -07:00
parent 6843150e0c
commit 7e0a09feec
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
510 changed files with 1783 additions and 1483 deletions

View file

@ -416,39 +416,31 @@ syscon utime UTIME_NOW 0x3fffffff 0x3fffffff -1 -1 -1 -2 0x3fffffff
syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -2 -2 -1 0x3ffffffe -1 # timespec::tv_nsec may be this; polyfilled xnu/nt
# getauxval() keys
#
# Unsupported values are encoded as 0.
# libc/sysv/consts/auxv.h
#
# group name GNU/Systemd GNU/Systemd (Aarch64) XNU's Not UNIX! MacOS (Arm64) FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon auxv AT_EXECFD 2 2 0 0 2 0 2 0 # file descriptor of program
syscon auxv AT_PHDR 3 3 3 3 3 0 3 0 # address of program headers of executable
syscon auxv AT_PHENT 4 4 4 4 4 0 4 0
syscon auxv AT_PHNUM 5 5 5 5 5 0 5 0
syscon auxv AT_PAGESZ 6 6 6 6 6 0 6 0
syscon auxv AT_BASE 7 7 7 7 7 0 7 0 # address of program interpreter
syscon auxv AT_FLAGS 8 8 0 0 8 0 8 0
syscon auxv AT_ENTRY 9 9 9 9 9 0 9 0 # entry address of executable
syscon auxv AT_NOTELF 10 10 0 0 10 0 0 0
syscon auxv AT_EXECFN 31 31 31 31 15 31 2014 31 # address of string containing first argument passed to execve() used when running program; AT_EXECPATH on FreeBSD
syscon auxv AT_SECURE 23 23 23 23 0 23 0 23
syscon auxv AT_RANDOM 25 25 25 25 16 25 0 25 # address of sixteen bytes of random data; AT_CANARY on FreeBSD whose AT_CANARYLEN should be 64
syscon auxv AT_HWCAP 16 16 16 16 0 16 0 16
syscon auxv AT_HWCAP2 26 26 26 26 0 26 0 26
syscon auxv AT_UID 11 11 11 11 0 11 2001 11
syscon auxv AT_EUID 12 12 12 12 0 12 2000 12
syscon auxv AT_GID 13 13 13 13 0 13 2003 13
syscon auxv AT_EGID 14 14 14 14 0 14 2002 14
syscon auxv AT_EXECFD 2 2 0 0 2 2 2 2 # file descriptor of program
syscon auxv AT_NOTELF 10 10 0 0 10 10 0 10
syscon auxv AT_OSRELDATE 0 0 0 0 18 0 0 0
syscon auxv AT_UID 11 11 11 11 0 0 2001 0
syscon auxv AT_EUID 12 12 12 12 0 0 2000 0
syscon auxv AT_GID 13 13 13 13 0 0 2003 0
syscon auxv AT_EGID 14 14 14 14 0 0 2002 0
syscon auxv AT_PLATFORM 15 15 0 0 0 0 0 0 # address of string with hardware platform for rpath interpretation
syscon auxv AT_HWCAP 16 16 16 16 0 0 0 0
syscon auxv AT_CLKTCK 17 17 0 0 0 0 0 0
syscon auxv AT_DCACHEBSIZE 19 19 0 0 0 0 0 0
syscon auxv AT_ICACHEBSIZE 20 20 0 0 0 0 0 0
syscon auxv AT_UCACHEBSIZE 21 21 0 0 0 0 0 0
syscon auxv AT_SECURE 23 23 23 23 0 0 0 0
syscon auxv AT_BASE_PLATFORM 24 24 0 0 0 0 0 0
syscon auxv AT_RANDOM 25 25 25 25 16 0 0 0 # address of sixteen bytes of random data; AT_CANARY on FreeBSD whose AT_CANARYLEN should be 64
syscon auxv AT_HWCAP2 26 26 26 26 0 0 0 0
syscon auxv AT_EXECFN 31 31 31 31 15 999 2014 31 # address of string containing first argument passed to execve() used when running program; AT_EXECPATH on FreeBSD
syscon auxv AT_SYSINFO_EHDR 33 33 0 0 0 0 0 0
syscon auxv AT_PLATFORM 15 15 0 0 0 15 0 15 # address of string with hardware platform for rpath interpretation
syscon auxv AT_CLKTCK 17 17 0 0 0 17 0 17
syscon auxv AT_DCACHEBSIZE 19 19 0 0 0 19 0 19
syscon auxv AT_ICACHEBSIZE 20 20 0 0 0 20 0 20
syscon auxv AT_UCACHEBSIZE 21 21 0 0 0 21 0 21
syscon auxv AT_BASE_PLATFORM 24 24 0 0 0 24 0 24
syscon auxv AT_SYSINFO_EHDR 33 33 0 0 0 33 0 33
syscon auxv AT_STACKBASE 0 0 0 0 0 0 13 0
syscon auxv AT_EXECPATH 31 31 31 31 15 999 2014 31 # FreeBSD name for AT_EXECFN
syscon auxv AT_MINSIGSTKSZ 51 51 0 0 0 0 0 0 # FreeBSD name for AT_EXECFN
syscon auxv AT_EXECPATH 31 31 31 31 15 31 2014 31 # FreeBSD name for AT_EXECFN
syscon auxv AT_MINSIGSTKSZ 51 51 0 0 0 51 0 51 # FreeBSD name for AT_EXECFN
syscon auxv AT_CANARY 0 0 0 0 16 0 0 0
syscon auxv AT_CANARYLEN 0 0 0 0 17 0 0 0
syscon auxv AT_NCPUS 0 0 0 0 19 0 0 0
@ -457,7 +449,7 @@ syscon auxv AT_PAGESIZESLEN 0 0 0 0 21 0 0 0
syscon auxv AT_TIMEKEEP 0 0 0 0 22 0 0 0
syscon auxv AT_STACKPROT 0 0 0 0 23 0 0 0
syscon auxv AT_EHDRFLAGS 0 0 0 0 24 0 0 0
syscon auxv AT_NO_AUTOMOUNT 0x0800 0x0800 0 0 0 0 0 0
syscon auxv AT_NO_AUTOMOUNT 0x0800 0x0800 0 0 0 0x0800 0 0x0800
# getrlimit() / setrlimit() resource parameter
#

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_ENTRY,9,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,12,12,0,0,2000,0
.syscon auxv,AT_EUID,12,12,12,12,0,12,2000,12

View file

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

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_EXECFN,31,31,31,31,15,999,2014,31
.syscon auxv,AT_EXECFN,31,31,31,31,15,31,2014,31

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon auxv,AT_EXECPATH,31,31,31,31,15,999,2014,31
.syscon auxv,AT_EXECPATH,31,31,31,31,15,31,2014,31

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,25 +1,53 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_AUXV_H_
#define COSMOPOLITAN_LIBC_CALLS_AUXV_H_
/*
* integral getauxval() keys
*/
#define AT_PHDR 3
#define AT_PHENT 4
#define AT_PHNUM 5
#define AT_PAGESZ 6
#define AT_BASE 7
#define AT_FLAGS 8
#define AT_ENTRY 9
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const unsigned long AT_BASE;
/*
* portable getauxval() keys
*/
extern const unsigned long AT_EXECFN;
extern const unsigned long AT_SECURE;
extern const unsigned long AT_RANDOM;
extern const unsigned long AT_HWCAP;
extern const unsigned long AT_HWCAP2;
extern const unsigned long AT_UID;
extern const unsigned long AT_EUID;
extern const unsigned long AT_GID;
extern const unsigned long AT_EGID;
#define AT_EXECFN AT_EXECFN
#define AT_SECURE AT_SECURE
#define AT_RANDOM AT_RANDOM
#define AT_HWCAP AT_HWCAP
#define AT_HWCAP2 AT_HWCAP2
#define AT_UID AT_UID
#define AT_EUID AT_EUID
#define AT_GID AT_GID
#define AT_EGID AT_EGID
/*
* platform-specific getauxval() keys
*/
extern const unsigned long AT_BASE_PLATFORM;
extern const unsigned long AT_CANARY;
extern const unsigned long AT_CANARYLEN;
extern const unsigned long AT_CLKTCK;
extern const unsigned long AT_DCACHEBSIZE;
extern const unsigned long AT_EGID;
extern const unsigned long AT_EHDRFLAGS;
extern const unsigned long AT_ENTRY;
extern const unsigned long AT_EUID;
extern const unsigned long AT_EXECFD;
extern const unsigned long AT_EXECFN;
extern const unsigned long AT_EXECPATH;
extern const unsigned long AT_FLAGS;
extern const unsigned long AT_GID;
extern const unsigned long AT_HWCAP2;
extern const unsigned long AT_HWCAP;
extern const unsigned long AT_ICACHEBSIZE;
extern const unsigned long AT_MINSIGSTKSZ;
extern const unsigned long AT_NCPUS;
@ -28,61 +56,13 @@ extern const unsigned long AT_NO_AUTOMOUNT;
extern const unsigned long AT_OSRELDATE;
extern const unsigned long AT_PAGESIZES;
extern const unsigned long AT_PAGESIZESLEN;
extern const unsigned long AT_PAGESZ;
extern const unsigned long AT_PHDR;
extern const unsigned long AT_PHENT;
extern const unsigned long AT_PHNUM;
extern const unsigned long AT_PLATFORM;
extern const unsigned long AT_RANDOM;
extern const unsigned long AT_SECURE;
extern const unsigned long AT_STACKBASE;
extern const unsigned long AT_STACKPROT;
extern const unsigned long AT_SYSINFO_EHDR;
extern const unsigned long AT_TIMEKEEP;
extern const unsigned long AT_UCACHEBSIZE;
extern const unsigned long AT_UID;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#define AT_BASE AT_BASE
#define AT_BASE_PLATFORM AT_BASE_PLATFORM
#define AT_CANARY AT_CANARY
#define AT_CANARYLEN AT_CANARYLEN
#define AT_CLKTCK AT_CLKTCK
#define AT_DCACHEBSIZE AT_DCACHEBSIZE
#define AT_EGID AT_EGID
#define AT_EHDRFLAGS AT_EHDRFLAGS
#define AT_ENTRY AT_ENTRY
#define AT_EUID AT_EUID
#define AT_EXECFD AT_EXECFD
#define AT_EXECFN AT_EXECFN
#define AT_EXECPATH AT_EXECPATH
#define AT_FLAGS AT_FLAGS
#define AT_GID AT_GID
#define AT_HWCAP AT_HWCAP
#define AT_HWCAP2 AT_HWCAP2
#define AT_ICACHEBSIZE AT_ICACHEBSIZE
#define AT_MINSIGSTKSZ AT_MINSIGSTKSZ
#define AT_NCPUS AT_NCPUS
#define AT_NOTELF AT_NOTELF
#define AT_NO_AUTOMOUNT AT_NO_AUTOMOUNT
#define AT_OSRELDATE AT_OSRELDATE
#define AT_PAGESIZES AT_PAGESIZES
#define AT_PAGESIZESLEN AT_PAGESIZESLEN
#define AT_PAGESZ AT_PAGESZ
#define AT_PHDR AT_PHDR
#define AT_PHENT AT_PHENT
#define AT_PHNUM AT_PHNUM
#define AT_PLATFORM AT_PLATFORM
#define AT_RANDOM AT_RANDOM
#define AT_SECURE AT_SECURE
#define AT_STACKBASE AT_STACKBASE
#define AT_STACKPROT AT_STACKPROT
#define AT_SYSINFO_EHDR AT_SYSINFO_EHDR
#define AT_TIMEKEEP AT_TIMEKEEP
#define AT_UCACHEBSIZE AT_UCACHEBSIZE
#define AT_UID AT_UID
#endif /* COSMOPOLITAN_LIBC_CALLS_AUXV_H_ */