mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-19 00:50:30 +00:00
Fix bugs in cosmocc toolchain
This change integrates e58abc1110b335a3341e8ad5821ad8e3880d9bb2 from https://github.com/ahgamut/musl-cross-make/ which fixes the issues we were having with our C language extension for symbolic constants. This change also performs some code cleanup and bug fixes to getaddrinfo(). It's now possible to compile projects like ncurses, readline and python without needing to patch anything upstream, except maybe a line or two. Pretty soon it should be possible to build a Linux distro on Cosmo.
This commit is contained in:
parent
22f81a8d50
commit
23e235b7a5
272 changed files with 3491 additions and 4350 deletions
|
@ -53,7 +53,7 @@ static int ioctl_tcgets_sysv(int fd, struct termios *tio) {
|
|||
} else if (IsFreebsd() || IsOpenbsd() || IsNetbsd()) {
|
||||
COPY_TERMIOS(tio, &mt.bsd);
|
||||
} else {
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
|
|
|
@ -1260,8 +1260,8 @@ static privileged void OnSigSys(int sig, siginfo_t *si, void *vctx) {
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
Log("error: bad syscall ", GetSyscallName(si->si_syscall),
|
||||
" (ord=", ord, ")\n", NULL);
|
||||
Log("error: bad syscall ", GetSyscallName(si->si_syscall), " (ord=", ord,
|
||||
")\n", NULL);
|
||||
}
|
||||
switch (mode & PLEDGE_PENALTY_MASK) {
|
||||
case PLEDGE_PENALTY_KILL_PROCESS:
|
||||
|
@ -1366,24 +1366,6 @@ static privileged void AllowMonitor(struct Filter *f) {
|
|||
AppendFilter(f, PLEDGE(fragment));
|
||||
}
|
||||
|
||||
// SYSCALL is only allowed in the .privileged section
|
||||
// We assume program image is loaded in 32-bit spaces
|
||||
static privileged void AppendOriginVerification(struct Filter *f) {
|
||||
long x = (long)__privileged_start;
|
||||
long y = (long)__privileged_end;
|
||||
struct sock_filter fragment[] = {
|
||||
/*L0*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(instruction_pointer) + 4),
|
||||
/*L1*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 5 - 2),
|
||||
/*L2*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(instruction_pointer)),
|
||||
/*L3*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, x, 0, 5 - 4),
|
||||
/*L4*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, y, 0, 6 - 5),
|
||||
/*L5*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL),
|
||||
/*L6*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)),
|
||||
/*L7*/ /* next filter */
|
||||
};
|
||||
AppendFilter(f, PLEDGE(fragment));
|
||||
}
|
||||
|
||||
// The first argument of sys_clone_linux() must NOT have:
|
||||
//
|
||||
// - CLONE_NEWNS (0x00020000)
|
||||
|
@ -1615,7 +1597,6 @@ static privileged void AllowGetsockoptRestrict(struct Filter *f) {
|
|||
// - MAP_HUGETLB (0x40000)
|
||||
//
|
||||
static privileged void AllowMmapExec(struct Filter *f) {
|
||||
long y = (long)__privileged_end;
|
||||
static const struct sock_filter fragment[] = {
|
||||
/*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_mmap, 0, 6 - 1),
|
||||
/*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags
|
||||
|
|
|
@ -106,7 +106,7 @@ textwindows int sys_poll_nt(struct pollfd *fds, uint64_t nfds, uint64_t *ms,
|
|||
pipefds[pn].events = fds[i].events & (POLLIN | POLLOUT);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
++pn;
|
||||
} else {
|
||||
|
|
|
@ -255,7 +255,7 @@ ssize_t readansi(int fd, char *p, size_t n) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
} while (t != kDone);
|
||||
errno = e;
|
||||
|
|
|
@ -106,5 +106,5 @@ noasan noubsan int setcontext(const ucontext_t *uc) {
|
|||
"ret"
|
||||
: /* no outputs */
|
||||
: "m"(uc->uc_mcontext.rip), "m"(uc->uc_mcontext.rdi));
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue