Release Cosmopolitan v3.3

This change upgrades to GCC 12.3 and GNU binutils 2.42. The GNU linker
appears to have changed things so that only a single de-duplicated str
table is present in the binary, and it gets placed wherever the linker
wants, regardless of what the linker script says. To cope with that we
need to stop using .ident to embed licenses. As such, this change does
significant work to revamp how third party licenses are defined in the
codebase, using `.section .notice,"aR",@progbits`.

This new GCC 12.3 toolchain has support for GNU indirect functions. It
lets us support __target_clones__ for the first time. This is used for
optimizing the performance of libc string functions such as strlen and
friends so far on x86, by ensuring AVX systems favor a second codepath
that uses VEX encoding. It shaves some latency off certain operations.
It's a useful feature to have for scientific computing for the reasons
explained by the test/libcxx/openmp_test.cc example which compiles for
fifteen different microarchitectures. Thanks to the upgrades, it's now
also possible to use newer instruction sets, such as AVX512FP16, VNNI.

Cosmo now uses the %gs register on x86 by default for TLS. Doing it is
helpful for any program that links `cosmo_dlopen()`. Such programs had
to recompile their binaries at startup to change the TLS instructions.
That's not great, since it means every page in the executable needs to
be faulted. The work of rewriting TLS-related x86 opcodes, is moved to
fixupobj.com instead. This is great news for MacOS x86 users, since we
previously needed to morph the binary every time for that platform but
now that's no longer necessary. The only platforms where we need fixup
of TLS x86 opcodes at runtime are now Windows, OpenBSD, and NetBSD. On
Windows we morph TLS to point deeper into the TIB, based on a TlsAlloc
assignment, and on OpenBSD/NetBSD we morph %gs back into %fs since the
kernels do not allow us to specify a value for the %gs register.

OpenBSD users are now required to use APE Loader to run Cosmo binaries
and assimilation is no longer possible. OpenBSD kernel needs to change
to allow programs to specify a value for the %gs register, or it needs
to stop marking executable pages loaded by the kernel as mimmutable().

This release fixes __constructor__, .ctor, .init_array, and lastly the
.preinit_array so they behave the exact same way as glibc.

We no longer use hex constants to define math.h symbols like M_PI.
This commit is contained in:
Justine Tunney 2024-02-20 11:12:09 -08:00
parent d3ff48c63f
commit 957c61cbbf
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
736 changed files with 13726 additions and 9445 deletions

View file

@ -74,11 +74,15 @@ o//libc/intrin/memmove.o: private \
-fno-toplevel-reorder
o//libc/intrin/bzero.o \
o//libc/intrin/strlen.o \
o//libc/intrin/strchr.o \
o//libc/intrin/memchr.o \
o//libc/intrin/memrchr.o \
o//libc/intrin/memcmp.o \
o//libc/intrin/memset.o \
o//libc/intrin/memmove.o: private \
CFLAGS += \
-O2 -finline
-O2 -finline -foptimize-sibling-calls
o/$(MODE)/libc/intrin/bzero.o \
o/$(MODE)/libc/intrin/memcmp.o \
@ -89,7 +93,9 @@ o/$(MODE)/libc/intrin/memmove.o: private \
o/$(MODE)/libc/intrin/x86.o: private \
CFLAGS += \
-ffreestanding \
-fno-jump-tables
-fno-jump-tables \
-fpatchable-function-entry=0 \
-Os
# these assembly files are safe to build on aarch64
o/$(MODE)/libc/intrin/aarch64/%.o: libc/intrin/aarch64/%.S

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __memchr_aarch64 memchr
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64

View file

@ -26,15 +26,11 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __memcpy_aarch64_simd memcpy
#define __memmove_aarch64_simd memmove
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __memrchr_aarch64 memrchr
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __memset_aarch64 memset
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __stpcpy_aarch64 stpcpy
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD.

View file

@ -26,15 +26,11 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strchr_aarch64 strchr
#define __index_aarch64 index
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strchrnul_aarch64 strchrnul
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strcmp_aarch64 strcmp
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strcpy_aarch64 strcpy
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strlen_aarch64 strlen
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strncmp_aarch64 strncmp
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64.

View file

