mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 14:22:28 +00:00
Fix MODE=optlinux and MODE=tiny builds
This commit is contained in:
parent
5660ec4741
commit
0602ff6bab
12 changed files with 75 additions and 36 deletions
|
@ -80,19 +80,19 @@ void SetUp(void) {
|
||||||
sigaction(SIGSEGV, &sa, 0);
|
sigaction(SIGSEGV, &sa, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackOverflow(void);
|
int StackOverflow(int d) {
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
char A[8];
|
||||||
int StackOverflow(void) {
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
return pStackOverflow();
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(stackoverflow, standardStack_altStack_process_longjmp) {
|
TEST(stackoverflow, standardStack_altStack_process_longjmp) {
|
||||||
if (IsTiny())
|
|
||||||
return; // TODO(jart): why?
|
|
||||||
|
|
||||||
int jumpcode;
|
int jumpcode;
|
||||||
if (!(jumpcode = setjmp(recover))) {
|
if (!(jumpcode = setjmp(recover))) {
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
}
|
}
|
||||||
ASSERT_EQ(123, jumpcode);
|
ASSERT_EQ(123, jumpcode);
|
||||||
ASSERT_TRUE(smashed_stack);
|
ASSERT_TRUE(smashed_stack);
|
||||||
|
|
|
@ -51,10 +51,13 @@ void CrashHandler(int sig, siginfo_t *si, void *ctx) {
|
||||||
longjmp(recover, 123);
|
longjmp(recover, 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackOverflow(void);
|
int StackOverflow(int d) {
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
char A[8];
|
||||||
int StackOverflow(void) {
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
return pStackOverflow();
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MyPosixThread(void *arg) {
|
void *MyPosixThread(void *arg) {
|
||||||
|
@ -71,7 +74,7 @@ void *MyPosixThread(void *arg) {
|
||||||
sigaction(SIGBUS, &sa, &o1);
|
sigaction(SIGBUS, &sa, &o1);
|
||||||
sigaction(SIGSEGV, &sa, &o2);
|
sigaction(SIGSEGV, &sa, &o2);
|
||||||
if (!(jumpcode = setjmp(recover))) {
|
if (!(jumpcode = setjmp(recover))) {
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
}
|
}
|
||||||
ASSERT_EQ(123, jumpcode);
|
ASSERT_EQ(123, jumpcode);
|
||||||
sigaction(SIGSEGV, &o2, 0);
|
sigaction(SIGSEGV, &o2, 0);
|
||||||
|
|
|
@ -85,10 +85,13 @@ void CrashHandler(int sig, siginfo_t *si, void *arg) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackOverflow(void);
|
int StackOverflow(int d) {
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
char A[8];
|
||||||
int StackOverflow(void) {
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
return pStackOverflow();
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MyPosixThread(void *arg) {
|
void *MyPosixThread(void *arg) {
|
||||||
|
@ -103,7 +106,7 @@ void *MyPosixThread(void *arg) {
|
||||||
sa.sa_sigaction = CrashHandler;
|
sa.sa_sigaction = CrashHandler;
|
||||||
sigaction(SIGBUS, &sa, 0);
|
sigaction(SIGBUS, &sa, 0);
|
||||||
sigaction(SIGSEGV, &sa, 0);
|
sigaction(SIGSEGV, &sa, 0);
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,13 @@ void CrashHandler(int sig) {
|
||||||
pthread_exit((void *)123L);
|
pthread_exit((void *)123L);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackOverflow(void);
|
int StackOverflow(int d) {
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
char A[8];
|
||||||
int StackOverflow(void) {
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
return pStackOverflow();
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MyPosixThread(void *arg) {
|
void *MyPosixThread(void *arg) {
|
||||||
|
@ -63,7 +66,7 @@ void *MyPosixThread(void *arg) {
|
||||||
sa.sa_handler = CrashHandler;
|
sa.sa_handler = CrashHandler;
|
||||||
sigaction(SIGBUS, &sa, 0);
|
sigaction(SIGBUS, &sa, 0);
|
||||||
sigaction(SIGSEGV, &sa, 0);
|
sigaction(SIGSEGV, &sa, 0);
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,17 @@ void CrashHandler(int sig) {
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackOverflow(void);
|
int StackOverflow(int d) {
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
char A[8];
|
||||||
int StackOverflow(void) {
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
return pStackOverflow();
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MyPosixThread(void *arg) {
|
void *MyPosixThread(void *arg) {
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "libc/intrin/weaken.h"
|
#include "libc/intrin/weaken.h"
|
||||||
#include "libc/limits.h"
|
#include "libc/limits.h"
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
|
#include "libc/macros.internal.h"
|
||||||
#include "libc/mem/leaks.h"
|
#include "libc/mem/leaks.h"
|
||||||
#include "libc/mem/mem.h"
|
#include "libc/mem/mem.h"
|
||||||
#include "libc/runtime/internal.h"
|
#include "libc/runtime/internal.h"
|
||||||
|
@ -28,8 +29,15 @@
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
int StackOverflow(void) {
|
#include <stdlib.h>
|
||||||
return _weaken(StackOverflow)();
|
|
||||||
|
int StackOverflow(int d) {
|
||||||
|
char A[8];
|
||||||
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflow(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FpuCrash(void) {
|
void FpuCrash(void) {
|
||||||
|
@ -85,14 +93,21 @@ int NpeCrash(char *p) {
|
||||||
return *p;
|
return *p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StackOverflowCrash(int d) {
|
||||||
|
char A[8];
|
||||||
|
for (int i = 0; i < sizeof(A); i++)
|
||||||
|
A[i] = d + i;
|
||||||
|
if (__veil("r", d))
|
||||||
|
return StackOverflowCrash(d + 1) + A[d % sizeof(A)];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void (*pFpuCrash)(void) = FpuCrash;
|
void (*pFpuCrash)(void) = FpuCrash;
|
||||||
void (*pBssOverrunCrash)(int) = BssOverrunCrash;
|
void (*pBssOverrunCrash)(int) = BssOverrunCrash;
|
||||||
void (*pDataOverrunCrash)(int) = DataOverrunCrash;
|
void (*pDataOverrunCrash)(int) = DataOverrunCrash;
|
||||||
int (*pRodataOverrunCrash)(int) = RodataOverrunCrash;
|
int (*pRodataOverrunCrash)(int) = RodataOverrunCrash;
|
||||||
char *(*pStackOverrunCrash)(int) = StackOverrunCrash;
|
|
||||||
char *(*pMemoryLeakCrash)(void) = MemoryLeakCrash;
|
char *(*pMemoryLeakCrash)(void) = MemoryLeakCrash;
|
||||||
int (*pNpeCrash)(char *) = NpeCrash;
|
int (*pNpeCrash)(char *) = NpeCrash;
|
||||||
int (*pStackOverflow)(void) = StackOverflow;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
ShowCrashReports();
|
ShowCrashReports();
|
||||||
|
@ -112,7 +127,7 @@ int main(int argc, char *argv[]) {
|
||||||
pDataOverrunCrash(10 + 1);
|
pDataOverrunCrash(10 + 1);
|
||||||
exit(0);
|
exit(0);
|
||||||
case 5:
|
case 5:
|
||||||
exit((intptr_t)pStackOverrunCrash(10 + 10000));
|
exit(StackOverflowCrash(0));
|
||||||
case 6:
|
case 6:
|
||||||
exit((intptr_t)pMemoryLeakCrash());
|
exit((intptr_t)pMemoryLeakCrash());
|
||||||
case 7:
|
case 7:
|
||||||
|
@ -120,7 +135,7 @@ int main(int argc, char *argv[]) {
|
||||||
case 8:
|
case 8:
|
||||||
exit(pNpeCrash(0));
|
exit(pNpeCrash(0));
|
||||||
case 9:
|
case 9:
|
||||||
exit(pStackOverflow());
|
exit(StackOverflow(0));
|
||||||
default:
|
default:
|
||||||
fputs("error: unrecognized argument\n", stderr);
|
fputs("error: unrecognized argument\n", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
2
third_party/libcxx/ryu/d2s.cpp
vendored
2
third_party/libcxx/ryu/d2s.cpp
vendored
|
@ -477,7 +477,7 @@ struct __floating_decimal_64 {
|
||||||
2882303761517u, 576460752303u, 115292150460u, 23058430092u, 4611686018u, 922337203u, 184467440u,
|
2882303761517u, 576460752303u, 115292150460u, 23058430092u, 4611686018u, 922337203u, 184467440u,
|
||||||
36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };
|
36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };
|
||||||
|
|
||||||
unsigned long _Trailing_zero_bits;
|
unsigned long _Trailing_zero_bits = 0;
|
||||||
#ifdef _LIBCPP_HAS_BITSCAN64
|
#ifdef _LIBCPP_HAS_BITSCAN64
|
||||||
(void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
|
(void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
|
||||||
#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
|
#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
|
||||||
|
|
3
third_party/libcxx/string
vendored
3
third_party/libcxx/string
vendored
|
@ -1883,7 +1883,10 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; __first != __last; ++__first)
|
for (; __first != __last; ++__first)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||||
traits_type::assign(*__dest++, *__first);
|
traits_type::assign(*__dest++, *__first);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
return __dest;
|
return __dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
third_party/pcre/pcre2_compile.c
vendored
3
third_party/pcre/pcre2_compile.c
vendored
|
@ -8169,7 +8169,10 @@ if (*code == OP_CBRA)
|
||||||
capitem.number = capnumber;
|
capitem.number = capnumber;
|
||||||
capitem.next = cb->open_caps;
|
capitem.next = cb->open_caps;
|
||||||
capitem.assert_depth = cb->assert_depth;
|
capitem.assert_depth = cb->assert_depth;
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdangling-pointer"
|
||||||
cb->open_caps = &capitem;
|
cb->open_caps = &capitem;
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offset is set zero to mark that this bracket is still open */
|
/* Offset is set zero to mark that this bracket is still open */
|
||||||
|
|
3
third_party/stb/stb_image.c
vendored
3
third_party/stb/stb_image.c
vendored
|
@ -4211,9 +4211,12 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) {
|
||||||
tc16[k] = (uint16_t)stbi__get16be(s); // copy the values as-is
|
tc16[k] = (uint16_t)stbi__get16be(s); // copy the values as-is
|
||||||
} else {
|
} else {
|
||||||
for (k = 0; k < s->img_n; ++k)
|
for (k = 0; k < s->img_n; ++k)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||||
tc[k] = (unsigned char)(stbi__get16be(s) & 255) *
|
tc[k] = (unsigned char)(stbi__get16be(s) & 255) *
|
||||||
stbi__depth_scale_table[z->depth]; // non 8-bit images
|
stbi__depth_scale_table[z->depth]; // non 8-bit images
|
||||||
// will be larger
|
// will be larger
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
3
third_party/tidy/tidy.c
vendored
3
third_party/tidy/tidy.c
vendored
|
@ -1202,7 +1202,10 @@ static tmbstr cleanup_description( ctmbstr description )
|
||||||
name = realloc(name, l_name);
|
name = realloc(name, l_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||||
strncpy(name + i_name, &c, 1);
|
strncpy(name + i_name, &c, 1);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
i_name++;
|
i_name++;
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -653,8 +653,8 @@ int main(int argc, char *argv[]) {
|
||||||
bool hasfunbits;
|
bool hasfunbits;
|
||||||
int useruid, usergid;
|
int useruid, usergid;
|
||||||
int owneruid, ownergid;
|
int owneruid, ownergid;
|
||||||
int oldfsuid, oldfsgid;
|
|
||||||
unsigned long ipromises;
|
unsigned long ipromises;
|
||||||
|
int oldfsuid = 0, oldfsgid = 0;
|
||||||
|
|
||||||
// parse flags
|
// parse flags
|
||||||
GetOpts(argc, argv);
|
GetOpts(argc, argv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue