Skip to content

Commit 675b1a1

Browse files
committed
glibc: update crt0 code to 2.42
1 parent 1804251 commit 675b1a1

File tree

21 files changed

+165
-193
lines changed

21 files changed

+165
-193
lines changed

lib/libc/glibc/elf/elf.h

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,21 @@ struct abort_msg_s
368368
extern struct abort_msg_s *__abort_msg;
369369
libc_hidden_proto (__abort_msg)
370370

371+
enum readonly_error_type
372+
{
373+
readonly_noerror,
374+
readonly_area_writable,
375+
readonly_procfs_inaccessible,
376+
readonly_procfs_open_fail,
377+
};
378+
379+
extern enum readonly_error_type __readonly_area (const void *ptr,
380+
size_t size)
381+
attribute_hidden;
382+
extern enum readonly_error_type __readonly_area_fallback (const void *ptr,
383+
size_t size)
384+
attribute_hidden;
385+
371386
# if IS_IN (rtld)
372387
extern __typeof (unsetenv) unsetenv attribute_hidden;
373388
extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;

lib/libc/glibc/io/fcntl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
291-
extern int lockf (int __fd, int __cmd, off_t __len);
291+
extern int lockf (int __fd, int __cmd, off_t __len) __wur;
292292
# else
293293
# ifdef __REDIRECT
294-
extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
294+
extern 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
300-
extern int lockf64 (int __fd, int __cmd, off64_t __len);
301+
extern int lockf64 (int __fd, int __cmd, off64_t __len) __wur;
301302
# endif
302303
#endif
303304

lib/libc/glibc/posix/bits/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
989+
extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur;
990+
extern 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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ _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
6262

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,25 @@ 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
7878

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
112114
END(_start)

0 commit comments

Comments
 (0)