mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Disable linker map generation and improve tinyness
This commit is contained in:
parent
23e235b7a5
commit
4b2023ffab
39 changed files with 119 additions and 121 deletions
|
@ -44,9 +44,6 @@ void __assert_fail(const char *, const char *, int) _Hide relegated;
|
|||
})
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_ASSERT_H_ */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#ifndef __x86_64__
|
||||
|
||||
size_t __virtualmax = -1;
|
||||
size_t __virtualmax;
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -28,9 +28,42 @@ _Hide extern const struct MagnumStr kSockOptnames[];
|
|||
_Hide extern const struct MagnumStr kTcpOptnames[];
|
||||
_Hide extern const struct MagnumStr kPollNames[];
|
||||
|
||||
char *GetMagnumStr(const struct MagnumStr *, int);
|
||||
char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int);
|
||||
|
||||
__funline char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
int i;
|
||||
for (i = 0; ms[i].x != MAGNUM_TERMINATOR; ++i) {
|
||||
if (x == MAGNUM_NUMBER(ms, i)) {
|
||||
return MAGNUM_STRING(ms, i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts errno value to descriptive sentence.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
__funline char *_strerdoc(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoDocs, x);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts errno value to symbolic name.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
__funline char *_strerrno(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoNames, x);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_FMT_MAGNUMSTRS_H_ */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
|
||||
privileged char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
int i;
|
||||
for (i = 0; ms[i].x != MAGNUM_TERMINATOR; ++i) {
|
||||
if (x == MAGNUM_NUMBER(ms, i)) {
|
||||
return MAGNUM_STRING(ms, i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -26,6 +26,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/divmod10.internal.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/asancodes.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
|
@ -522,37 +523,13 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
goto EmitChar;
|
||||
|
||||
case 'm': {
|
||||
int unixerr;
|
||||
uint32_t winerr;
|
||||
unixerr = tib ? tib->tib_errno : __errno;
|
||||
winerr = 0;
|
||||
if (IsWindows()) {
|
||||
if (type == 1 && _weaken(__imp_WSAGetLastError)) {
|
||||
winerr = (*_weaken(__imp_WSAGetLastError))();
|
||||
} else if (_weaken(__imp_GetLastError)) {
|
||||
winerr = (*_weaken(__imp_GetLastError))();
|
||||
}
|
||||
}
|
||||
if (!unixerr && sign == ' ') {
|
||||
int e;
|
||||
if (!(e = tib ? tib->tib_errno : __errno) && sign == ' ') {
|
||||
break;
|
||||
} else if (_weaken(strerror_wr) &&
|
||||
!_weaken(strerror_wr)(unixerr, winerr, z, sizeof(z))) {
|
||||
s = z;
|
||||
type = 0;
|
||||
goto FormatString;
|
||||
} else {
|
||||
if (p + 7 <= e) {
|
||||
*p++ = ' ';
|
||||
*p++ = 'e';
|
||||
*p++ = 'r';
|
||||
*p++ = 'r';
|
||||
*p++ = 'n';
|
||||
*p++ = 'o';
|
||||
*p++ = '=';
|
||||
}
|
||||
type = 0;
|
||||
x = unixerr;
|
||||
goto FormatDecimal;
|
||||
s = _strerrno(e);
|
||||
goto FormatString;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
|
||||
/**
|
||||
* Converts errno value to descriptive sentence.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
privileged char *_strerdoc(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoDocs, x);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -17,15 +17,3 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
|
||||
/**
|
||||
* Converts errno value to symbolic name.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
privileged char *_strerrno(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoNames, x);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define ShouldUseMsabiAttribute() 1
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/formatmessageflags.h"
|
||||
|
@ -32,7 +33,7 @@
|
|||
* @param err is error number or zero if unknown
|
||||
* @return 0 on success, or error code
|
||||
*/
|
||||
privileged int strerror_wr(int err, uint32_t winerr, char *buf, size_t size) {
|
||||
int strerror_wr(int err, uint32_t winerr, char *buf, size_t size) {
|
||||
/* kprintf() weakly depends on this function */
|
||||
int c, n;
|
||||
bool wanting;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
│ SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -135,6 +135,7 @@ textstartup void cosmo(long *sp, struct Syslib *m1) {
|
|||
_mmi.p->y = (uintptr_t)(GetStackAddr() + (GetStackSize() - FRAMESIZE)) >> 16;
|
||||
_mmi.p->size = GetStackSize();
|
||||
_mmi.p->prot = PROT_READ | PROT_WRITE;
|
||||
__virtualmax = -1;
|
||||
|
||||
#if 0
|
||||
#if IsAsan()
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
static char stacklog[1024];
|
||||
|
||||
size_t GetStackUsage(char *s, size_t n) {
|
||||
noasan size_t GetStackUsage(char *s, size_t n) {
|
||||
// RHEL5 MAP_GROWSDOWN seems to only grow to 68kb :'(
|
||||
// So we count non-zero bytes down from the top
|
||||
// First clear 64 bytes is considered the end
|
||||
|
|
|
@ -210,8 +210,6 @@ int strerror_r(int, char *, size_t)
|
|||
dontthrow nocallback;
|
||||
int strerror_wr(int, uint32_t, char *, size_t)
|
||||
dontthrow nocallback;
|
||||
char *_strerrno(int) nosideeffect libcesque;
|
||||
char *_strerdoc(int) nosideeffect libcesque;
|
||||
int __xpg_strerror_r(int, char *, size_t)
|
||||
dontthrow nocallback;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue