mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
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:
parent
6843150e0c
commit
7e0a09feec
510 changed files with 1783 additions and 1483 deletions
|
@ -35,9 +35,9 @@ TEST(_bitreverse, test) {
|
|||
|
||||
BENCH(_bitreverse, bench) {
|
||||
EZBENCH2("_bitreverse8", donothing,
|
||||
EXPROPRIATE(_bitreverse8(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse8(__conceal("r", 123))));
|
||||
EZBENCH2("_bitreverse32", donothing,
|
||||
EXPROPRIATE(_bitreverse32(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse32(__conceal("r", 123))));
|
||||
EZBENCH2("_bitreverse64", donothing,
|
||||
EXPROPRIATE(_bitreverse64(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse64(__conceal("r", 123))));
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ TEST(ksnprintf, fuzzTheUnbreakable) {
|
|||
uint64_t x;
|
||||
char *f, b[32];
|
||||
_Alignas(FRAMESIZE) static const char weasel[FRAMESIZE];
|
||||
f = VEIL("r", weasel);
|
||||
f = __veil("r", weasel);
|
||||
EXPECT_SYS(0, 0, mprotect(f, FRAMESIZE, PROT_READ | PROT_WRITE));
|
||||
strcpy(f, "hello %s\n");
|
||||
EXPECT_EQ(12, ksnprintf(b, sizeof(b), f, "world"));
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
static noasan void *golden(void *p, int c, size_t n) {
|
||||
static dontasan void *golden(void *p, int c, size_t n) {
|
||||
size_t i;
|
||||
if (IsAsan()) __asan_verify(p, n);
|
||||
for (i = 0; i < n; ++i) ((char *)p)[i] = c;
|
||||
|
|
|
@ -60,6 +60,6 @@ TEST(unmorton, test) {
|
|||
|
||||
BENCH(morton, bench) {
|
||||
EZBENCH2("morton", donothing,
|
||||
EXPROPRIATE(morton(CONCEAL("r", 123), CONCEAL("r", 123))));
|
||||
EZBENCH2("unmorton", donothing, EXPROPRIATE(unmorton(CONCEAL("r", 123))));
|
||||
__expropriate(morton(__conceal("r", 123), __conceal("r", 123))));
|
||||
EZBENCH2("unmorton", donothing, __expropriate(unmorton(__conceal("r", 123))));
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
@ -28,14 +28,14 @@ void SetUpOnce(void) {
|
|||
|
||||
TEST(popcnt, test) {
|
||||
EXPECT_EQ(32, popcnt(0x5555555555555555));
|
||||
EXPECT_EQ(32, popcnt(VEIL("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, (popcnt)(VEIL("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, popcnt(__veil("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, (popcnt)(__veil("r", 0x5555555555555555)));
|
||||
}
|
||||
|
||||
BENCH(popcnt, bench) {
|
||||
EZBENCH2("popcnt", donothing,
|
||||
EXPROPRIATE(popcnt(VEIL("r", 0x5555555555555555))));
|
||||
__expropriate(popcnt(__veil("r", 0x5555555555555555))));
|
||||
EZBENCH2("(popcnt)", donothing,
|
||||
EXPROPRIATE((popcnt)(VEIL("r", 0x5555555555555555))));
|
||||
__expropriate((popcnt)(__veil("r", 0x5555555555555555))));
|
||||
EZBENCH_N("_countbits", kHyperionSize, _countbits(kHyperion, kHyperionSize));
|
||||
}
|
||||
|
|
|
@ -93,15 +93,16 @@ TEST(strchr, fuzz) {
|
|||
}
|
||||
|
||||
BENCH(strchr, bench) {
|
||||
EZBENCH2("strchr 0", donothing, EXPROPRIATE(strchr(VEIL("r", ""), 0)));
|
||||
EZBENCH2("strchr 5", donothing, EXPROPRIATE(strchr(VEIL("r", "hello"), 'o')));
|
||||
EZBENCH2("strchr 0", donothing, __expropriate(strchr(__veil("r", ""), 0)));
|
||||
EZBENCH2("strchr 5", donothing,
|
||||
__expropriate(strchr(__veil("r", "hello"), 'o')));
|
||||
EZBENCH2("strchr 8", donothing,
|
||||
EXPROPRIATE(strchr(VEIL("r", "hellzzzo"), 'o')));
|
||||
__expropriate(strchr(__veil("r", "hellzzzo"), 'o')));
|
||||
EZBENCH2("strchr 17", donothing,
|
||||
EXPROPRIATE(strchr(VEIL("r", "hellzzzhellzzzeeo"), 'o')));
|
||||
__expropriate(strchr(__veil("r", "hellzzzhellzzzeeo"), 'o')));
|
||||
EZBENCH2("strchr 34", donothing,
|
||||
EXPROPRIATE(
|
||||
strchr(VEIL("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o')));
|
||||
__expropriate(
|
||||
strchr(__veil("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o')));
|
||||
}
|
||||
|
||||
char *memchr_pure(const char *m, int c, size_t n) {
|
||||
|
|
|
@ -543,37 +543,37 @@ BENCH(bench_00_strcmp, bench) {
|
|||
dupe = gc(malloc(size));
|
||||
|
||||
EZBENCH2("strcmp [identity]", longstringislong(size, data),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), data)));
|
||||
__expropriate(strcmp(__veil("r", data), data)));
|
||||
|
||||
EZBENCH2("strcmp [2 diff]", donothing,
|
||||
EXPROPRIATE(strcmp(VEIL("r", "hi"), VEIL("r", "there"))));
|
||||
__expropriate(strcmp(__veil("r", "hi"), __veil("r", "there"))));
|
||||
EZBENCH2("scmppure [2 diff]", donothing,
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", "hi"), VEIL("r", "there"))));
|
||||
__expropriate(strcmp_pure(__veil("r", "hi"), __veil("r", "there"))));
|
||||
|
||||
EZBENCH2("strcmp [2 dupe]", randomize_buf2str_dupe(2, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [2 dupe]", randomize_buf2str_dupe(2, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [4 dupe]", randomize_buf2str_dupe(4, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [4 dupe]", randomize_buf2str_dupe(4, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [8 dupe]", randomize_buf2str_dupe(8, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [8 dupe]", randomize_buf2str_dupe(8, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
}
|
||||
|
||||
BENCH(bench_01_strcasecmp, bench) {
|
||||
|
@ -584,26 +584,28 @@ BENCH(bench_01_strcasecmp, bench) {
|
|||
dupe = gc(malloc(size));
|
||||
|
||||
EZBENCH2("strcasecmp [iden]", longstringislong(size, data),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), data)));
|
||||
__expropriate(strcasecmp(__veil("r", data), data)));
|
||||
|
||||
EZBENCH2("strcasecmp [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
EZBENCH2("sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcasecmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2(
|
||||
"sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
__expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcasecmp [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
EZBENCH2("sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcasecmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2(
|
||||
"sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
__expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
}
|
||||
|
||||
BENCH(memcmp, bench) {
|
||||
volatile char *copy = gc(strdup(kHyperion));
|
||||
EZBENCH2("memcmp big", donothing,
|
||||
EXPROPRIATE(memcmp(kHyperion, copy, kHyperionSize)));
|
||||
__expropriate(memcmp(kHyperion, copy, kHyperionSize)));
|
||||
copy = gc(strdup("tough little ship"));
|
||||
EZBENCH2("memcmp 18", donothing,
|
||||
EXPROPRIATE(memcmp("tough little ship", copy, 18)));
|
||||
__expropriate(memcmp("tough little ship", copy, 18)));
|
||||
}
|
||||
|
||||
/* jart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue