From 675b1a15a17d796fa9e48902047c3c7b350a1d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 31 Jul 2025 22:08:36 +0200 Subject: [PATCH] glibc: update crt0 code to 2.42 --- lib/libc/glibc/elf/elf.h | 33 +++---- lib/libc/glibc/include/elf.h | 13 +++ lib/libc/glibc/include/libc-symbols.h | 8 +- lib/libc/glibc/include/stdlib.h | 15 ++++ lib/libc/glibc/io/fcntl.h | 9 +- lib/libc/glibc/posix/bits/types.h | 2 +- lib/libc/glibc/stdlib/stdlib.h | 6 ++ .../aarch64/nptl/bits/pthreadtypes-arch.h | 24 ++--- lib/libc/glibc/sysdeps/aarch64/start-2.33.S | 25 ++++-- lib/libc/glibc/sysdeps/aarch64/start.S | 14 +-- lib/libc/glibc/sysdeps/aarch64/sysdep.h | 87 ++----------------- lib/libc/glibc/sysdeps/generic/sysdep.h | 3 + lib/libc/glibc/sysdeps/htl/libc-lockP.h | 49 +++-------- lib/libc/glibc/sysdeps/mach/sysdep.h | 5 ++ lib/libc/glibc/sysdeps/nptl/pthread.h | 5 ++ lib/libc/glibc/sysdeps/sparc/sparc32/start.S | 11 ++- lib/libc/glibc/sysdeps/sparc/sparc64/start.S | 4 + .../sysdeps/unix/sysv/linux/aarch64/sysdep.h | 9 +- .../sysdeps/unix/sysv/linux/kernel-features.h | 4 + .../sysdeps/unix/sysv/linux/riscv/sysdep.h | 3 +- lib/libc/glibc/sysdeps/x86/sysdep.h | 29 +++++++ 21 files changed, 165 insertions(+), 193 deletions(-) diff --git a/lib/libc/glibc/elf/elf.h b/lib/libc/glibc/elf/elf.h index 96df2eec01..2f29a47c0b 100644 --- a/lib/libc/glibc/elf/elf.h +++ b/lib/libc/glibc/elf/elf.h @@ -837,12 +837,15 @@ typedef struct #define NT_ARM_ZT 0x40d /* ARM SME ZT registers. */ #define NT_ARM_FPMR 0x40e /* ARM floating point mode register. */ #define NT_ARM_POE 0x40f /* ARM POE registers. */ +#define NT_ARM_GCS 0x410 /* ARM GCS state. */ #define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */ #define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */ #define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */ #define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */ #define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */ +#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged + address control */ #define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers. */ #define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers. */ @@ -2906,19 +2909,6 @@ enum #define R_AARCH64_NONE 0 /* No relocation. */ -/* ILP32 AArch64 relocs. */ -#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */ -#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */ -#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */ -#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */ -#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */ -#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */ -#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */ -#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */ -#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */ -#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */ - -/* LP64 AArch64 relocs. */ #define R_AARCH64_ABS64 257 /* Direct 64 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */ #define R_AARCH64_ABS16 259 /* Direct 16-bit. */ @@ -4091,6 +4081,7 @@ enum #define R_RISCV_TLS_DTPREL64 9 #define R_RISCV_TLS_TPREL32 10 #define R_RISCV_TLS_TPREL64 11 +#define R_RISCV_TLSDESC 12 #define R_RISCV_BRANCH 16 #define R_RISCV_JAL 17 #define R_RISCV_CALL 18 @@ -4116,16 +4107,10 @@ enum #define R_RISCV_SUB16 38 #define R_RISCV_SUB32 39 #define R_RISCV_SUB64 40 -#define R_RISCV_GNU_VTINHERIT 41 -#define R_RISCV_GNU_VTENTRY 42 +#define R_RISCV_GOT32_PCREL 41 #define R_RISCV_ALIGN 43 #define R_RISCV_RVC_BRANCH 44 #define R_RISCV_RVC_JUMP 45 -#define R_RISCV_RVC_LUI 46 -#define R_RISCV_GPREL_I 47 -#define R_RISCV_GPREL_S 48 -#define R_RISCV_TPREL_I 49 -#define R_RISCV_TPREL_S 50 #define R_RISCV_RELAX 51 #define R_RISCV_SUB6 52 #define R_RISCV_SET6 53 @@ -4137,8 +4122,12 @@ enum #define R_RISCV_PLT32 59 #define R_RISCV_SET_ULEB128 60 #define R_RISCV_SUB_ULEB128 61 +#define R_RISCV_TLSDESC_HI20 62 +#define R_RISCV_TLSDESC_LOAD_LO12 63 +#define R_RISCV_TLSDESC_ADD_LO12 64 +#define R_RISCV_TLSDESC_CALL 65 -#define R_RISCV_NUM 62 +#define R_RISCV_NUM 66 /* RISC-V specific values for the st_other field. */ #define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling @@ -4147,7 +4136,7 @@ enum /* RISC-V specific values for the sh_type field. */ #define SHT_RISCV_ATTRIBUTES (SHT_LOPROC + 3) -/* RISC-V specific values for the p_type field. */ +/* RISC-V specific values for the p_type field (deprecated). */ #define PT_RISCV_ATTRIBUTES (PT_LOPROC + 3) /* RISC-V specific values for the d_tag field. */ diff --git a/lib/libc/glibc/include/elf.h b/lib/libc/glibc/include/elf.h index 14ed67ff67..1424982bb5 100644 --- a/lib/libc/glibc/include/elf.h +++ b/lib/libc/glibc/include/elf.h @@ -15,6 +15,19 @@ # define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \ ALIGN_UP (ELF_NOTE_DESC_OFFSET ((namesz), (align)) + (descsz), (align)) +# ifdef HIDDEN_VAR_NEEDS_DYNAMIC_RELOC +# define DL_ADDRESS_WITHOUT_RELOC(expr) (expr) +# else +/* Evaluate EXPR without run-time relocation for it. EXPR should be an + array, an address of an object, or a string literal. */ +# define DL_ADDRESS_WITHOUT_RELOC(expr) \ + ({ \ + __auto_type _result = (expr); \ + asm ("" : "+r" (_result)); \ + _result; \ + }) +# endif + /* Some information which is not meant for the public and therefore not in . */ # include diff --git a/lib/libc/glibc/include/libc-symbols.h b/lib/libc/glibc/include/libc-symbols.h index b11460131d..7f2c8938b6 100644 --- a/lib/libc/glibc/include/libc-symbols.h +++ b/lib/libc/glibc/include/libc-symbols.h @@ -155,7 +155,7 @@ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \ __attribute_copy__ (name); -/* Zig patch. weak_hidden_alias was removed from glibc v2.36 (v2.37?), Zig +/* zig patch: weak_hidden_alias was removed from glibc v2.36 (v2.37?), Zig needs it for the v2.32 and earlier {f,l,}stat wrappers, so only include in this header for 2.32 and earlier. */ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 32) || __GLIBC__ < 2 @@ -220,7 +220,7 @@ #define __make_section_unallocated(section_string) \ asm (".section " section_string "\n\t.previous"); -/* Tacking on "\n\t#" to the section name makes gcc put it's bogus +/* Tacking on "\n\t#" to the section name makes gcc put its bogus section attributes on what looks like a comment to the assembler. */ #ifdef HAVE_SECTION_QUOTES # define __sec_comment "\"\n\t#\"" @@ -280,7 +280,7 @@ for linking") /* - + */ #ifdef HAVE_GNU_RETAIN @@ -807,7 +807,7 @@ for linking") #define libm_ifunc_init() #define libm_ifunc(name, expr) \ __ifunc (name, name, expr, void, libm_ifunc_init) - + /* These macros facilitate sharing source files with gnulib. They are here instead of sys/cdefs.h because they should not be diff --git a/lib/libc/glibc/include/stdlib.h b/lib/libc/glibc/include/stdlib.h index 57f4ab8545..b7147ba590 100644 --- a/lib/libc/glibc/include/stdlib.h +++ b/lib/libc/glibc/include/stdlib.h @@ -368,6 +368,21 @@ struct abort_msg_s extern struct abort_msg_s *__abort_msg; libc_hidden_proto (__abort_msg) +enum readonly_error_type +{ + readonly_noerror, + readonly_area_writable, + readonly_procfs_inaccessible, + readonly_procfs_open_fail, +}; + +extern enum readonly_error_type __readonly_area (const void *ptr, + size_t size) + attribute_hidden; +extern enum readonly_error_type __readonly_area_fallback (const void *ptr, + size_t size) + attribute_hidden; + # if IS_IN (rtld) extern __typeof (unsetenv) unsetenv attribute_hidden; extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; diff --git a/lib/libc/glibc/io/fcntl.h b/lib/libc/glibc/io/fcntl.h index 2e07f8fc4b..d99dc68a88 100644 --- a/lib/libc/glibc/io/fcntl.h +++ b/lib/libc/glibc/io/fcntl.h @@ -168,7 +168,7 @@ typedef __pid_t pid_t; #endif -/* fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards +/* zig patch: fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards * re-defines it to fcntl64 (via #define) if _FILE_OFFSET_BITS == 64. */ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2 /* Do the file control operation described by CMD on FD. @@ -288,16 +288,17 @@ extern int creat64 (const char *__file, mode_t __mode) __nonnull ((1)); # define F_TEST 3 /* Test a region for other processes locks. */ # ifndef __USE_FILE_OFFSET64 -extern int lockf (int __fd, int __cmd, off_t __len); +extern int lockf (int __fd, int __cmd, off_t __len) __wur; # else # ifdef __REDIRECT -extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64); +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), + lockf64) __wur; # else # define lockf lockf64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int lockf64 (int __fd, int __cmd, off64_t __len); +extern int lockf64 (int __fd, int __cmd, off64_t __len) __wur; # endif #endif diff --git a/lib/libc/glibc/posix/bits/types.h b/lib/libc/glibc/posix/bits/types.h index 97d2b1be35..a6638467c8 100644 --- a/lib/libc/glibc/posix/bits/types.h +++ b/lib/libc/glibc/posix/bits/types.h @@ -217,7 +217,7 @@ typedef int __sig_atomic_t; /* Seconds since the Epoch, visible to user code when time_t is too narrow only for consistency with the old way of widening too-narrow types. User code should never use __time64_t. */ -/* Zig patch: Don't check __LIBC here because it breaks fstatat.c on x86. */ +/* zig patch: Don't check __LIBC here because it breaks fstatat.c on x86. */ #if __TIMESIZE == 64 # define __time64_t __time_t #elif __TIMESIZE != 64 diff --git a/lib/libc/glibc/stdlib/stdlib.h b/lib/libc/glibc/stdlib/stdlib.h index 975f5aeb0b..cd4503c761 100644 --- a/lib/libc/glibc/stdlib/stdlib.h +++ b/lib/libc/glibc/stdlib/stdlib.h @@ -985,6 +985,12 @@ __extension__ extern long long int llabs (long long int __x) __THROW __attribute__ ((__const__)) __wur; #endif +#if __GLIBC_USE (ISOC2Y) +extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur; +extern unsigned long int ulabs (long int __x) __THROW __attribute__ ((__const__)) __wur; +__extension__ extern unsigned long long int ullabs (long long int __x) + __THROW __attribute__ ((__const__)) __wur; +#endif /* Return the `div_t', `ldiv_t' or `lldiv_t' representation of the value of NUMER over DENOM. */ diff --git a/lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h b/lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h index 7f11e82ff5..c282560335 100644 --- a/lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h +++ b/lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h @@ -21,23 +21,13 @@ #include -#ifdef __ILP32__ -# define __SIZEOF_PTHREAD_ATTR_T 32 -# define __SIZEOF_PTHREAD_MUTEX_T 32 -# define __SIZEOF_PTHREAD_MUTEXATTR_T 4 -# define __SIZEOF_PTHREAD_CONDATTR_T 4 -# define __SIZEOF_PTHREAD_RWLOCK_T 48 -# define __SIZEOF_PTHREAD_BARRIER_T 20 -# define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -#else -# define __SIZEOF_PTHREAD_ATTR_T 64 -# define __SIZEOF_PTHREAD_MUTEX_T 48 -# define __SIZEOF_PTHREAD_MUTEXATTR_T 8 -# define __SIZEOF_PTHREAD_CONDATTR_T 8 -# define __SIZEOF_PTHREAD_RWLOCK_T 56 -# define __SIZEOF_PTHREAD_BARRIER_T 32 -# define __SIZEOF_PTHREAD_BARRIERATTR_T 8 -#endif +#define __SIZEOF_PTHREAD_ATTR_T 64 +#define __SIZEOF_PTHREAD_MUTEX_T 48 +#define __SIZEOF_PTHREAD_MUTEXATTR_T 8 +#define __SIZEOF_PTHREAD_CONDATTR_T 8 +#define __SIZEOF_PTHREAD_RWLOCK_T 56 +#define __SIZEOF_PTHREAD_BARRIER_T 32 +#define __SIZEOF_PTHREAD_BARRIERATTR_T 8 #define __SIZEOF_PTHREAD_COND_T 48 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 diff --git a/lib/libc/glibc/sysdeps/aarch64/start-2.33.S b/lib/libc/glibc/sysdeps/aarch64/start-2.33.S index d96cf57e2d..6d8d49ce23 100644 --- a/lib/libc/glibc/sysdeps/aarch64/start-2.33.S +++ b/lib/libc/glibc/sysdeps/aarch64/start-2.33.S @@ -54,8 +54,8 @@ _start: mov x5, x0 /* Load argc and a pointer to argv */ - ldr PTR_REG (1), [sp, #0] - add x2, sp, #PTR_SIZE + ldr x1, [sp, #0] + add x2, sp, 8 /* Setup stack limit in argument register */ mov x6, sp @@ -63,13 +63,13 @@ _start: #ifdef PIC # ifdef SHARED adrp x0, :got:main - ldr PTR_REG (0), [x0, #:got_lo12:main] + ldr x0, [x0, #:got_lo12:main] adrp x3, :got:__libc_csu_init - ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init] + ldr x3, [x3, #:got_lo12:__libc_csu_init] adrp x4, :got:__libc_csu_fini - ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini] + ldr x4, [x4, #:got_lo12:__libc_csu_fini] # else adrp x0, __wrap_main add x0, x0, :lo12:__wrap_main @@ -80,9 +80,18 @@ _start: # endif #else /* Set up the other arguments in registers */ - MOVL (0, main) - MOVL (3, __libc_csu_init) - MOVL (4, __libc_csu_fini) + movz x0, :abs_g3:main + movk x0, :abs_g2_nc:main + movk x0, :abs_g1_nc:main + movk x0, :abs_g0_nc:main + movz x3, :abs_g3:__libc_csu_init + movk x3, :abs_g2_nc:__libc_csu_init + movk x3, :abs_g1_nc:__libc_csu_init + movk x3, :abs_g0_nc:__libc_csu_init + movz x4, :abs_g3:__libc_csu_fini + movk x4, :abs_g2_nc:__libc_csu_fini + movk x4, :abs_g1_nc:__libc_csu_fini + movk x4, :abs_g0_nc:__libc_csu_fini #endif /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, diff --git a/lib/libc/glibc/sysdeps/aarch64/start.S b/lib/libc/glibc/sysdeps/aarch64/start.S index ef6b5ad686..694c338c8b 100644 --- a/lib/libc/glibc/sysdeps/aarch64/start.S +++ b/lib/libc/glibc/sysdeps/aarch64/start.S @@ -70,8 +70,8 @@ ENTRY(_start) mov x5, x0 /* Load argc and a pointer to argv */ - ldr PTR_REG (1), [sp, #0] - add x2, sp, #PTR_SIZE + ldr x1, [sp, #0] + add x2, sp, 8 /* Setup stack limit in argument register */ mov x6, sp @@ -79,14 +79,16 @@ ENTRY(_start) #ifdef PIC # ifdef SHARED adrp x0, :got:main - ldr PTR_REG (0), [x0, #:got_lo12:main] + ldr x0, [x0, #:got_lo12:main] # else adrp x0, __wrap_main add x0, x0, :lo12:__wrap_main # endif #else - /* Set up the other arguments in registers */ - MOVL (0, main) + movz x0, :abs_g3:main + movk x0, :abs_g2_nc:main + movk x0, :abs_g1_nc:main + movk x0, :abs_g0_nc:main #endif mov x3, #0 /* Used to be init. */ mov x4, #0 /* Used to be fini. */ @@ -106,7 +108,7 @@ ENTRY(_start) because crt1.o and rcrt1.o share code and the later must avoid the use of GOT relocations before __libc_start_main is called. */ __wrap_main: - BTI_C + bti c b main #endif END(_start) diff --git a/lib/libc/glibc/sysdeps/aarch64/sysdep.h b/lib/libc/glibc/sysdeps/aarch64/sysdep.h index 036eb12527..f5e28cb242 100644 --- a/lib/libc/glibc/sysdeps/aarch64/sysdep.h +++ b/lib/libc/glibc/sysdeps/aarch64/sysdep.h @@ -21,59 +21,15 @@ #include -#ifdef __LP64__ -# define AARCH64_R(NAME) R_AARCH64_ ## NAME -# define PTR_REG(n) x##n -# define PTR_LOG_SIZE 3 -# define PTR_ARG(n) -# define SIZE_ARG(n) -#else -# define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME -# define PTR_REG(n) w##n -# define PTR_LOG_SIZE 2 -# define PTR_ARG(n) mov w##n, w##n -# define SIZE_ARG(n) mov w##n, w##n -#endif - -#define PTR_SIZE (1< +/* This macro is defined in Mach system headers, but string functions use it + with different definitions depending on whether being compiled for + wide-characters or not. */ +#undef P2ALIGN + /* The Mach definitions assume underscores should be prepended to symbol names. Redefine them to do so only when appropriate. */ #undef EXT diff --git a/lib/libc/glibc/sysdeps/nptl/pthread.h b/lib/libc/glibc/sysdeps/nptl/pthread.h index 9ad36cabe9..92957a620d 100644 --- a/lib/libc/glibc/sysdeps/nptl/pthread.h +++ b/lib/libc/glibc/sysdeps/nptl/pthread.h @@ -1317,6 +1317,11 @@ extern int pthread_getcpuclockid (pthread_t __thread_id, __THROW __nonnull ((2)); #endif +#ifdef __USE_GNU +/* Return the Linux TID for THREAD_ID. Returns -1 on failure. */ +extern pid_t pthread_gettid_np (pthread_t __thread_id); +#endif + /* Install handlers to be called when a new process is created with FORK. The PREPARE handler is called in the parent process just before performing diff --git a/lib/libc/glibc/sysdeps/sparc/sparc32/start.S b/lib/libc/glibc/sysdeps/sparc/sparc32/start.S index 694b020ce0..8393760da6 100644 --- a/lib/libc/glibc/sysdeps/sparc/sparc32/start.S +++ b/lib/libc/glibc/sysdeps/sparc/sparc32/start.S @@ -35,6 +35,7 @@ #include +#define FRAME_SIZE 104 .section ".text" .align 4 @@ -48,12 +49,12 @@ _start: /* Terminate the stack frame, and reserve space for functions to drop their arguments. */ mov %g0, %fp - sub %sp, 6*4, %sp + sub %sp, FRAME_SIZE, %sp /* Extract the arguments and environment as encoded on the stack. The argument info starts after one register window (16 words) past the SP. */ - ld [%sp+22*4], %o1 - add %sp, 23*4, %o2 + ld [%sp+168], %o1 + add %sp, 172, %o2 /* Load the addresses of the user entry points. */ #ifndef PIC @@ -73,6 +74,10 @@ _start: be NULL. */ mov %g1, %o5 + /* Provide the highest stack address to update the __libc_stack_end (used + to enable executable stacks if required). */ + st %sp, [%sp+23*4] + /* Let libc do the rest of the initialization, and call main. */ call __libc_start_main nop diff --git a/lib/libc/glibc/sysdeps/sparc/sparc64/start.S b/lib/libc/glibc/sysdeps/sparc/sparc64/start.S index c9c25c2e47..08e1e77210 100644 --- a/lib/libc/glibc/sysdeps/sparc/sparc64/start.S +++ b/lib/libc/glibc/sysdeps/sparc/sparc64/start.S @@ -74,6 +74,10 @@ _start: be NULL. */ mov %g1, %o5 + /* Provide the highest stack address to update the __libc_stack_end (used + to enable executable stacks if required). */ + stx %sp, [%sp+STACK_BIAS+22*8] + /* Let libc do the rest of the initialization, and call main. */ call __libc_start_main nop diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h index b813805931..f0e8d64eef 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -152,13 +152,8 @@ #else /* not __ASSEMBLER__ */ -# ifdef __LP64__ -# define VDSO_NAME "LINUX_2.6.39" -# define VDSO_HASH 123718537 -# else -# define VDSO_NAME "LINUX_4.9" -# define VDSO_HASH 61765625 -# endif +# define VDSO_NAME "LINUX_2.6.39" +# define VDSO_HASH 123718537 /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres" diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h index 86b2d3ce51..a49a9159cf 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h @@ -54,6 +54,10 @@ configurations). */ #define __ASSUME_SET_ROBUST_LIST 1 +/* The termios2 interface was introduced across all architectures except + Alpha in kernel 2.6.22. */ +#define __ASSUME_TERMIOS2 1 + /* Support for various CLOEXEC and NONBLOCK flags was added in 2.6.27. */ #define __ASSUME_IN_NONBLOCK 1 diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h index ee015dfeb6..05e0e0523d 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -145,11 +145,12 @@ # define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres" # define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define HAVE_GETRANDOM_VSYSCALL "__vdso_getrandom" # else # define VDSO_NAME "LINUX_5.4" # define VDSO_HASH 61765876 -/* RV32 does not support the gettime VDSO syscalls. */ +/* RV32 does not support the gettime and getrandom VDSO syscalls. */ # endif # define HAVE_CLONE3_WRAPPER 1 diff --git a/lib/libc/glibc/sysdeps/x86/sysdep.h b/lib/libc/glibc/sysdeps/x86/sysdep.h index 541393f1dc..b8e963b654 100644 --- a/lib/libc/glibc/sysdeps/x86/sysdep.h +++ b/lib/libc/glibc/sysdeps/x86/sysdep.h @@ -102,6 +102,9 @@ | (1 << X86_XSTATE_ZMM_ID) \ | (1 << X86_XSTATE_APX_F_ID)) +/* The maximum supported xstate ID. */ +# define X86_XSTATE_MAX_ID X86_XSTATE_APX_F_ID + /* AMX state mask. */ # define AMX_STATE_SAVE_MASK \ ((1 << X86_XSTATE_TILECFG_ID) | (1 << X86_XSTATE_TILEDATA_ID)) @@ -123,6 +126,9 @@ | (1 << X86_XSTATE_K_ID) \ | (1 << X86_XSTATE_ZMM_H_ID)) +/* The maximum supported xstate ID. */ +# define X86_XSTATE_MAX_ID X86_XSTATE_ZMM_H_ID + /* States to be included in xsave_state_size. */ # define FULL_STATE_SAVE_MASK STATE_SAVE_MASK #endif @@ -177,6 +183,29 @@ #define atom_text_section .section ".text.atom", "ax" +#ifndef DL_STACK_ALIGNMENT +/* Due to GCC bug: + + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066 + + __tls_get_addr may be called with 8-byte/4-byte stack alignment. + Although this bug has been fixed in GCC 4.9.4, 5.3 and 6, we can't + assume that stack will be always aligned at 16 bytes. */ +# ifdef __x86_64__ +# define DL_STACK_ALIGNMENT 8 +# define MINIMUM_ALIGNMENT 16 +# else +# define DL_STACK_ALIGNMENT 4 +# endif +#endif + +/* True if _dl_runtime_resolve/_dl_tlsdesc_dynamic should align stack for + STATE_SAVE or align stack to MINIMUM_ALIGNMENT bytes before calling + _dl_fixup/__tls_get_addr. */ +#define DL_RUNTIME_RESOLVE_REALIGN_STACK \ + (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \ + || MINIMUM_ALIGNMENT > DL_STACK_ALIGNMENT) + #endif /* __ASSEMBLER__ */ #endif /* _X86_SYSDEP_H */