mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 05:20:28 +00:00
Make redbean StoreAsset() work better
- Better UBSAN error messages - POSIX Advisory Locks polyfills - Move redbean manual to /.help.txt - System call memory safety in ASAN mode - Character classification now does UNICODE
This commit is contained in:
parent
919b6fec10
commit
690be544da
228 changed files with 3653 additions and 3015 deletions
|
@ -91,6 +91,9 @@ bool wantpg;
|
|||
bool wantrecord;
|
||||
bool wantubsan;
|
||||
bool touchtarget;
|
||||
bool no_sanitize_null;
|
||||
bool no_sanitize_alignment;
|
||||
bool no_sanitize_pointer_overflow;
|
||||
|
||||
char *cmd;
|
||||
char *comdbg;
|
||||
|
@ -400,6 +403,12 @@ int main(int argc, char *argv[]) {
|
|||
} else if (!strcmp(argv[i], "-fno-sanitize=all")) {
|
||||
wantasan = false;
|
||||
wantubsan = false;
|
||||
} else if (!strcmp(argv[i], "-fno-sanitize=null")) {
|
||||
if (isgcc && ccversion >= 6) no_sanitize_null = true;
|
||||
} else if (!strcmp(argv[i], "-fno-sanitize=alignment")) {
|
||||
if (isgcc && ccversion >= 6) no_sanitize_alignment = true;
|
||||
} else if (!strcmp(argv[i], "-fno-sanitize=pointer-overflow")) {
|
||||
if (isgcc && ccversion >= 6) no_sanitize_pointer_overflow = true;
|
||||
} else if (startswith(argv[i], "-fsanitize=implicit") &&
|
||||
strstr(argv[i], "integer")) {
|
||||
if (isgcc) AddArg(argv[i]);
|
||||
|
@ -470,6 +479,15 @@ int main(int argc, char *argv[]) {
|
|||
AddArg("-fsanitize=undefined");
|
||||
AddArg("-fno-data-sections");
|
||||
}
|
||||
if (no_sanitize_null) {
|
||||
AddArg("-fno-sanitize=null");
|
||||
}
|
||||
if (no_sanitize_alignment) {
|
||||
AddArg("-fno-sanitize=alignment");
|
||||
}
|
||||
if (no_sanitize_pointer_overflow) {
|
||||
AddArg("-fno-sanitize=pointer-overflow");
|
||||
}
|
||||
if (wantframe) {
|
||||
AddArg("-fno-omit-frame-pointer");
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
.macro .errno local:req linux:req
|
||||
.globl \local
|
||||
.long \local-kLinuxErrnos
|
||||
.long \linux
|
||||
.byte \linux
|
||||
.endm
|
||||
|
||||
// Lookup table translating errnos between systems.
|
||||
//
|
||||
// @see libc/sysv/systemfive.S
|
||||
.rodata
|
||||
.align 8
|
||||
.align 4
|
||||
kLinuxErrnos:
|
||||
.errno EPERM,1
|
||||
.errno ENOENT,2
|
||||
|
@ -85,47 +85,18 @@ kLinuxErrnos:
|
|||
.errno EAFNOSUPPORT,97
|
||||
.errno EADDRINUSE,98
|
||||
.errno EADDRNOTAVAIL,99
|
||||
.errno ECHRNG,44
|
||||
.errno EL2NSYNC,45
|
||||
.errno EL3HLT,46
|
||||
.errno EL3RST,47
|
||||
.errno ELNRNG,48
|
||||
.errno EUNATCH,49
|
||||
.errno ENOCSI,50
|
||||
.errno EL2HLT,51
|
||||
.errno EBADE,52
|
||||
.errno EBADR,53
|
||||
.errno EXFULL,54
|
||||
.errno ENOANO,55
|
||||
.errno EBADRQC,56
|
||||
.errno EBADSLT,57
|
||||
.errno ENOSTR,60
|
||||
.errno ENODATA,61
|
||||
.errno ETIME,62
|
||||
.errno ENOSR,63
|
||||
.errno ENONET,64
|
||||
.errno ENOPKG,65
|
||||
.errno EREMOTE,66
|
||||
.errno ENOLINK,67
|
||||
.errno EADV,68
|
||||
.errno ESRMNT,69
|
||||
.errno ECOMM,70
|
||||
.errno EPROTO,71
|
||||
.errno EMULTIHOP,72
|
||||
.errno EDOTDOT,73
|
||||
.errno EBADMSG,74
|
||||
.errno EOVERFLOW,75
|
||||
.errno ENOTUNIQ,76
|
||||
.errno EBADFD,77
|
||||
.errno EREMCHG,78
|
||||
.errno ELIBACC,79
|
||||
.errno ELIBBAD,80
|
||||
.errno ELIBSCN,81
|
||||
.errno ELIBMAX,82
|
||||
.errno ELIBEXEC,83
|
||||
.errno EILSEQ,84
|
||||
.errno ERESTART,85
|
||||
.errno ESTRPIPE,86
|
||||
.errno ENETDOWN,100
|
||||
.errno ENETUNREACH,101
|
||||
.errno ENETRESET,102
|
||||
|
@ -143,23 +114,10 @@ kLinuxErrnos:
|
|||
.errno EALREADY,114
|
||||
.errno EINPROGRESS,115
|
||||
.errno ESTALE,116
|
||||
.errno EUCLEAN,117
|
||||
.errno ENOTNAM,118
|
||||
.errno ENAVAIL,119
|
||||
.errno EISNAM,120
|
||||
.errno EREMOTEIO,121
|
||||
.errno EDQUOT,122
|
||||
.errno ENOMEDIUM,123
|
||||
.errno EMEDIUMTYPE,124
|
||||
.errno ECANCELED,125
|
||||
.errno ENOKEY,126
|
||||
.errno EKEYEXPIRED,127
|
||||
.errno EKEYREVOKED,128
|
||||
.errno EKEYREJECTED,129
|
||||
.errno EOWNERDEAD,130
|
||||
.errno ENOTRECOVERABLE,131
|
||||
.errno ERFKILL,132
|
||||
.errno EHWPOISON,133
|
||||
.long 0
|
||||
.byte 0
|
||||
.endobj kLinuxErrnos,globl
|
||||
kLinuxErrnosLength = (.-kLinuxErrnos)/8
|
||||
.globl kLinuxErrnosLength
|
||||
|
|
|
@ -21,42 +21,21 @@
|
|||
#include "libc/runtime/carsort.h"
|
||||
#include "tool/build/lib/xlaterrno.h"
|
||||
|
||||
struct LinuxErrno {
|
||||
struct thatispacked LinuxErrno {
|
||||
int32_t local;
|
||||
int32_t linux;
|
||||
uint8_t linux;
|
||||
};
|
||||
|
||||
extern const char kLinuxErrnosLength[];
|
||||
extern const struct LinuxErrno kLinuxErrnos[];
|
||||
static struct LinuxErrno *errnos;
|
||||
|
||||
/**
|
||||
* Turns local errno into Linux errno.
|
||||
*/
|
||||
int XlatErrno(int local) {
|
||||
static bool once;
|
||||
long i, n, m, l, r;
|
||||
n = (uintptr_t)kLinuxErrnosLength;
|
||||
if (!once) {
|
||||
errnos = malloc(sizeof(struct LinuxErrno) * n);
|
||||
for (i = 0; i < n; ++i) {
|
||||
errnos[i].local =
|
||||
*(int *)((intptr_t)kLinuxErrnos + kLinuxErrnos[i].local);
|
||||
errnos[i].linux = kLinuxErrnos[i].linux;
|
||||
}
|
||||
carsort100(n, (void *)errnos);
|
||||
once = true;
|
||||
}
|
||||
l = 0;
|
||||
r = n - 1;
|
||||
while (l <= r) {
|
||||
m = (l + r) / 2;
|
||||
if (errnos[m].local < local) {
|
||||
l = m + 1;
|
||||
} else if (errnos[m].local > local) {
|
||||
r = m - 1;
|
||||
} else {
|
||||
return errnos[m].linux;
|
||||
int i;
|
||||
for (i = 0; kLinuxErrnos[i].local; ++i) {
|
||||
if (local == *(int *)((intptr_t)kLinuxErrnos + kLinuxErrnos[i].local)) {
|
||||
return kLinuxErrnos[i].linux;
|
||||
}
|
||||
}
|
||||
return ENOSYS;
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/ai.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue