glibc: update crt0 code to 2.42

This commit is contained in:
Alex Rønne Petersen
2025-07-31 22:08:36 +02:00
parent 1804251dfb
commit 675b1a15a1
21 changed files with 165 additions and 193 deletions

View File

@@ -837,12 +837,15 @@ typedef struct
#define NT_ARM_ZT 0x40d /* ARM SME ZT registers. */ #define NT_ARM_ZT 0x40d /* ARM SME ZT registers. */
#define NT_ARM_FPMR 0x40e /* ARM floating point mode register. */ #define NT_ARM_FPMR 0x40e /* ARM floating point mode register. */
#define NT_ARM_POE 0x40f /* ARM POE registers. */ #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_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */ #define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */ #define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */
#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */ #define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */
#define NT_RISCV_VECTOR 0x901 /* RISC-V vector 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_CPUCFG 0xa00 /* LoongArch CPU config registers. */
#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and #define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and
status registers. */ status registers. */
@@ -2906,19 +2909,6 @@ enum
#define R_AARCH64_NONE 0 /* No relocation. */ #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_ABS64 257 /* Direct 64 bit. */
#define R_AARCH64_ABS32 258 /* Direct 32 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */
#define R_AARCH64_ABS16 259 /* Direct 16-bit. */ #define R_AARCH64_ABS16 259 /* Direct 16-bit. */
@@ -4091,6 +4081,7 @@ enum
#define R_RISCV_TLS_DTPREL64 9 #define R_RISCV_TLS_DTPREL64 9
#define R_RISCV_TLS_TPREL32 10 #define R_RISCV_TLS_TPREL32 10
#define R_RISCV_TLS_TPREL64 11 #define R_RISCV_TLS_TPREL64 11
#define R_RISCV_TLSDESC 12
#define R_RISCV_BRANCH 16 #define R_RISCV_BRANCH 16
#define R_RISCV_JAL 17 #define R_RISCV_JAL 17
#define R_RISCV_CALL 18 #define R_RISCV_CALL 18
@@ -4116,16 +4107,10 @@ enum
#define R_RISCV_SUB16 38 #define R_RISCV_SUB16 38
#define R_RISCV_SUB32 39 #define R_RISCV_SUB32 39
#define R_RISCV_SUB64 40 #define R_RISCV_SUB64 40
#define R_RISCV_GNU_VTINHERIT 41 #define R_RISCV_GOT32_PCREL 41
#define R_RISCV_GNU_VTENTRY 42
#define R_RISCV_ALIGN 43 #define R_RISCV_ALIGN 43
#define R_RISCV_RVC_BRANCH 44 #define R_RISCV_RVC_BRANCH 44
#define R_RISCV_RVC_JUMP 45 #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_RELAX 51
#define R_RISCV_SUB6 52 #define R_RISCV_SUB6 52
#define R_RISCV_SET6 53 #define R_RISCV_SET6 53
@@ -4137,8 +4122,12 @@ enum
#define R_RISCV_PLT32 59 #define R_RISCV_PLT32 59
#define R_RISCV_SET_ULEB128 60 #define R_RISCV_SET_ULEB128 60
#define R_RISCV_SUB_ULEB128 61 #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. */ /* RISC-V specific values for the st_other field. */
#define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling #define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling
@@ -4147,7 +4136,7 @@ enum
/* RISC-V specific values for the sh_type field. */ /* RISC-V specific values for the sh_type field. */
#define SHT_RISCV_ATTRIBUTES (SHT_LOPROC + 3) #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) #define PT_RISCV_ATTRIBUTES (PT_LOPROC + 3)
/* RISC-V specific values for the d_tag field. */ /* RISC-V specific values for the d_tag field. */

View File

