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

@ -126,7 +126,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) {
return 0;
}
// More input remains therefore we must have filled |b2b->block|.
_unassert(b2b->block_used == BLAKE2B_CBLOCK);
unassert(b2b->block_used == BLAKE2B_CBLOCK);
Blake2bTransform(b2b, b2b->block.words, BLAKE2B_CBLOCK,
/*is_final_block=*/0);
b2b->block_used = 0;

View file

@ -52,8 +52,8 @@ static unsigned _getcachesize_cpuid4(int type, int level) {
* @return size in bytes, or 0 if unknown
*/
unsigned _getcachesize(int type, int level) {
_unassert(1 <= type && type <= 3);
_unassert(level >= 1);
unassert(1 <= type && type <= 3);
unassert(level >= 1);
return _getcachesize_cpuid4(type, level);
}

View file

@ -51,7 +51,7 @@ static const char kUtf8Dispatch[] = {
*
* @param size if -1 implies strlen
*/
noasan bool _isutf8(const void *data, size_t size) {
dontasan bool _isutf8(const void *data, size_t size) {
long c;
unsigned m;
const char *p, *e;

View file

@ -32,8 +32,8 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @param needlelen is its character count
* @return pointer to first result or NULL if not found
*/
noasan void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen) {
dontasan void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen) {
#ifdef __x86_64__
char c;
xmm_t n, *v;

View file

@ -35,8 +35,8 @@ static inline const char16_t *memrchr16_pure(const char16_t *s, char16_t c,
}
#ifdef __x86_64__
noasan static inline const char16_t *memrchr16_sse(const char16_t *s,
char16_t c, size_t n) {
dontasan static inline const char16_t *memrchr16_sse(const char16_t *s,
char16_t c, size_t n) {
size_t i;
unsigned k, m;
xmm_t v, t = {c, c, c, c, c, c, c, c};

View file

@ -33,7 +33,8 @@ static inline const unsigned char *rawmemchr_pure(const unsigned char *s,
#ifdef __x86_64__
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
noasan static inline const char *rawmemchr_sse(const char *s, unsigned char c) {
dontasan static inline const char *rawmemchr_sse(const char *s,
unsigned char c) {
unsigned k;
unsigned m;
xmm_t v, *p;
@ -53,7 +54,7 @@ noasan static inline const char *rawmemchr_sse(const char *s, unsigned char c) {
}
#endif
static inline noasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
static inline dontasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
return (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;

View file

@ -29,7 +29,7 @@
* @return is <0, 0, or >0 based on tolower(uint8_t) comparison
* @asyncsignalsafe
*/
noasan int strcasecmp(const char *a, const char *b) {
dontasan int strcasecmp(const char *a, const char *b) {
int x, y;
size_t i = 0;
uint64_t v, w, d;

View file

@ -35,7 +35,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @asyncsignalsafe
* @see strstr()
*/
noasan char *strcasestr(const char *haystack, const char *needle) {
dontasan char *strcasestr(const char *haystack, const char *needle) {
#ifdef __x86_64__
char c;
xmm_t *p;

View file

@ -29,7 +29,7 @@ typedef char16_t xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @return number of shorts (excluding NUL)
* @asyncsignalsafe
*/
noasan size_t strlen16(const char16_t *s) {
dontasan size_t strlen16(const char16_t *s) {
#ifdef __x86_64__
size_t n;
xmm_t z = {0};

View file

@ -27,11 +27,11 @@
* @return number of shorts
* @asyncsignalsafe
*/
noasan size_t strnlen16(const char16_t *s, size_t n) {
dontasan size_t strnlen16(const char16_t *s, size_t n) {
size_t i;
for (i = 0;; ++i) {
if (i == n || !s[i]) break;
}
_unassert(i == n || (i < n && !s[i]));
unassert(i == n || (i < n && !s[i]));
return i;
}

View file

@ -21,7 +21,7 @@
#include "libc/intrin/asan.internal.h"
#include "libc/str/str.h"
static noasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) {
static dontasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) {
uint64_t w;
for (; i + 8 < n; i += 8) {
w = *(uint64_t *)(s + i);
@ -45,7 +45,7 @@ static noasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) {
* @return byte length
* @asyncsignalsafe
*/
noasan size_t strnlen_s(const char *s, size_t n) {
dontasan size_t strnlen_s(const char *s, size_t n) {
size_t i;
if (!s) return 0;
if (IsAsan()) __asan_verify(s, n);
@ -56,6 +56,6 @@ noasan size_t strnlen_s(const char *s, size_t n) {
for (;; ++i) {
if (i == n || !s[i]) break;
}
_unassert(i == n || (i < n && !s[i]));
unassert(i == n || (i < n && !s[i]));
return i;
}

View file

@ -35,7 +35,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @see strcasestr()
* @see memmem()
*/
noasan char *strstr(const char *haystack, const char *needle) {
dontasan char *strstr(const char *haystack, const char *needle) {
#ifdef __x86_64__
xmm_t *p;
size_t i;

View file

@ -42,7 +42,7 @@
* @note if dest is NULL, count has to be zero
*/
size_t strxfrm(char *dest, const char *src, size_t count) {
_unassert(dest == NULL ? count == 0 : 1);
unassert(dest == NULL ? count == 0 : 1);
return strlcpy(dest, src, count);
}

View file

@ -24,8 +24,8 @@
typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
size_t n) {
dontasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
size_t n) {
uint64_t w;
xmm_t a = {0};
while (n > 16 + 16) {
@ -41,9 +41,9 @@ noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
}
#ifdef __x86_64__
noasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p,
const char *q,
size_t n) {
dontasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p,
const char *q,
size_t n) {
uint64_t w;
xmm_t a = {0};
if (n > 32) {

View file

@ -27,8 +27,8 @@
static const int16_t kDel16[8] = {127, 127, 127, 127, 127, 127, 127, 127};
/* 10x speedup for ascii */
static noasan axdx_t tprecode16to8_sse2(char *dst, size_t dstsize,
const char16_t *src, axdx_t r) {
static dontasan axdx_t tprecode16to8_sse2(char *dst, size_t dstsize,
const char16_t *src, axdx_t r) {
int16_t v1[8], v2[8], v3[8], vz[8];
memset(vz, 0, 16);
while (r.ax + 8 < dstsize) {

View file

@ -25,8 +25,8 @@
#include "libc/str/utf16.h"
/* 34x speedup for ascii */
static inline noasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize,
const char *src, axdx_t r) {
static inline dontasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize,
const char *src, axdx_t r) {
uint8_t v1[16], v2[16], vz[16];
memset(vz, 0, 16);
while (r.ax + 16 < dstsize) {

View file

@ -29,7 +29,7 @@ typedef wchar_t xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @return number of wide characters (excluding NUL)
* @asyncsignalsafe
*/
noasan size_t wcslen(const wchar_t *s) {
dontasan size_t wcslen(const wchar_t *s) {
#ifdef __x86_64__
size_t n;
xmm_t z = {0};

View file

@ -36,8 +36,8 @@ static inline const wchar_t *wmemrchr_pure(const wchar_t *s, wchar_t c,
}
#ifdef __x86_64__
noasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c,
size_t n) {
dontasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c,
size_t n) {
size_t i;
unsigned k, m;
xmm_t v, t = {c, c, c, c};