authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-31 22:08:36+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-01 09:00:27+02:00
log675b1a15a17d796fa9e48902047c3c7b350a1d7e
treefc3cd1f7ad755033f6c9e0f57c61b784866703af
parent1804251dfb5b1a5699371735aac138b3a2d6c3f6
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

glibc: update crt0 code to 2.42


21 files changed, 165 insertions(+), 193 deletions(-)

lib/libc/glibc/elf/elf.h+11-22
......@@ -837,12 +837,15 @@ typedef struct
837837#define NT_ARM_ZT 0x40d /* ARM SME ZT registers. */
838838#define NT_ARM_FPMR 0x40e /* ARM floating point mode register. */
839839#define NT_ARM_POE 0x40f /* ARM POE registers. */
840#define NT_ARM_GCS 0x410 /* ARM GCS state. */
840841#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
841842#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
842843#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
843844#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */
844845#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */
845846#define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */
847#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged
848 address control */
846849#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers. */
847850#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and
848851 status registers. */
......@@ -2906,19 +2909,6 @@ enum
29062909
29072910#define R_AARCH64_NONE 0 /* No relocation. */
29082911
2909/* ILP32 AArch64 relocs. */
2910#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
2911#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
2912#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
2913#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
2914#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
2915#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
2916#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
2917#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
2918#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
2919#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
2920
2921/* LP64 AArch64 relocs. */
29222912#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
29232913#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
29242914#define R_AARCH64_ABS16 259 /* Direct 16-bit. */
......@@ -4091,6 +4081,7 @@ enum
40914081#define R_RISCV_TLS_DTPREL64 9
40924082#define R_RISCV_TLS_TPREL32 10
40934083#define R_RISCV_TLS_TPREL64 11
4084#define R_RISCV_TLSDESC 12
40944085#define R_RISCV_BRANCH 16
40954086#define R_RISCV_JAL 17
40964087#define R_RISCV_CALL 18
......@@ -4116,16 +4107,10 @@ enum
41164107#define R_RISCV_SUB16 38
41174108#define R_RISCV_SUB32 39
41184109#define R_RISCV_SUB64 40
4119#define R_RISCV_GNU_VTINHERIT 41
4120#define R_RISCV_GNU_VTENTRY 42
4110#define R_RISCV_GOT32_PCREL 41
41214111#define R_RISCV_ALIGN 43
41224112#define R_RISCV_RVC_BRANCH 44
41234113#define R_RISCV_RVC_JUMP 45
4124#define R_RISCV_RVC_LUI 46
4125#define R_RISCV_GPREL_I 47
4126#define R_RISCV_GPREL_S 48
4127#define R_RISCV_TPREL_I 49
4128#define R_RISCV_TPREL_S 50
41294114#define R_RISCV_RELAX 51
41304115#define R_RISCV_SUB6 52
41314116#define R_RISCV_SET6 53
......@@ -4137,8 +4122,12 @@ enum
41374122#define R_RISCV_PLT32 59
41384123#define R_RISCV_SET_ULEB128 60
41394124#define R_RISCV_SUB_ULEB128 61
4125#define R_RISCV_TLSDESC_HI20 62
4126#define R_RISCV_TLSDESC_LOAD_LO12 63
4127#define R_RISCV_TLSDESC_ADD_LO12 64
4128#define R_RISCV_TLSDESC_CALL 65
41404129
4141#define R_RISCV_NUM 62
4130#define R_RISCV_NUM 66
41424131
41434132/* RISC-V specific values for the st_other field. */
41444133#define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling
......@@ -4147,7 +4136,7 @@ enum
41474136/* RISC-V specific values for the sh_type field. */
41484137#define SHT_RISCV_ATTRIBUTES (SHT_LOPROC + 3)
41494138
4150/* RISC-V specific values for the p_type field. */
4139/* RISC-V specific values for the p_type field (deprecated). */
41514140#define PT_RISCV_ATTRIBUTES (PT_LOPROC + 3)
41524141
41534142/* RISC-V specific values for the d_tag field. */
lib/libc/glibc/include/elf.h+13
......@@ -15,6 +15,19 @@
1515# define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \
1616 ALIGN_UP (ELF_NOTE_DESC_OFFSET ((namesz), (align)) + (descsz), (align))
1717
18# ifdef HIDDEN_VAR_NEEDS_DYNAMIC_RELOC
19# define DL_ADDRESS_WITHOUT_RELOC(expr) (expr)
20# else
21/* Evaluate EXPR without run-time relocation for it. EXPR should be an
22 array, an address of an object, or a string literal. */
23# define DL_ADDRESS_WITHOUT_RELOC(expr) \
24 ({ \
25 __auto_type _result = (expr); \
26 asm ("" : "+r" (_result)); \
27 _result; \
28 })
29# endif
30
1831/* Some information which is not meant for the public and therefore not
1932 in <elf.h>. */
2033# include <dl-dtprocnum.h>
lib/libc/glibc/include/libc-symbols.h+4-4
......@@ -155,7 +155,7 @@
155155 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
156156 __attribute_copy__ (name);
157157
158/* Zig patch. weak_hidden_alias was removed from glibc v2.36 (v2.37?), Zig
158/* zig patch: weak_hidden_alias was removed from glibc v2.36 (v2.37?), Zig
159159 needs it for the v2.32 and earlier {f,l,}stat wrappers, so only include
160160 in this header for 2.32 and earlier. */
161161#if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 32) || __GLIBC__ < 2
......@@ -220,7 +220,7 @@
220220#define __make_section_unallocated(section_string) \
221221 asm (".section " section_string "\n\t.previous");
222222
223/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
223/* Tacking on "\n\t#" to the section name makes gcc put its bogus
224224 section attributes on what looks like a comment to the assembler. */
225225#ifdef HAVE_SECTION_QUOTES
226226# define __sec_comment "\"\n\t#\""
......@@ -280,7 +280,7 @@ for linking")
280280
281281
282282/*
283
283
284284*/
285285
286286#ifdef HAVE_GNU_RETAIN
......@@ -807,7 +807,7 @@ for linking")
807807#define libm_ifunc_init()
808808#define libm_ifunc(name, expr) \
809809 __ifunc (name, name, expr, void, libm_ifunc_init)
810
810
811811/* These macros facilitate sharing source files with gnulib.
812812
813813 They are here instead of sys/cdefs.h because they should not be
lib/libc/glibc/include/stdlib.h+15
......@@ -368,6 +368,21 @@ struct abort_msg_s
368368extern struct abort_msg_s *__abort_msg;
369369libc_hidden_proto (__abort_msg)
370370
371enum readonly_error_type
372{
373 readonly_noerror,
374 readonly_area_writable,
375 readonly_procfs_inaccessible,
376 readonly_procfs_open_fail,
377};
378
379extern enum readonly_error_type __readonly_area (const void *ptr,
380 size_t size)
381 attribute_hidden;
382extern enum readonly_error_type __readonly_area_fallback (const void *ptr,
383 size_t size)
384 attribute_hidden;
385
371386# if IS_IN (rtld)
372387extern __typeof (unsetenv) unsetenv attribute_hidden;
373388extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
lib/libc/glibc/io/fcntl.h+5-4
......@@ -168,7 +168,7 @@ typedef __pid_t pid_t;
168168#endif
169169
170170
171/* fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards
171/* zig patch: fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards
172172 * re-defines it to fcntl64 (via #define) if _FILE_OFFSET_BITS == 64. */
173173#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
174174/* 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));
288288# define F_TEST 3 /* Test a region for other processes locks. */
289289
290290# ifndef __USE_FILE_OFFSET64
291extern int lockf (int __fd, int __cmd, off_t __len);
291extern int lockf (int __fd, int __cmd, off_t __len) __wur;
292292# else
293293# ifdef __REDIRECT
294extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
294extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
295 lockf64) __wur;
295296# else
296297# define lockf lockf64
297298# endif
298299# endif
299300# ifdef __USE_LARGEFILE64
300extern int lockf64 (int __fd, int __cmd, off64_t __len);
301extern int lockf64 (int __fd, int __cmd, off64_t __len) __wur;
301302# endif
302303#endif
303304
lib/libc/glibc/posix/bits/types.h+1-1
......@@ -217,7 +217,7 @@ typedef int __sig_atomic_t;
217217/* Seconds since the Epoch, visible to user code when time_t is too
218218 narrow only for consistency with the old way of widening too-narrow
219219 types. User code should never use __time64_t. */
220/* Zig patch: Don't check __LIBC here because it breaks fstatat.c on x86. */
220/* zig patch: Don't check __LIBC here because it breaks fstatat.c on x86. */
221221#if __TIMESIZE == 64
222222# define __time64_t __time_t
223223#elif __TIMESIZE != 64
lib/libc/glibc/stdlib/stdlib.h+6
......@@ -985,6 +985,12 @@ __extension__ extern long long int llabs (long long int __x)
985985 __THROW __attribute__ ((__const__)) __wur;
986986#endif
987987
988#if __GLIBC_USE (ISOC2Y)
989extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur;
990extern unsigned long int ulabs (long int __x) __THROW __attribute__ ((__const__)) __wur;
991__extension__ extern unsigned long long int ullabs (long long int __x)
992 __THROW __attribute__ ((__const__)) __wur;
993#endif
988994
989995/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
990996 of the value of NUMER over DENOM. */
lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h+7-17
......@@ -21,23 +21,13 @@
2121
2222#include <bits/endian.h>
2323
24#ifdef __ILP32__
25# define __SIZEOF_PTHREAD_ATTR_T 32
26# define __SIZEOF_PTHREAD_MUTEX_T 32
27# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
28# define __SIZEOF_PTHREAD_CONDATTR_T 4
29# define __SIZEOF_PTHREAD_RWLOCK_T 48
30# define __SIZEOF_PTHREAD_BARRIER_T 20
31# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32#else
33# define __SIZEOF_PTHREAD_ATTR_T 64
34# define __SIZEOF_PTHREAD_MUTEX_T 48
35# define __SIZEOF_PTHREAD_MUTEXATTR_T 8
36# define __SIZEOF_PTHREAD_CONDATTR_T 8
37# define __SIZEOF_PTHREAD_RWLOCK_T 56
38# define __SIZEOF_PTHREAD_BARRIER_T 32
39# define __SIZEOF_PTHREAD_BARRIERATTR_T 8
40#endif
24#define __SIZEOF_PTHREAD_ATTR_T 64
25#define __SIZEOF_PTHREAD_MUTEX_T 48
26#define __SIZEOF_PTHREAD_MUTEXATTR_T 8
27#define __SIZEOF_PTHREAD_CONDATTR_T 8
28#define __SIZEOF_PTHREAD_RWLOCK_T 56
29#define __SIZEOF_PTHREAD_BARRIER_T 32
30#define __SIZEOF_PTHREAD_BARRIERATTR_T 8
4131#define __SIZEOF_PTHREAD_COND_T 48
4232#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
4333
lib/libc/glibc/sysdeps/aarch64/start-2.33.S+17-8
......@@ -54,8 +54,8 @@ _start:
5454 mov x5, x0
5555
5656 /* Load argc and a pointer to argv */
57 ldr PTR_REG (1), [sp, #0]
58 add x2, sp, #PTR_SIZE
57 ldr x1, [sp, #0]
58 add x2, sp, 8
5959
6060 /* Setup stack limit in argument register */
6161 mov x6, sp
......@@ -63,13 +63,13 @@ _start:
6363#ifdef PIC
6464# ifdef SHARED
6565 adrp x0, :got:main
66 ldr PTR_REG (0), [x0, #:got_lo12:main]
66 ldr x0, [x0, #:got_lo12:main]
6767
6868 adrp x3, :got:__libc_csu_init
69 ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
69 ldr x3, [x3, #:got_lo12:__libc_csu_init]
7070
7171 adrp x4, :got:__libc_csu_fini
72 ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
72 ldr x4, [x4, #:got_lo12:__libc_csu_fini]
7373# else
7474 adrp x0, __wrap_main
7575 add x0, x0, :lo12:__wrap_main
......@@ -80,9 +80,18 @@ _start:
8080# endif
8181#else
8282 /* Set up the other arguments in registers */
83 MOVL (0, main)
84 MOVL (3, __libc_csu_init)
85 MOVL (4, __libc_csu_fini)
83 movz x0, :abs_g3:main
84 movk x0, :abs_g2_nc:main
85 movk x0, :abs_g1_nc:main
86 movk x0, :abs_g0_nc:main
87 movz x3, :abs_g3:__libc_csu_init
88 movk x3, :abs_g2_nc:__libc_csu_init
89 movk x3, :abs_g1_nc:__libc_csu_init
90 movk x3, :abs_g0_nc:__libc_csu_init
91 movz x4, :abs_g3:__libc_csu_fini
92 movk x4, :abs_g2_nc:__libc_csu_fini
93 movk x4, :abs_g1_nc:__libc_csu_fini
94 movk x4, :abs_g0_nc:__libc_csu_fini
8695#endif
8796
8897 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
lib/libc/glibc/sysdeps/aarch64/start.S+8-6
......@@ -70,8 +70,8 @@ ENTRY(_start)
7070 mov x5, x0
7171
7272 /* Load argc and a pointer to argv */
73 ldr PTR_REG (1), [sp, #0]
74 add x2, sp, #PTR_SIZE
73 ldr x1, [sp, #0]
74 add x2, sp, 8
7575
7676 /* Setup stack limit in argument register */
7777 mov x6, sp
......@@ -79,14 +79,16 @@ ENTRY(_start)
7979#ifdef PIC
8080# ifdef SHARED
8181 adrp x0, :got:main
82 ldr PTR_REG (0), [x0, #:got_lo12:main]
82 ldr x0, [x0, #:got_lo12:main]
8383# else
8484 adrp x0, __wrap_main
8585 add x0, x0, :lo12:__wrap_main
8686# endif
8787#else
88 /* Set up the other arguments in registers */
89 MOVL (0, main)
88 movz x0, :abs_g3:main
89 movk x0, :abs_g2_nc:main
90 movk x0, :abs_g1_nc:main
91 movk x0, :abs_g0_nc:main
9092#endif
9193 mov x3, #0 /* Used to be init. */
9294 mov x4, #0 /* Used to be fini. */
......@@ -106,7 +108,7 @@ ENTRY(_start)
106108 because crt1.o and rcrt1.o share code and the later must avoid the
107109 use of GOT relocations before __libc_start_main is called. */
108110__wrap_main:
109 BTI_C
111 bti c
110112 b main
111113#endif
112114END(_start)
lib/libc/glibc/sysdeps/aarch64/sysdep.h+6-81
......@@ -21,59 +21,15 @@
2121
2222#include <sysdeps/generic/sysdep.h>
2323
24#ifdef __LP64__
25# define AARCH64_R(NAME) R_AARCH64_ ## NAME
26# define PTR_REG(n) x##n
27# define PTR_LOG_SIZE 3
28# define PTR_ARG(n)
29# define SIZE_ARG(n)
30#else
31# define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
32# define PTR_REG(n) w##n
33# define PTR_LOG_SIZE 2
34# define PTR_ARG(n) mov w##n, w##n
35# define SIZE_ARG(n) mov w##n, w##n
36#endif
37
38#define PTR_SIZE (1<<PTR_LOG_SIZE)
39
40#ifndef __ASSEMBLER__
41/* Strip pointer authentication code from pointer p. */
42static inline void *
43strip_pac (void *p)
44{
45 register void *ra asm ("x30") = (p);
46 asm ("hint 7 // xpaclri" : "+r"(ra));
47 return ra;
48}
49
50/* This is needed when glibc is built with -mbranch-protection=pac-ret
51 with a gcc that is affected by PR target/94891. */
52# if HAVE_AARCH64_PAC_RET
53# undef RETURN_ADDRESS
54# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n))
55# endif
56#endif
57
5824#ifdef __ASSEMBLER__
5925
26/* CFI directive for return address. */
27#define cfi_negate_ra_state .cfi_negate_ra_state
28
6029/* Syntactic details of assembler. */
6130
6231#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
6332
64/* Branch Target Identitication support. */
65#if HAVE_AARCH64_BTI
66# define BTI_C hint 34
67# define BTI_J hint 36
68#else
69# define BTI_C nop
70# define BTI_J nop
71#endif
72
73/* Return address signing support (pac-ret). */
74#define PACIASP hint 25
75#define AUTIASP hint 29
76
7733/* Guarded Control Stack support. */
7834#define CHKFEAT_X16 hint 40
7935#define MRS_GCSPR(x) mrs x, s3_3_c2_c5_1
......@@ -103,11 +59,7 @@ strip_pac (void *p)
10359
10460/* Add GNU property note with the supported features to all asm code
10561 where sysdep.h is included. */
106#if HAVE_AARCH64_BTI && HAVE_AARCH64_PAC_RET
10762GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS)
108#elif HAVE_AARCH64_BTI
109GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
110#endif
11163
11264/* Define an entry point visible from C. */
11365#define ENTRY(name) \
......@@ -116,7 +68,7 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
11668 .p2align 6; \
11769 C_LABEL(name) \
11870 cfi_startproc; \
119 BTI_C; \
71 bti c; \
12072 CALL_MCOUNT
12173
12274/* Define an entry point visible from C. */
......@@ -126,7 +78,7 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
12678 .p2align align; \
12779 C_LABEL(name) \
12880 cfi_startproc; \
129 BTI_C; \
81 bti c; \
13082 CALL_MCOUNT
13183
13284/* 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)
14395 .endr; \
14496 C_LABEL(name) \
14597 cfi_startproc; \
146 BTI_C; \
98 bti c; \
14799 CALL_MCOUNT
148100
149101#undef END
......@@ -195,33 +147,6 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_GCS)
195147# define L(name) .L##name
196148#endif
197149
198/* Load or store to/from a pc-relative EXPR into/from R, using T.
199 Note R and T are register numbers and not register names. */
200#define LDST_PCREL(OP, R, T, EXPR) \
201 adrp x##T, EXPR; \
202 OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
203
204/* Load or store to/from a got-relative EXPR into/from R, using T.
205 Note R and T are register numbers and not register names. */
206#define LDST_GLOBAL(OP, R, T, EXPR) \
207 adrp x##T, :got:EXPR; \
208 ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
209 OP PTR_REG (R), [x##T];
210
211/* Load an immediate into R.
212 Note R is a register number and not a register name. */
213#ifdef __LP64__
214# define MOVL(R, NAME) \
215 movz PTR_REG (R), #:abs_g3:NAME; \
216 movk PTR_REG (R), #:abs_g2_nc:NAME; \
217 movk PTR_REG (R), #:abs_g1_nc:NAME; \
218 movk PTR_REG (R), #:abs_g0_nc:NAME;
219#else
220# define MOVL(R, NAME) \
221 movz PTR_REG (R), #:abs_g1:NAME; \
222 movk PTR_REG (R), #:abs_g0_nc:NAME;
223#endif
224
225150/* Since C identifiers are not normally prefixed with an underscore
226151 on this system, the asm identifier `syscall_error' intrudes on the
227152 C name space. Make sure we use an innocuous name. */
lib/libc/glibc/sysdeps/generic/sysdep.h+3
......@@ -45,6 +45,7 @@
4545# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
4646# define cfi_offset(reg, off) .cfi_offset reg, off
4747# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
48# define cfi_val_offset(reg, off) .cfi_val_offset reg, off
4849# define cfi_register(r1, r2) .cfi_register r1, r2
4950# define cfi_return_column(reg) .cfi_return_column reg
5051# define cfi_restore(reg) .cfi_restore reg
......@@ -74,6 +75,8 @@
7475 ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
7576# define CFI_REL_OFFSET(reg, off) \
7677 ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
78# define CFI_VAL_OFFSET(reg, off) \
79 ".cfi_val_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
7780# define CFI_REGISTER(r1, r2) \
7881 ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
7982# define CFI_RETURN_COLUMN(reg) \
lib/libc/glibc/sysdeps/htl/libc-lockP.h+10-39
......@@ -75,7 +75,6 @@
7575
7676extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
7777 const pthread_mutexattr_t *__mutex_attr);
78
7978extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
8079libc_hidden_proto (__pthread_mutex_destroy)
8180
......@@ -91,75 +90,47 @@ libc_hidden_proto (__pthread_mutexattr_init)
9190extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
9291libc_hidden_proto (__pthread_mutexattr_destroy)
9392
94extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
95 int __kind);
96
9793extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
9894 const pthread_rwlockattr_t *__attr);
95libc_hidden_proto (__pthread_rwlock_init)
9996
10097extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
98libc_hidden_proto (__pthread_rwlock_destroy)
10199
102100extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
101libc_hidden_proto (__pthread_rwlock_rdlock)
103102
104103extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
104libc_hidden_proto (__pthread_rwlock_tryrdlock)
105105
106106extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
107libc_hidden_proto (__pthread_rwlock_wrlock)
107108
108109extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
110libc_hidden_proto (__pthread_rwlock_trywrlock)
109111
110112extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
113libc_hidden_proto (__pthread_rwlock_unlock)
111114
112115extern int __pthread_once (pthread_once_t *__once_control,
113116 void (*__init_routine) (void));
117libc_hidden_proto (__pthread_once);
114118
115119extern int __pthread_atfork (void (*__prepare) (void),
116120 void (*__parent) (void),
117121 void (*__child) (void));
118122
123extern int __pthread_setcancelstate (int state, int *oldstate);
124libc_hidden_proto (__pthread_setcancelstate)
119125/* Make the pthread functions weak so that we can elide them from
120126 single-threaded processes. */
121127#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
122128# ifdef weak_extern
123weak_extern (__pthread_mutex_init)
124weak_extern (__pthread_mutex_destroy)
125weak_extern (__pthread_mutex_lock)
126weak_extern (__pthread_mutex_trylock)
127weak_extern (__pthread_mutex_unlock)
128weak_extern (__pthread_mutexattr_settype)
129weak_extern (__pthread_rwlock_init)
130weak_extern (__pthread_rwlock_destroy)
131weak_extern (__pthread_rwlock_rdlock)
132weak_extern (__pthread_rwlock_tryrdlock)
133weak_extern (__pthread_rwlock_wrlock)
134weak_extern (__pthread_rwlock_trywrlock)
135weak_extern (__pthread_rwlock_unlock)
136weak_extern (__pthread_key_create)
137weak_extern (__pthread_setspecific)
138weak_extern (__pthread_getspecific)
139weak_extern (__pthread_once)
140129weak_extern (__pthread_initialize)
141130weak_extern (__pthread_atfork)
142weak_extern (__pthread_setcancelstate)
143131# else
144# pragma weak __pthread_mutex_init
145# pragma weak __pthread_mutex_destroy
146# pragma weak __pthread_mutex_lock
147# pragma weak __pthread_mutex_trylock
148# pragma weak __pthread_mutex_unlock
149# pragma weak __pthread_mutexattr_settype
150# pragma weak __pthread_rwlock_destroy
151# pragma weak __pthread_rwlock_rdlock
152# pragma weak __pthread_rwlock_tryrdlock
153# pragma weak __pthread_rwlock_wrlock
154# pragma weak __pthread_rwlock_trywrlock
155# pragma weak __pthread_rwlock_unlock
156# pragma weak __pthread_key_create
157# pragma weak __pthread_setspecific
158# pragma weak __pthread_getspecific
159# pragma weak __pthread_once
160132# pragma weak __pthread_initialize
161133# pragma weak __pthread_atfork
162# pragma weak __pthread_setcancelstate
163134# endif
164135#endif
165136
lib/libc/glibc/sysdeps/mach/sysdep.h+5
......@@ -20,6 +20,11 @@
2020/* Get the Mach definitions of ENTRY and kernel_trap. */
2121#include <mach/machine/syscall_sw.h>
2222
23/* This macro is defined in Mach system headers, but string functions use it
24 with different definitions depending on whether being compiled for
25 wide-characters or not. */
26#undef P2ALIGN
27
2328/* The Mach definitions assume underscores should be prepended to
2429 symbol names. Redefine them to do so only when appropriate. */
2530#undef EXT
lib/libc/glibc/sysdeps/nptl/pthread.h+5
......@@ -1317,6 +1317,11 @@ extern int pthread_getcpuclockid (pthread_t __thread_id,
13171317 __THROW __nonnull ((2));
13181318#endif
13191319
1320#ifdef __USE_GNU
1321/* Return the Linux TID for THREAD_ID. Returns -1 on failure. */
1322extern pid_t pthread_gettid_np (pthread_t __thread_id);
1323#endif
1324
13201325
13211326/* Install handlers to be called when a new process is created with FORK.
13221327 The PREPARE handler is called in the parent process just before performing
lib/libc/glibc/sysdeps/sparc/sparc32/start.S+8-3
......@@ -35,6 +35,7 @@
3535
3636#include <sysdep.h>
3737
38#define FRAME_SIZE 104
3839
3940 .section ".text"
4041 .align 4
......@@ -48,12 +49,12 @@ _start:
4849 /* Terminate the stack frame, and reserve space for functions to
4950 drop their arguments. */
5051 mov %g0, %fp
51 sub %sp, 6*4, %sp
52 sub %sp, FRAME_SIZE, %sp
5253
5354 /* Extract the arguments and environment as encoded on the stack. The
5455 argument info starts after one register window (16 words) past the SP. */
55 ld [%sp+22*4], %o1
56 add %sp, 23*4, %o2
56 ld [%sp+168], %o1
57 add %sp, 172, %o2
5758
5859 /* Load the addresses of the user entry points. */
5960#ifndef PIC
......@@ -73,6 +74,10 @@ _start:
7374 be NULL. */
7475 mov %g1, %o5
7576
77 /* Provide the highest stack address to update the __libc_stack_end (used
78 to enable executable stacks if required). */
79 st %sp, [%sp+23*4]
80
7681 /* Let libc do the rest of the initialization, and call main. */
7782 call __libc_start_main
7883 nop
lib/libc/glibc/sysdeps/sparc/sparc64/start.S+4
......@@ -74,6 +74,10 @@ _start:
7474 be NULL. */
7575 mov %g1, %o5
7676
77 /* Provide the highest stack address to update the __libc_stack_end (used
78 to enable executable stacks if required). */
79 stx %sp, [%sp+STACK_BIAS+22*8]
80
7781 /* Let libc do the rest of the initialization, and call main. */
7882 call __libc_start_main
7983 nop
lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h+2-7
......@@ -152,13 +152,8 @@
152152
153153#else /* not __ASSEMBLER__ */
154154
155# ifdef __LP64__
156# define VDSO_NAME "LINUX_2.6.39"
157# define VDSO_HASH 123718537
158# else
159# define VDSO_NAME "LINUX_4.9"
160# define VDSO_HASH 61765625
161# endif
155# define VDSO_NAME "LINUX_2.6.39"
156# define VDSO_HASH 123718537
162157
163158/* List of system calls which are supported as vsyscalls. */
164159# define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"
lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h+4
......@@ -54,6 +54,10 @@
5454 configurations). */
5555#define __ASSUME_SET_ROBUST_LIST 1
5656
57/* The termios2 interface was introduced across all architectures except
58 Alpha in kernel 2.6.22. */
59#define __ASSUME_TERMIOS2 1
60
5761/* Support for various CLOEXEC and NONBLOCK flags was added in
5862 2.6.27. */
5963#define __ASSUME_IN_NONBLOCK 1
lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h+2-1
......@@ -145,11 +145,12 @@
145145# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
146146# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
147147# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
148# define HAVE_GETRANDOM_VSYSCALL "__vdso_getrandom"
148149# else
149150# define VDSO_NAME "LINUX_5.4"
150151# define VDSO_HASH 61765876
151152
152/* RV32 does not support the gettime VDSO syscalls. */
153/* RV32 does not support the gettime and getrandom VDSO syscalls. */
153154# endif
154155# define HAVE_CLONE3_WRAPPER 1
155156
lib/libc/glibc/sysdeps/x86/sysdep.h+29
......@@ -102,6 +102,9 @@
102102 | (1 << X86_XSTATE_ZMM_ID) \
103103 | (1 << X86_XSTATE_APX_F_ID))
104104
105/* The maximum supported xstate ID. */
106# define X86_XSTATE_MAX_ID X86_XSTATE_APX_F_ID
107
105108/* AMX state mask. */
106109# define AMX_STATE_SAVE_MASK \
107110 ((1 << X86_XSTATE_TILECFG_ID) | (1 << X86_XSTATE_TILEDATA_ID))
......@@ -123,6 +126,9 @@
123126 | (1 << X86_XSTATE_K_ID) \
124127 | (1 << X86_XSTATE_ZMM_H_ID))
125128
129/* The maximum supported xstate ID. */
130# define X86_XSTATE_MAX_ID X86_XSTATE_ZMM_H_ID
131
126132/* States to be included in xsave_state_size. */
127133# define FULL_STATE_SAVE_MASK STATE_SAVE_MASK
128134#endif
......@@ -177,6 +183,29 @@
177183
178184#define atom_text_section .section ".text.atom", "ax"
179185
186#ifndef DL_STACK_ALIGNMENT
187/* Due to GCC bug:
188
189 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
190
191 __tls_get_addr may be called with 8-byte/4-byte stack alignment.
192 Although this bug has been fixed in GCC 4.9.4, 5.3 and 6, we can't
193 assume that stack will be always aligned at 16 bytes. */
194# ifdef __x86_64__
195# define DL_STACK_ALIGNMENT 8
196# define MINIMUM_ALIGNMENT 16
197# else
198# define DL_STACK_ALIGNMENT 4
199# endif
200#endif
201
202/* True if _dl_runtime_resolve/_dl_tlsdesc_dynamic should align stack for
203 STATE_SAVE or align stack to MINIMUM_ALIGNMENT bytes before calling
204 _dl_fixup/__tls_get_addr. */
205#define DL_RUNTIME_RESOLVE_REALIGN_STACK \
206 (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \
207 || MINIMUM_ALIGNMENT > DL_STACK_ALIGNMENT)
208
180209#endif /* __ASSEMBLER__ */
181210
182211#endif /* _X86_SYSDEP_H */