@@ -15,6 +15,19 @@
# define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \ # define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \
ALIGN_UP (ELF_NOTE_DESC_OFFSET ((namesz), (align)) + (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 /* Some information which is not meant for the public and therefore not
in <elf.h>. */ in <elf.h>. */
# include <dl-dtprocnum.h> # include <dl-dtprocnum.h>

View File

@@ -155,7 +155,7 @@
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
__attribute_copy__ (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 needs it for the v2.32 and earlier {f,l,}stat wrappers, so only include
in this header for 2.32 and earlier. */ in this header for 2.32 and earlier. */
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 32) || __GLIBC__ < 2 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 32) || __GLIBC__ < 2
@@ -220,7 +220,7 @@
#define __make_section_unallocated(section_string) \ #define __make_section_unallocated(section_string) \
asm (".section " section_string "\n\t.previous"); 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. */ section attributes on what looks like a comment to the assembler. */
#ifdef HAVE_SECTION_QUOTES #ifdef HAVE_SECTION_QUOTES
# define __sec_comment "\"\n\t#\"" # define __sec_comment "\"\n\t#\""
@@ -280,7 +280,7 @@ for linking")
/* /*
*/ */
#ifdef HAVE_GNU_RETAIN #ifdef HAVE_GNU_RETAIN
@@ -807,7 +807,7 @@ for linking")
#define libm_ifunc_init() #define libm_ifunc_init()
#define libm_ifunc(name, expr) \ #define libm_ifunc(name, expr) \
__ifunc (name, name, expr, void, libm_ifunc_init) __ifunc (name, name, expr, void, libm_ifunc_init)
/* These macros facilitate sharing source files with gnulib. /* These macros facilitate sharing source files with gnulib.
They are here instead of sys/cdefs.h because they should not be They are here instead of sys/cdefs.h because they should not be

View File

@@ -368,6 +368,21 @@ struct abort_msg_s
extern struct abort_msg_s *__abort_msg; extern struct abort_msg_s *__abort_msg;
libc_hidden_proto (__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) # if IS_IN (rtld)
extern __typeof (unsetenv) unsetenv attribute_hidden; extern __typeof (unsetenv) unsetenv attribute_hidden;
extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;

View File

@@ -168,7 +168,7 @@ typedef __pid_t pid_t;
#endif #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. */ * re-defines it to fcntl64 (via #define) if _FILE_OFFSET_BITS == 64. */
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
/* Do the file control operation described by CMD on FD. /* 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. */ # define F_TEST 3 /* Test a region for other processes locks. */
# ifndef __USE_FILE_OFFSET64 # 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 # else
# ifdef __REDIRECT # 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 # else
# define lockf lockf64 # define lockf lockf64
# endif # endif
# endif # endif
# ifdef __USE_LARGEFILE64 # 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
#endif #endif

View File

@@ -217,7 +217,7 @@ typedef int __sig_atomic_t;
/* Seconds since the Epoch, visible to user code when time_t is too /* 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 narrow only for consistency with the old way of widening too-narrow
types. User code should never use __time64_t. */ 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 #if __TIMESIZE == 64
# define __time64_t __time_t # define __time64_t __time_t
#elif __TIMESIZE != 64 #elif __TIMESIZE != 64

View File

@@ -985,6 +985,12 @@ __extension__ extern long long int llabs (long long int __x)
__THROW __attribute__ ((__const__)) __wur; __THROW __attribute__ ((__const__)) __wur;
#endif #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 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
of the value of NUMER over DENOM. */ of the value of NUMER over DENOM. */

View File

@@ -21,23 +21,13 @@
#include <bits/endian.h> #include <bits/endian.h>
#ifdef __ILP32__ #define __SIZEOF_PTHREAD_ATTR_T 64
# define __SIZEOF_PTHREAD_ATTR_T 32 #define __SIZEOF_PTHREAD_MUTEX_T 48
# define __SIZEOF_PTHREAD_MUTEX_T 32 #define __SIZEOF_PTHREAD_MUTEXATTR_T 8
# define __SIZEOF_PTHREAD_MUTEXATTR_T 4 #define __SIZEOF_PTHREAD_CONDATTR_T 8
# define __SIZEOF_PTHREAD_CONDATTR_T 4 #define __SIZEOF_PTHREAD_RWLOCK_T 56
# define __SIZEOF_PTHREAD_RWLOCK_T 48 #define __SIZEOF_PTHREAD_BARRIER_T 32
# define __SIZEOF_PTHREAD_BARRIER_T 20 #define __SIZEOF_PTHREAD_BARRIERATTR_T 8
# 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_COND_T 48 #define __SIZEOF_PTHREAD_COND_T 48
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8

View File

@@ -54,8 +54,8 @@ _start:
mov x5, x0 mov x5, x0
/* Load argc and a pointer to argv */ /* Load argc and a pointer to argv */
ldr PTR_REG (1), [sp, #0] ldr x1, [sp, #0]
add x2, sp, #PTR_SIZE add x2, sp, 8
/* Setup stack limit in argument register */ /* Setup stack limit in argument register */
mov x6, sp mov x6, sp
@@ -63,13 +63,13 @@ _start:
#ifdef PIC #ifdef PIC
# ifdef SHARED # ifdef SHARED
adrp x0, :got:main adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main] ldr x0, [x0, #:got_lo12:main]
adrp x3, :got:__libc_csu_init 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 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 # else
adrp x0, __wrap_main adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main add x0, x0, :lo12:__wrap_main
@@ -80,9 +80,18 @@ _start:
# endif # endif
#else #else
/* Set up the other arguments in registers */ /* Set up the other arguments in registers */
MOVL (0, main) movz x0, :abs_g3:main
MOVL (3, __libc_csu_init) movk x0, :abs_g2_nc:main
MOVL (4, __libc_csu_fini) 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 #endif
/* __libc_start_main (main, argc, argv, init, fini, rtld_fini, /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,

View File

@@ -70,8 +70,8 @@ ENTRY(_start)
mov x5, x0 mov x5, x0
/* Load argc and a pointer to argv */ /* Load argc and a pointer to argv */
ldr PTR_REG (1), [sp, #0] ldr x1, [sp, #0]
add x2, sp, #PTR_SIZE add x2, sp, 8
/* Setup stack limit in argument register */ /* Setup stack limit in argument register */
mov x6, sp mov x6, sp
@@ -79,14 +79,16 @@ ENTRY(_start)
#ifdef PIC #ifdef PIC
# ifdef SHARED # ifdef SHARED
adrp x0, :got:main adrp x0, :got:main
ldr PTR_REG (0), [x0, #:got_lo12:main] ldr x0, [x0, #:got_lo12:main]
# else # else
adrp x0, __wrap_main adrp x0, __wrap_main
add x0, x0, :lo12:__wrap_main add x0, x0, :lo12:__wrap_main
# endif # endif
#else #else
/* Set up the other arguments in registers */ movz x0, :abs_g3:main
MOVL (0, main) movk x0, :abs_g2_nc:main
movk x0, :abs_g1_nc:main
movk x0, :abs_g0_nc:main
#endif #endif
mov x3, #0 /* Used to be init. */ mov x3, #0 /* Used to be init. */
mov x4, #0 /* Used to be fini. */ 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 because crt1.o and rcrt1.o share code and the later must avoid the
use of GOT relocations before __libc_start_main is called. */ use of GOT relocations before __libc_start_main is called. */
__wrap_main: __wrap_main:
BTI_C bti c
b main b main
#endif #endif
END(_start) END(_start)

View File

@@ -21,59 +21,15 @@
#include <sysdeps/generic/sysdep.h> #include <sysdeps/generic/sysdep.h>
#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<<PTR_LOG_SIZE)
#ifndef __ASSEMBLER__
/* Strip pointer authentication code from pointer p. */
static inline void *
strip_pac (void *p)
{
register void *ra asm ("x30") = (p);
asm ("hint 7 // xpaclri" : "+r"(ra));
return ra;
}
/* This is needed when glibc is built with -mbranch-protection=pac-ret
with a gcc that is affected by PR target/94891. */
# if HAVE_AARCH64_PAC_RET
# undef RETURN_ADDRESS
# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n))
# endif
#endif
#ifdef __ASSEMBLER__ #ifdef __ASSEMBLER__
/* CFI directive for return address. */
#define cfi_negate_ra_state .cfi_negate_ra_state
/* Syntactic details of assembler. */ /* Syntactic details of assembler. */
#define ASM_SIZE_DIRECTIVE(name) .size name,.-name #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
/* Branch Target Identitication support. */
#if HAVE_AARCH64_BTI
# define BTI_C hint 34
# define BTI_J hint 36
#else
# define BTI_C nop
# define BTI_J nop
#endif
/* Return address signing support (pac-ret). */
#define PACIASP hint 25
#define AUTIASP hint 29
/* Guarded Control Stack support. */ /* Guarded Control Stack support. */
#define CHKFEAT_X16 hint 40 #define CHKFEAT_X16 hint 40
#define MRS_GCSPR(x) mrs x, s3_3_c2_c5_1 #define MRS_GCSPR(x) mrs x, s3_3_c2_c5_1
@@ -103,11 +59,7 @@ strip_pac (void *p)
/* Add GNU property note with the supported features to all asm code /* Add GNU property note with the supported features to all asm code
where sysdep.h is included. */ where sysdep.h is included. */
#if HAVE_AARCH64_BTI && HAVE_AARCH64_PAC_RET
GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS) GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS)
#elif HAVE_AARCH64_BTI
GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
#endif
/* Define an entry point visible from C. */ /* Define an entry point visible from C. */
#define ENTRY(name) \ #define ENTRY(name) \
@@ -116,7 +68,7 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
.p2align 6; \ .p2align 6; \
C_LABEL(name) \ C_LABEL(name) \
cfi_startproc; \ cfi_startproc; \
BTI_C; \ bti c; \
CALL_MCOUNT CALL_MCOUNT
/* Define an entry point visible from C. */ /* Define an entry point visible from C. */
@@ -126,7 +78,7 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
.p2align align; \ .p2align align; \
C_LABEL(name) \ C_LABEL(name) \
cfi_startproc; \ cfi_startproc; \
BTI_C; \ bti c; \
CALL_MCOUNT CALL_MCOUNT
/* Define an entry point visible from C with a specified alignment and /* Define an entry point visible from C with a specified alignment and
@@ -143,7 +95,7 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
.endr; \ .endr; \
C_LABEL(name) \ C_LABEL(name) \
cfi_startproc; \ cfi_startproc; \
BTI_C; \ bti c; \
CALL_MCOUNT CALL_MCOUNT
#undef END #undef END
@@ -195,33 +147,6 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
# define L(name) .L##name # define L(name) .L##name
#endif #endif
/* Load or store to/from a pc-relative EXPR into/from R, using T.
Note R and T are register numbers and not register names. */
#define LDST_PCREL(OP, R, T, EXPR) \
adrp x##T, EXPR; \
OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
/* Load or store to/from a got-relative EXPR into/from R, using T.
Note R and T are register numbers and not register names. */
#define LDST_GLOBAL(OP, R, T, EXPR) \
adrp x##T, :got:EXPR; \
ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
OP PTR_REG (R), [x##T];
/* Load an immediate into R.
Note R is a register number and not a register name. */
#ifdef __LP64__
# define MOVL(R, NAME) \
movz PTR_REG (R), #:abs_g3:NAME; \
movk PTR_REG (R), #:abs_g2_nc:NAME; \
movk PTR_REG (R), #:abs_g1_nc:NAME; \
movk PTR_REG (R), #:abs_g0_nc:NAME;
#else
# define MOVL(R, NAME) \
movz PTR_REG (R), #:abs_g1:NAME; \
movk PTR_REG (R), #:abs_g0_nc:NAME;
#endif
/* Since C identifiers are not normally prefixed with an underscore /* Since C identifiers are not normally prefixed with an underscore
on this system, the asm identifier `syscall_error' intrudes on the on this system, the asm identifier `syscall_error' intrudes on the
C name space. Make sure we use an innocuous name. */ C name space. Make sure we use an innocuous name. */

View File

@@ -45,6 +45,7 @@
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off # define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
# define cfi_offset(reg, off) .cfi_offset reg, off # define cfi_offset(reg, off) .cfi_offset reg, off
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off # define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
# define cfi_val_offset(reg, off) .cfi_val_offset reg, off
# define cfi_register(r1, r2) .cfi_register r1, r2 # define cfi_register(r1, r2) .cfi_register r1, r2
# define cfi_return_column(reg) .cfi_return_column reg # define cfi_return_column(reg) .cfi_return_column reg
# define cfi_restore(reg) .cfi_restore reg # define cfi_restore(reg) .cfi_restore reg
@@ -74,6 +75,8 @@
".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off) ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
# define CFI_REL_OFFSET(reg, off) \ # define CFI_REL_OFFSET(reg, off) \
".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off) ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
# define CFI_VAL_OFFSET(reg, off) \
".cfi_val_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
# define CFI_REGISTER(r1, r2) \ # define CFI_REGISTER(r1, r2) \
".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2) ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
# define CFI_RETURN_COLUMN(reg) \ # define CFI_RETURN_COLUMN(reg) \

View File

@@ -75,7 +75,6 @@
extern int __pthread_mutex_init (pthread_mutex_t *__mutex, extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
const pthread_mutexattr_t *__mutex_attr); const pthread_mutexattr_t *__mutex_attr);
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
libc_hidden_proto (__pthread_mutex_destroy) libc_hidden_proto (__pthread_mutex_destroy)
@@ -91,75 +90,47 @@ libc_hidden_proto (__pthread_mutexattr_init)
extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr); extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
libc_hidden_proto (__pthread_mutexattr_destroy) libc_hidden_proto (__pthread_mutexattr_destroy)
extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
int __kind);
extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock, extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
const pthread_rwlockattr_t *__attr); const pthread_rwlockattr_t *__attr);
libc_hidden_proto (__pthread_rwlock_init)
extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_destroy)
extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_rdlock)
extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_tryrdlock)
extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_wrlock)
extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_trywrlock)
extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
libc_hidden_proto (__pthread_rwlock_unlock)
extern int __pthread_once (pthread_once_t *__once_control, extern int __pthread_once (pthread_once_t *__once_control,
void (*__init_routine) (void)); void (*__init_routine) (void));
libc_hidden_proto (__pthread_once);
extern int __pthread_atfork (void (*__prepare) (void), extern int __pthread_atfork (void (*__prepare) (void),
void (*__parent) (void), void (*__parent) (void),
void (*__child) (void)); void (*__child) (void));
extern int __pthread_setcancelstate (int state, int *oldstate);
libc_hidden_proto (__pthread_setcancelstate)
/* Make the pthread functions weak so that we can elide them from /* Make the pthread functions weak so that we can elide them from
single-threaded processes. */ single-threaded processes. */
#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread) #if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
# ifdef weak_extern # ifdef weak_extern
weak_extern (__pthread_mutex_init)
weak_extern (__pthread_mutex_destroy)
weak_extern (__pthread_mutex_lock)
weak_extern (__pthread_mutex_trylock)
weak_extern (__pthread_mutex_unlock)
weak_extern (__pthread_mutexattr_settype)
weak_extern (__pthread_rwlock_init)
weak_extern (__pthread_rwlock_destroy)
weak_extern (__pthread_rwlock_rdlock)
weak_extern (__pthread_rwlock_tryrdlock)
weak_extern (__pthread_rwlock_wrlock)
weak_extern (__pthread_rwlock_trywrlock)
weak_extern (__pthread_rwlock_unlock)
weak_extern (__pthread_key_create)
weak_extern (__pthread_setspecific)
weak_extern (__pthread_getspecific)
weak_extern (__pthread_once)
weak_extern (__pthread_initialize) weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork) weak_extern (__pthread_atfork)
weak_extern (__pthread_setcancelstate)
# else # else
# pragma weak __pthread_mutex_init
# pragma weak __pthread_mutex_destroy
# pragma weak __pthread_mutex_lock
# pragma weak __pthread_mutex_trylock
# pragma weak __pthread_mutex_unlock
# pragma weak __pthread_mutexattr_settype
# pragma weak __pthread_rwlock_destroy
# pragma weak __pthread_rwlock_rdlock
# pragma weak __pthread_rwlock_tryrdlock
# pragma weak __pthread_rwlock_wrlock
# pragma weak __pthread_rwlock_trywrlock
# pragma weak __pthread_rwlock_unlock
# pragma weak __pthread_key_create
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_once
# pragma weak __pthread_initialize # pragma weak __pthread_initialize
# pragma weak __pthread_atfork # pragma weak __pthread_atfork
# pragma weak __pthread_setcancelstate
# endif # endif
#endif #endif