@ -26,14 +26,10 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strnlen_aarch64 strnlen
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64, Advanced SIMD.

View file

@ -26,15 +26,11 @@
*/
#include "libc/intrin/aarch64/asmdefs.internal.h"
.yoink arm_optimized_routines_notice
#define __strrchr_aarch64 strrchr
#define __rindex_aarch64 rindex
.ident "\n\n\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited\n"
.include "libc/disclaimer.inc"
/* Assumptions:
*
* ARMv8-a, AArch64

3
libc/intrin/armopt.c Normal file
View file

@ -0,0 +1,3 @@
__notice(arm_optimized_routines_notice, "\
Optimized Routines (MIT License)\n\
Copyright 2022 ARM Limited");

3
libc/intrin/chromium.c Normal file
View file

@ -0,0 +1,3 @@
__notice(chromium_notice, "\
Chromium (BSD-3 License)\n\
Copyright 2017 The Chromium Authors");

View file

@ -33,10 +33,6 @@ void __cxa_unlock(void) {
pthread_mutex_unlock(&__cxa_lock_obj);
}
static textstartup void __cxa_init() {
__attribute__((__constructor__(60))) static textstartup void __cxa_init() {
pthread_atfork(__cxa_lock, __cxa_unlock, __cxa_wipe);
}
const void *const __cxa_ctor[] initarray = {
__cxa_init,
};

4
libc/intrin/fblibm.c Normal file
View file

@ -0,0 +1,4 @@
__notice(freebsd_libm_notice, "FreeBSD libm (BSD-2 License)\n\
Copyright (c) 1992-2024 The FreeBSD Project.\n\
Copyright (c) 2005-2011 Bruce D. Evans, Steven G. Kargl, David Schultz\n\
Copyright (c) 2009-2013 Steven G. Kargl");

2
libc/intrin/fdlibm.c Normal file
View file

@ -0,0 +1,2 @@
__notice(fdlibm_notice, "fdlibm (fdlibm license)\n\
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.");

2
libc/intrin/folibm.c Normal file
View file

@ -0,0 +1,2 @@
__notice(openbsd_libm_notice, "OpenBSD libm (ISC License)\n\
Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>");

View file

@ -30,10 +30,6 @@ bool32 IsRunningUnderMake(void) {
return g_isrunningundermake;
}
textstartup void g_isrunningundermake_init(void) {
__attribute__((__constructor__(30))) textstartup void onmake_init(void) {
g_isrunningundermake = !!getenv("MAKEFLAGS");
}
const void *const g_isrunningundermake_ctor[] initarray = {
g_isrunningundermake_init,
};

View file

@ -36,8 +36,8 @@ static inline const unsigned char *memchr_pure(const unsigned char *s,
}
#if defined(__x86_64__) && !defined(__chibicc__)
static inline const unsigned char *memchr_sse(const unsigned char *s,
unsigned char c, size_t n) {
static __vex const unsigned char *memchr_sse(const unsigned char *s,
unsigned char c, size_t n) {
size_t i;
unsigned m;
xmm_t v, t = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
@ -67,11 +67,9 @@ static inline const unsigned char *memchr_sse(const unsigned char *s,
* @return is pointer to first instance of c or NULL if not found
* @asyncsignalsafe
*/
__vex void *memchr(const void *s, int c, size_t n) {
void *memchr(const void *s, int c, size_t n) {
#if defined(__x86_64__) && !defined(__chibicc__)
const void *r;
r = memchr_sse(s, c, n);
return (void *)r;
return (void *)memchr_sse(s, c, n);
#else
return (void *)memchr_pure(s, c, n);
#endif

View file

@ -27,66 +27,7 @@
typedef long long xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
typedef long long xmm_a __attribute__((__vector_size__(16), __aligned__(16)));
/**
* Copies memory.
*
* memmove n=0 661 picoseconds
* memmove n=1 661 ps/byte 1,476 mb/s
* memmove n=2 330 ps/byte 2,952 mb/s
* memmove n=3 330 ps/byte 2,952 mb/s
* memmove n=4 165 ps/byte 5,904 mb/s
* memmove n=7 141 ps/byte 6,888 mb/s
* memmove n=8 82 ps/byte 11 GB/s
* memmove n=15 44 ps/byte 21 GB/s
* memmove n=16 41 ps/byte 23 GB/s
* memmove n=31 32 ps/byte 29 GB/s
* memmove n=32 31 ps/byte 30 GB/s
* memmove n=63 21 ps/byte 45 GB/s
* memmove n=64 15 ps/byte 61 GB/s
* memmove n=127 13 ps/byte 73 GB/s
* memmove n=128 31 ps/byte 30 GB/s
* memmove n=255 20 ps/byte 45 GB/s
* memmove n=256 19 ps/byte 49 GB/s
* memmove n=511 16 ps/byte 56 GB/s
* memmove n=512 17 ps/byte 54 GB/s
* memmove n=1023 18 ps/byte 52 GB/s
* memmove n=1024 13 ps/byte 72 GB/s
* memmove n=2047 9 ps/byte 96 GB/s
* memmove n=2048 9 ps/byte 98 GB/s
* memmove n=4095 8 ps/byte 112 GB/s
* memmove n=4096 8 ps/byte 109 GB/s
* memmove n=8191 7 ps/byte 124 GB/s
* memmove n=8192 7 ps/byte 125 GB/s
* memmove n=16383 7 ps/byte 134 GB/s
* memmove n=16384 7 ps/byte 134 GB/s
* memmove n=32767 13 ps/byte 72 GB/s
* memmove n=32768 13 ps/byte 72 GB/s
* memmove n=65535 13 ps/byte 68 GB/s
* memmove n=65536 14 ps/byte 67 GB/s
* memmove n=131071 14 ps/byte 65 GB/s
* memmove n=131072 14 ps/byte 64 GB/s
* memmove n=262143 15 ps/byte 63 GB/s
* memmove n=262144 15 ps/byte 63 GB/s
* memmove n=524287 15 ps/byte 61 GB/s
* memmove n=524288 15 ps/byte 61 GB/s
* memmove n=1048575 15 ps/byte 61 GB/s
* memmove n=1048576 15 ps/byte 61 GB/s
* memmove n=2097151 19 ps/byte 48 GB/s
* memmove n=2097152 27 ps/byte 35 GB/s
* memmove n=4194303 28 ps/byte 33 GB/s
* memmove n=4194304 28 ps/byte 33 GB/s
* memmove n=8388607 28 ps/byte 33 GB/s
* memmove n=8388608 28 ps/byte 33 GB/s
*
* DST and SRC may overlap.
*
* @param dst is destination
* @param src is memory to copy
* @param n is number of bytes to copy
* @return dst
* @asyncsignalsafe
*/
__vex void *memmove(void *dst, const void *src, size_t n) {
static __vex void *__memmove(void *dst, const void *src, size_t n) {
char *d;
size_t i;
const char *s;
@ -338,6 +279,69 @@ __vex void *memmove(void *dst, const void *src, size_t n) {
}
}
/**
* Copies memory.
*
* memmove n=0 661 picoseconds
* memmove n=1 661 ps/byte 1,476 mb/s
* memmove n=2 330 ps/byte 2,952 mb/s
* memmove n=3 330 ps/byte 2,952 mb/s
* memmove n=4 165 ps/byte 5,904 mb/s
* memmove n=7 141 ps/byte 6,888 mb/s
* memmove n=8 82 ps/byte 11 GB/s
* memmove n=15 44 ps/byte 21 GB/s
* memmove n=16 41 ps/byte 23 GB/s
* memmove n=31 32 ps/byte 29 GB/s
* memmove n=32 31 ps/byte 30 GB/s
* memmove n=63 21 ps/byte 45 GB/s
* memmove n=64 15 ps/byte 61 GB/s
* memmove n=127 13 ps/byte 73 GB/s
* memmove n=128 31 ps/byte 30 GB/s
* memmove n=255 20 ps/byte 45 GB/s
* memmove n=256 19 ps/byte 49 GB/s
* memmove n=511 16 ps/byte 56 GB/s
* memmove n=512 17 ps/byte 54 GB/s
* memmove n=1023 18 ps/byte 52 GB/s
* memmove n=1024 13 ps/byte 72 GB/s
* memmove n=2047 9 ps/byte 96 GB/s
* memmove n=2048 9 ps/byte 98 GB/s
* memmove n=4095 8 ps/byte 112 GB/s
* memmove n=4096 8 ps/byte 109 GB/s
* memmove n=8191 7 ps/byte 124 GB/s
* memmove n=8192 7 ps/byte 125 GB/s
* memmove n=16383 7 ps/byte 134 GB/s
* memmove n=16384 7 ps/byte 134 GB/s
* memmove n=32767 13 ps/byte 72 GB/s
* memmove n=32768 13 ps/byte 72 GB/s
* memmove n=65535 13 ps/byte 68 GB/s
* memmove n=65536 14 ps/byte 67 GB/s
* memmove n=131071 14 ps/byte 65 GB/s
* memmove n=131072 14 ps/byte 64 GB/s
* memmove n=262143 15 ps/byte 63 GB/s
* memmove n=262144 15 ps/byte 63 GB/s
* memmove n=524287 15 ps/byte 61 GB/s
* memmove n=524288 15 ps/byte 61 GB/s
* memmove n=1048575 15 ps/byte 61 GB/s
* memmove n=1048576 15 ps/byte 61 GB/s
* memmove n=2097151 19 ps/byte 48 GB/s
* memmove n=2097152 27 ps/byte 35 GB/s
* memmove n=4194303 28 ps/byte 33 GB/s
* memmove n=4194304 28 ps/byte 33 GB/s
* memmove n=8388607 28 ps/byte 33 GB/s
* memmove n=8388608 28 ps/byte 33 GB/s
*
* DST and SRC may overlap.
*
* @param dst is destination
* @param src is memory to copy
* @param n is number of bytes to copy
* @return dst
* @asyncsignalsafe
*/
void *memmove(void *dst, const void *src, size_t n) {
return __memmove(dst, src, n);
}
__weak_reference(memmove, memcpy);
#endif /* __aarch64__ */

View file

@ -36,8 +36,8 @@ static inline const unsigned char *memrchr_pure(const unsigned char *s,
}
#if defined(__x86_64__) && !defined(__chibicc__)
static inline const unsigned char *memrchr_sse(const unsigned char *s,
unsigned char c, size_t n) {
static __vex const unsigned char *memrchr_sse(const unsigned char *s,
unsigned char c, size_t n) {
size_t i;
unsigned m;
xmm_t v, t = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
@ -67,11 +67,9 @@ static inline const unsigned char *memrchr_sse(const unsigned char *s,
* @return is pointer to first instance of c or NULL if not found
* @asyncsignalsafe
*/
__vex void *memrchr(const void *s, int c, size_t n) {
void *memrchr(const void *s, int c, size_t n) {
#if defined(__x86_64__) && !defined(__chibicc__)
const void *r;
r = memrchr_sse(s, c, n);
return (void *)r;
return (void *)memrchr_sse(s, c, n);
#else
return (void *)memrchr_pure(s, c, n);
#endif

3
libc/intrin/musl.c Normal file
View file

@ -0,0 +1,3 @@
__notice(musl_libc_notice, "\
Musl libc (MIT License)\n\
Copyright 2005-2014 Rich Felker, et. al.");

View file

@ -48,13 +48,9 @@
*/
bool __nocolor;
optimizesize textstartup void __nocolor_init(int argc, char **argv, char **envp,
intptr_t *auxv) {
__attribute__((__constructor__(20))) optimizesize textstartup void
__nocolor_init(int argc, char **argv, char **envp, intptr_t *auxv) {
char *s;
__nocolor = (IsWindows() && !IsAtLeastWindows10()) ||
((s = getenv("TERM")) && IsDumb(s));
}
const void *const __nocolor_ctor[] initarray = {
__nocolor_init,
};

View file

@ -28,11 +28,8 @@
#include "libc/limits.h"
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
__static_yoink("musl_libc_notice");
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
long double scalblnl(long double x, long n) {

View file

@ -26,11 +26,8 @@
*/
#include "libc/math.h"
__static_yoink("musl_libc_notice");
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
/**

View file

@ -26,11 +26,8 @@
*/
#include "libc/math.h"
__static_yoink("musl_libc_notice");
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
/**

View file

@ -28,11 +28,8 @@
#include "libc/math.h"
#include "libc/tinymath/ldshape.internal.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
__static_yoink("musl_libc_notice");
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
/**

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
#include "libc/notice.inc"
// Canary for -fstack-protector.
//

View file

@ -31,7 +31,7 @@ static inline const char *strchr_pure(const char *s, int c) {
#if defined(__x86_64__) && !defined(__chibicc__)
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
static inline const char *strchr_sse(const char *s, unsigned char c) {
static __vex const char *strchr_sse(const char *s, unsigned char c) {
unsigned k;
unsigned m;
const xmm_t *p;
@ -94,7 +94,7 @@ static inline const char *strchr_x64(const char *p, uint64_t c) {
* @asyncsignalsafe
* @vforksafe
*/
__vex char *strchr(const char *s, int c) {
char *strchr(const char *s, int c) {
#if defined(__x86_64__) && !defined(__chibicc__)
const char *r;
if (X86_HAVE(SSE)) {
@ -102,7 +102,6 @@ __vex char *strchr(const char *s, int c) {
} else {
r = strchr_pure(s, c);
}
unassert(!r || *r || !(c & 255));
return (char *)r;
#else
const char *r;
@ -110,9 +109,7 @@ __vex char *strchr(const char *s, int c) {
if ((*s & 255) == c) return (char *)s;
if (!*s) return NULL;
}
r = strchr_x64(s, c);
unassert(!r || *r || !c);
return (char *)r;
return (char *)strchr_x64(s, c);
#endif
}

View file

@ -20,14 +20,7 @@
#include "libc/str/str.h"
#ifndef __aarch64__
/**
* Returns length of NUL-terminated string.
*
* @param s is non-null NUL-terminated string pointer
* @return number of bytes (excluding NUL)
* @asyncsignalsafe
*/
size_t strlen(const char *s) {
static __vex size_t __strlen(const char *s) {
#if defined(__x86_64__) && !defined(__chibicc__)
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
xmm_t z = {0};
@ -56,4 +49,16 @@ size_t strlen(const char *s) {
return (const char *)p + (__builtin_ctzl(w) >> 3) - s;
#endif
}
/**
* Returns length of NUL-terminated string.
*
* @param s is non-null NUL-terminated string pointer
* @return number of bytes (excluding NUL)
* @asyncsignalsafe
*/
size_t strlen(const char *s) {
return __strlen(s);
}
#endif /* __aarch64__ */

View file

@ -627,7 +627,7 @@ void *__ubsan_get_current_report_data(void) {
return 0;
}
static textstartup void ubsan_init() {
__attribute__((__constructor__(90))) static textstartup void ubsan_init() {
STRACE(" _ _ ____ ____ _ _ _");
STRACE("| | | | __ ) ___| / \\ | \\ | |");
STRACE("| | | | _ \\___ \\ / _ \\ | \\| |");
@ -635,7 +635,3 @@ static textstartup void ubsan_init() {
STRACE(" \\___/|____/____/_/ \\_\\_| \\_|");
STRACE("cosmopolitan behavior module initialized");
}
const void *const ubsan_ctor[] initarray = {
ubsan_init,
};

View file

@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//
#if defined(__x86_64__) && (defined(__GNUC__) || defined(__clang__))
#include "libc/intrin/strace.internal.h"
#include "third_party/compiler_rt/cpu_model.h"
enum VendorSignatures {
SIG_INTEL = 0x756e6547, // Genu
@ -740,8 +738,6 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
#undef setFeature
}
int __cpu_indicator_init(void) CONSTRUCTOR_ATTRIBUTE;
struct __processor_model {
unsigned int __cpu_vendor;
unsigned int __cpu_type;
@ -757,7 +753,7 @@ unsigned __cpu_features2[(CPU_FEATURE_MAX - 1) / 32];
// the priority set. However, it still runs after ifunc initializers and
// needs to be called explicitly there.
int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
__attribute__((__constructor__(1))) textstartup int __cpu_indicator_init(void) {
unsigned EAX, EBX, ECX, EDX;
unsigned MaxLeaf = 5;
unsigned Vendor;