Fully support OpenBSD 7.3

This change (1) upgrades to OpenBSD's newer kernel ABIs, and (2)
modifies APE to have a read-only data segment. Doing this required
creating APE Loader v1.1, which is backwards and forwards compatible
with the previous version.

If you've run the following commands in the past to install your APE
Loader systemwide, then you need to run them again. Ad-hoc installations
shouldn't be impacted. It's also recommended that APE binaries be remade
after upgrading, since they embed old versions of the APE Loader.

    ape/apeuninstall.sh
    ape/apeinstall.sh

This change does more than just fix OpenBSD. The new loader is smarter
and more reliable. We're now able create much tinier ELF and Mach-O data
structures than we could before. Both APE Loader and execvpe() will now
normalize ambiguous argv[0] resolution the same way as the UNIX shell.
Badness with TLS linkage has been solved.

Fixes #826
This commit is contained in:
Justine Tunney 2023-07-01 05:10:12 -07:00
parent 963e10b9bf
commit 40eb3b9d5d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
48 changed files with 772 additions and 903 deletions

View file

@ -1706,16 +1706,16 @@ syscon nr __NR_fstat 0x0005 0x0050 0x2000153 0x0153 0x0227 0x0035
syscon nr __NR_lstat 0x0006 0x0fff 0x2000154 0x0154 0x0028 0x0028 0x1b9 0xfff
syscon nr __NR_poll 0x0007 0x0fff 0x20000e6 0x00e6 0x00d1 0x00fc 0x0d1 0xfff
syscon nr __NR_ppoll 0x010f 0x0049 0xfff 0xfff 0x0221 0x006d 0xfff 0xfff
syscon nr __NR_lseek 0x0008 0x003e 0x20000c7 0x00c7 0x01de 0x00c7 0x0c7 0xfff
syscon nr __NR_mmap 0x0009 0x00de 0x20000c5 0x00c5 0x01dd 0x00c5 0x0c5 0xfff
syscon nr __NR_lseek 0x0008 0x003e 0x20000c7 0x00c7 0x01de 0x00a6 0x0c7 0xfff # OpenBSD 7.3+
syscon nr __NR_mmap 0x0009 0x00de 0x20000c5 0x00c5 0x01dd 0x0031 0x0c5 0xfff # OpenBSD 7.3+
syscon nr __NR_msync 0x001a 0x00e3 0x2000041 0x0041 0x0041 0x0100 0x115 0xfff
syscon nr __NR_mprotect 0x000a 0x00e2 0x200004a 0x004a 0x004a 0x004a 0x04a 0xfff
syscon nr __NR_munmap 0x000b 0x00d7 0x2000049 0x0049 0x0049 0x0049 0x049 0xfff
syscon nr __NR_sigaction 0x000d 0x0086 0x200002e 0x002e 0x01a0 0x002e 0x154 0xfff
syscon nr __NR_sigprocmask 0x000e 0x0087 0x2000149 0x0149 0x0154 0x0030 0x125 0xfff
syscon nr __NR_ioctl 0x0010 0x001d 0x2000036 0x0036 0x0036 0x0036 0x036 0xfff
syscon nr __NR_pread 0x0011 0x0043 0x2000099 0x0099 0x01db 0x00ad 0x0ad 0xfff
syscon nr __NR_pwrite 0x0012 0x0044 0x200009a 0x009a 0x01dc 0x00ae 0x0ae 0xfff
syscon nr __NR_pread 0x0011 0x0043 0x2000099 0x0099 0x01db 0x00a9 0x0ad 0xfff # OpenBSD 7.3+
syscon nr __NR_pwrite 0x0012 0x0044 0x200009a 0x009a 0x01dc 0x00aa 0x0ae 0xfff # OpenBSD 7.3+
syscon nr __NR_readv 0x0013 0x0041 0x2000078 0x0078 0x0078 0x0078 0x078 0xfff
syscon nr __NR_writev 0x0014 0x0042 0x2000079 0x0079 0x0079 0x0079 0x079 0xfff
syscon nr __NR_access 0x0015 0x0fff 0x2000021 0x0021 0x0021 0x0021 0x021 0xfff
@ -1779,8 +1779,8 @@ syscon nr __NR_fcntl 0x0048 0x0019 0x200005c 0x005c 0x005c 0x005c
syscon nr __NR_flock 0x0049 0x0020 0x2000083 0x0083 0x0083 0x0083 0x083 0xfff
syscon nr __NR_fsync 0x004a 0x0052 0x200005f 0x005f 0x005f 0x005f 0x05f 0xfff
syscon nr __NR_fdatasync 0x004b 0x0053 0x20000bb 0x00bb 0x0226 0x005f 0x0f1 0xfff
syscon nr __NR_truncate 0x004c 0x002d 0x20000c8 0x00c8 0x01df 0x00c8 0x0c8 0xfff
syscon nr __NR_ftruncate 0x004d 0x002e 0x20000c9 0x00c9 0x01e0 0x00c9 0x0c9 0xfff
syscon nr __NR_truncate 0x004c 0x002d 0x20000c8 0x00c8 0x01df 0x00a7 0x0c8 0xfff # OpenBSD 7.3+
syscon nr __NR_ftruncate 0x004d 0x002e 0x20000c9 0x00c9 0x01e0 0x00a8 0x0c9 0xfff # OpenBSD 7.3+
syscon nr __NR_getcwd 0x004f 0x0011 0xfff 0xfff 0x0146 0x0130 0x128 0xfff
syscon nr __NR_chdir 0x0050 0x0031 0x200000c 0x000c 0x000c 0x000c 0x00c 0xfff
syscon nr __NR_fchdir 0x0051 0x0032 0x200000d 0x000d 0x000d 0x000d 0x00d 0xfff
@ -1964,8 +1964,8 @@ syscon nr __NR_sync_file_range 0x0115 0x0054 0xfff 0xfff 0xfff 0xfff
syscon nr __NR_vmsplice 0x0116 0x004b 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
syscon nr __NR_migrate_pages 0x0100 0x00ee 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
syscon nr __NR_move_pages 0x0117 0x00ef 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
syscon nr __NR_preadv 0x0127 0x0045 0xfff 0xfff 0x0121 0x010b 0x121 0xfff
syscon nr __NR_pwritev 0x0128 0x0046 0xfff 0xfff 0x0122 0x010c 0x122 0xfff
syscon nr __NR_preadv 0x0127 0x0045 0xfff 0xfff 0x0121 0x00ab 0x121 0xfff # OpenBSD 7.3+
syscon nr __NR_pwritev 0x0128 0x0046 0xfff 0xfff 0x0122 0x00aa 0x122 0xfff # OpenBSD 7.3+
syscon nr __NR_utimensat 0x0118 0x0058 0xfff 0xfff 0x0223 0x0054 0x1d3 0xfff
syscon nr __NR_fallocate 0x011d 0x002f 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
syscon nr __NR_posix_fallocate 0xfff 0xfff 0xfff 0xfff 0x0212 0xfff 0x1df 0xfff