View File

@@ -20,6 +20,11 @@
/* Get the Mach definitions of ENTRY and kernel_trap. */ /* Get the Mach definitions of ENTRY and kernel_trap. */
#include <mach/machine/syscall_sw.h> #include <mach/machine/syscall_sw.h>
/* 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 /* The Mach definitions assume underscores should be prepended to
symbol names. Redefine them to do so only when appropriate. */ symbol names. Redefine them to do so only when appropriate. */
#undef EXT #undef EXT

View File

@@ -1317,6 +1317,11 @@ extern int pthread_getcpuclockid (pthread_t __thread_id,
__THROW __nonnull ((2)); __THROW __nonnull ((2));
#endif #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. /* 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 The PREPARE handler is called in the parent process just before performing

View File

@@ -35,6 +35,7 @@
#include <sysdep.h> #include <sysdep.h>
#define FRAME_SIZE 104
.section ".text" .section ".text"
.align 4 .align 4
@@ -48,12 +49,12 @@ _start:
/* Terminate the stack frame, and reserve space for functions to /* Terminate the stack frame, and reserve space for functions to
drop their arguments. */ drop their arguments. */
mov %g0, %fp mov %g0, %fp
sub %sp, 6*4, %sp sub %sp, FRAME_SIZE, %sp
/* Extract the arguments and environment as encoded on the stack. The /* Extract the arguments and environment as encoded on the stack. The
argument info starts after one register window (16 words) past the SP. */ argument info starts after one register window (16 words) past the SP. */
ld [%sp+22*4], %o1 ld [%sp+168], %o1
add %sp, 23*4, %o2 add %sp, 172, %o2
/* Load the addresses of the user entry points. */ /* Load the addresses of the user entry points. */
#ifndef PIC #ifndef PIC
@@ -73,6 +74,10 @@ _start:
be NULL. */ be NULL. */
mov %g1, %o5 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. */ /* Let libc do the rest of the initialization, and call main. */
call __libc_start_main call __libc_start_main
nop nop

View File

@@ -74,6 +74,10 @@ _start:
be NULL. */ be NULL. */
mov %g1, %o5 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. */ /* Let libc do the rest of the initialization, and call main. */
call __libc_start_main call __libc_start_main
nop nop

View File

@@ -152,13 +152,8 @@
#else /* not __ASSEMBLER__ */ #else /* not __ASSEMBLER__ */
# ifdef __LP64__ # define VDSO_NAME "LINUX_2.6.39"
# define VDSO_NAME "LINUX_2.6.39" # define VDSO_HASH 123718537
# define VDSO_HASH 123718537
# else
# define VDSO_NAME "LINUX_4.9"
# define VDSO_HASH 61765625
# endif
/* List of system calls which are supported as vsyscalls. */ /* List of system calls which are supported as vsyscalls. */
# define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres" # define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"

View File

@@ -54,6 +54,10 @@
configurations). */ configurations). */
#define __ASSUME_SET_ROBUST_LIST 1 #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 /* Support for various CLOEXEC and NONBLOCK flags was added in
2.6.27. */ 2.6.27. */
#define __ASSUME_IN_NONBLOCK 1 #define __ASSUME_IN_NONBLOCK 1

View File

@@ -145,11 +145,12 @@
# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres" # define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime" # define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
# define HAVE_GETRANDOM_VSYSCALL "__vdso_getrandom"
# else # else
# define VDSO_NAME "LINUX_5.4" # define VDSO_NAME "LINUX_5.4"
# define VDSO_HASH 61765876 # define VDSO_HASH 61765876
/* RV32 does not support the gettime VDSO syscalls. */ /* RV32 does not support the gettime and getrandom VDSO syscalls. */
# endif # endif
# define HAVE_CLONE3_WRAPPER 1 # define HAVE_CLONE3_WRAPPER 1

View File

@@ -102,6 +102,9 @@
| (1 << X86_XSTATE_ZMM_ID) \ | (1 << X86_XSTATE_ZMM_ID) \
| (1 << X86_XSTATE_APX_F_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. */ /* AMX state mask. */
# define AMX_STATE_SAVE_MASK \ # define AMX_STATE_SAVE_MASK \
((1 << X86_XSTATE_TILECFG_ID) | (1 << X86_XSTATE_TILEDATA_ID)) ((1 << X86_XSTATE_TILECFG_ID) | (1 << X86_XSTATE_TILEDATA_ID))
@@ -123,6 +126,9 @@
| (1 << X86_XSTATE_K_ID) \ | (1 << X86_XSTATE_K_ID) \
| (1 << X86_XSTATE_ZMM_H_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. */ /* States to be included in xsave_state_size. */
# define FULL_STATE_SAVE_MASK STATE_SAVE_MASK # define FULL_STATE_SAVE_MASK STATE_SAVE_MASK
#endif #endif
@@ -177,6 +183,29 @@
#define atom_text_section .section ".text.atom", "ax" #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 /* __ASSEMBLER__ */
#endif /* _X86_SYSDEP_H */ #endif /* _X86_SYSDEP_H */