authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-07-29 08:51:50+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-07-31 23:04:48+02:00
logb3c063c8b837822e9ee7a0122620ef0ece9aab13
treefb604032f593d1862a4a11f1fad86d5563036593
parent2579b37ff6e7f08fe90cf920a83e1282e51c571e
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libc: update glibc crt0 code to 2.44


23 files changed, 875 insertions(+), 624 deletions(-)

lib/libc/glibc/elf/elf.h+6-2
...@@ -798,7 +798,8 @@ typedef struct...@@ -798,7 +798,8 @@ typedef struct
798#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */798#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
799#define NT_X86_SHSTK 0x204 /* x86 SHSTK state */799#define NT_X86_SHSTK 0x204 /* x86 SHSTK state */
800#define NT_X86_XSAVE_LAYOUT 0x205 /* XSAVE layout description. */800#define NT_X86_XSAVE_LAYOUT 0x205 /* XSAVE layout description. */
801#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */801#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves. This was
802 used in now removed s390-32 arch. */
802#define NT_S390_TIMER 0x301 /* s390 timer register */803#define NT_S390_TIMER 0x301 /* s390 timer register */
803#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */804#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
804#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */805#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
...@@ -846,6 +847,7 @@ typedef struct...@@ -846,6 +847,7 @@ typedef struct
846#define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */847#define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */
847#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged848#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged
848 address control */849 address control */
850#define NT_RISCV_USER_CFI 0x903 /* RISC-V shadow stack state */
849#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers. */851#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers. */
850#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and852#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and
851 status registers. */853 status registers. */
...@@ -3470,7 +3472,9 @@ enum...@@ -3470,7 +3472,9 @@ enum
34703472
3471/* Valid values for the e_flags field. */3473/* Valid values for the e_flags field. */
34723474
3473#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */3475#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed.
3476 This was used in now removed s390-32
3477 arch. */
34743478
3475/* Additional s390 relocs */3479/* Additional s390 relocs */
34763480
lib/libc/glibc/include/libc-symbols.h+2-1
...@@ -113,6 +113,7 @@...@@ -113,6 +113,7 @@
113#define HAVE_LIBINTL_H 1113#define HAVE_LIBINTL_H 1
114#define HAVE_WCTYPE_H 1114#define HAVE_WCTYPE_H 1
115#define HAVE_ISWCTYPE 1115#define HAVE_ISWCTYPE 1
116#define HAVE_MEMPCPY 1
116#define ENABLE_NLS 1117#define ENABLE_NLS 1
117118
118/* The symbols in all the user (non-_) macros are C symbols. */119/* The symbols in all the user (non-_) macros are C symbols. */
...@@ -682,7 +683,7 @@ for linking")...@@ -682,7 +683,7 @@ for linking")
682683
683/* Helper / base macros for indirect function symbols. */684/* Helper / base macros for indirect function symbols. */
684#define __ifunc_resolver(type_name, name, expr, init, classifier, ...) \685#define __ifunc_resolver(type_name, name, expr, init, classifier, ...) \
685 classifier inhibit_stack_protector \686 classifier \
686 __typeof (type_name) *name##_ifunc (__VA_ARGS__) \687 __typeof (type_name) *name##_ifunc (__VA_ARGS__) \
687 { \688 { \
688 init (); \689 init (); \
lib/libc/glibc/sysdeps/aarch64/sysdep.h+28-4
...@@ -43,7 +43,6 @@...@@ -43,7 +43,6 @@
43#define FEATURE_1_PAC 243#define FEATURE_1_PAC 2
44#define FEATURE_1_GCS 444#define FEATURE_1_GCS 4
4545
46/* Add a NT_GNU_PROPERTY_TYPE_0 note. */
47#define GNU_PROPERTY(type, value) \46#define GNU_PROPERTY(type, value) \
48 .section .note.gnu.property, "a"; \47 .section .note.gnu.property, "a"; \
49 .p2align 3; \48 .p2align 3; \
...@@ -57,9 +56,34 @@...@@ -57,9 +56,34 @@
57 .word 0; \56 .word 0; \
58 .text57 .text
5958
60/* Add GNU property note with the supported features to all asm code59#ifdef __ARM_BUILDATTR64_FV
61 where sysdep.h is included. */60/* Add AArch64 feature bits build attributes. */
62GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS)61# define FEATURE_1_AND_MARK(value) \
62 .aeabi_subsection aeabi_feature_and_bits, optional, ULEB128; \
63 .if ((value) & FEATURE_1_BTI); \
64 .aeabi_attribute Tag_Feature_BTI, 1; \
65 .else; \
66 .aeabi_attribute Tag_Feature_BTI, 0; \
67 .endif; \
68 .if ((value) & FEATURE_1_GCS); \
69 .aeabi_attribute Tag_Feature_GCS, 1; \
70 .else; \
71 .aeabi_attribute Tag_Feature_GCS, 0; \
72 .endif; \
73 .if ((value) & FEATURE_1_PAC); \
74 .aeabi_attribute Tag_Feature_PAC, 1; \
75 .else; \
76 .aeabi_attribute Tag_Feature_PAC, 0; \
77 .endif; \
78 .text
79#else
80/* Add a NT_GNU_PROPERTY_TYPE_0 note. */
81# define FEATURE_1_AND_MARK(value) GNU_PROPERTY (FEATURE_1_AND, value)
82#endif /* __ARM_BUILDATTR64_FV */
83
84/* Add marking with the supported features to all asm code where sysdep.h
85 is included. */
86FEATURE_1_AND_MARK (FEATURE_1_BTI | FEATURE_1_PAC | FEATURE_1_GCS)
6387
64/* Define an entry point visible from C. */88/* Define an entry point visible from C. */
65#define ENTRY(name) \89#define ENTRY(name) \
lib/libc/glibc/sysdeps/arm/start.S+27
...@@ -90,6 +90,7 @@ _start:...@@ -90,6 +90,7 @@ _start:
90 push { a1 }90 push { a1 }
9191
92#ifdef PIC92#ifdef PIC
93# ifdef SHARED
93 ldr sl, .L_GOT94 ldr sl, .L_GOT
94 adr a4, .L_GOT95 adr a4, .L_GOT
95 add sl, sl, a496 add sl, sl, a4
...@@ -103,6 +104,16 @@ _start:...@@ -103,6 +104,16 @@ _start:
103 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */104 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
104 /* Let the libc call main and exit with its return code. */105 /* Let the libc call main and exit with its return code. */
105 bl __libc_start_main(PLT)106 bl __libc_start_main(PLT)
107# else
108 ldr a1, .L_main_rel /* Load the relative offset of __wrap_main. */
109 adr a4, .L_main_rel /* Load the actual runtime address of the label. */
110 add a1, a4, a1 /* Add them together to get the absolute address. */
111
112 mov a4, #0 /* Used to be init. */
113 push { a4 } /* Used to be fini. */
114
115 bl __libc_start_main
116# endif /* ifdef SHARED */
106#else117#else
107118
108 mov a4, #0 /* Used to init. */119 mov a4, #0 /* Used to init. */
...@@ -119,14 +130,30 @@ _start:...@@ -119,14 +130,30 @@ _start:
119130
120#ifdef PIC131#ifdef PIC
121 .align 2132 .align 2
133# ifdef SHARED
122.L_GOT:134.L_GOT:
123 .word _GLOBAL_OFFSET_TABLE_ - .L_GOT135 .word _GLOBAL_OFFSET_TABLE_ - .L_GOT
124 .word main(GOT)136 .word main(GOT)
137# else
138.L_main_rel:
139 .word __wrap_main - .L_main_rel
140# endif
125#endif141#endif
126142
127 .cantunwind143 .cantunwind
128 .fnend144 .fnend
129145
146#if defined PIC && !defined SHARED
147/* When main is not defined in the executable but in a shared library then
148 a wrapper is needed, because crt1.o and rcrt1.o share this code and the
149 latter (static PIE) must avoid GOT relocations before __libc_start_main
150 is called. The branch to main is turned into a PLT entry by every linker,
151 unlike a REL32 data relocation against main. */
152 .type __wrap_main, %function
153__wrap_main:
154 b main
155#endif
156
130/* Define a symbol for the first piece of initialized data. */157/* Define a symbol for the first piece of initialized data. */
131 .data158 .data
132 .globl __data_start159 .globl __data_start
lib/libc/glibc/sysdeps/htl/libc-lockP.h+14
...@@ -21,6 +21,20 @@...@@ -21,6 +21,20 @@
2121
22#include <pthread.h>22#include <pthread.h>
2323
24typedef pthread_rwlock_t __libc_rwlock_t;
25
26#define __libc_rwlock_define(CLASS,NAME) \
27 CLASS __libc_rwlock_t NAME;
28#define __libc_rwlock_define_initialized(CLASS,NAME) \
29 CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;
30#define __libc_rwlock_init(NAME) __pthread_rwlock_init (&(NAME), NULL)
31#define __libc_rwlock_fini(NAME) ((void) 0)
32#define __libc_rwlock_rdlock(NAME) __pthread_rwlock_rdlock (&(NAME))
33#define __libc_rwlock_wrlock(NAME) __pthread_rwlock_wrlock (&(NAME))
34#define __libc_rwlock_tryrdlock(NAME) __pthread_rwlock_tryrdlock (&(NAME))
35#define __libc_rwlock_trywrlock(NAME) __pthread_rwlock_trywrlock (&(NAME))
36#define __libc_rwlock_unlock(NAME) __pthread_rwlock_unlock (&(NAME))
37
24/* If we check for a weakly referenced symbol and then perform a38/* If we check for a weakly referenced symbol and then perform a
25 normal jump to it te code generated for some platforms in case of39 normal jump to it te code generated for some platforms in case of
26 PIC is unnecessarily slow. What would happen is that the function40 PIC is unnecessarily slow. What would happen is that the function
lib/libc/glibc/sysdeps/loongarch/start.S+18-8
...@@ -36,6 +36,7 @@...@@ -36,6 +36,7 @@
36#define __ASSEMBLY__ 136#define __ASSEMBLY__ 1
37#include <entry.h>37#include <entry.h>
38#include <sys/asm.h>38#include <sys/asm.h>
39#include <sysdep.h>
3940
40/* The entry point's job is to call __libc_start_main. Per the ABI,41/* The entry point's job is to call __libc_start_main. Per the ABI,
41 a0 contains the address of a function to be passed to atexit.42 a0 contains the address of a function to be passed to atexit.
...@@ -57,23 +58,32 @@ ENTRY (ENTRY_POINT)...@@ -57,23 +58,32 @@ ENTRY (ENTRY_POINT)
57/* Terminate call stack by noting ra is undefined. Use a dummy58/* Terminate call stack by noting ra is undefined. Use a dummy
58 .cfi_label to force starting the FDE. */59 .cfi_label to force starting the FDE. */
59 .cfi_label .Ldummy60 .cfi_label .Ldummy
60 cfi_undefined (1)61 cfi_undefined (1)
61 or a5, a0, zero /* rtld_fini */62 or a5, a0, zero /* rtld_fini */
6263
63 la.pcrel a0, t0, main64#if defined PIC && !defined SHARED
65 /* Avoid relocation in static PIE since _start is called before it
66 is relocated. */
67 la.pcrel a0, __wrap_main
68#else
69 LA_GOT (a0, main)
70#endif
71
64 REG_L a1, sp, 072 REG_L a1, sp, 0
65 ADDI a2, sp, SZREG73 ADDI a2, sp, SZREG
6674
67 /* Adjust $sp for 16-aligned */75 /* Adjust $sp for 16-bytes aligned */
68 BSTRINS sp, zero, 3, 076 REG_ALIGN_ASM (sp, 4)
6977
70 move a3, zero /* used to be init */78 move a3, zero /* used to be init */
71 move a4, zero /* used to be fini */79 move a4, zero /* used to be fini */
72 or a6, sp, zero /* stack_end */80 or a6, sp, zero /* stack_end */
7381
74 la.pcrel ra, t0, __libc_start_main82 CALL (__libc_start_main)
75 jirl ra, ra, 083 CALL (abort)
7684
77 la.pcrel ra, t0, abort85#if defined PIC && !defined SHARED
78 jirl ra, ra, 086__wrap_main:
87 TAIL (main)
88#endif
79END (ENTRY_POINT)89END (ENTRY_POINT)
lib/libc/glibc/sysdeps/loongarch/sys/asm.h created+104
...@@ -0,0 +1,104 @@
1/* Miscellaneous macros.
2 Copyright (C) 2022-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_ASM_H
20#define _SYS_ASM_H
21
22#include <sys/regdef.h>
23#include <sysdeps/generic/sysdep.h>
24
25/* Macros to handle different pointer/register sizes for 32/64-bit code. */
26#if __loongarch_grlen == 64
27#define SZREG 8
28#define REG_L ld.d
29#define REG_S st.d
30#define SRLI srli.d
31#define SLLI slli.d
32#define ADDI addi.d
33#define ADD add.d
34#define SUB sub.d
35#define LI li.d
36#define BSTRINS bstrins.d
37
38#elif __loongarch_grlen == 32
39
40#define SZREG 4
41#define REG_L ld.w
42#define REG_S st.w
43#define SRLI srli.w
44#define SLLI slli.w
45#define ADDI addi.w
46#define ADD add.w
47#define SUB sub.w
48#define LI li.w
49#define BSTRINS bstrins.w
50
51#else
52#error __loongarch_grlen must equal 32 or 64
53#endif
54
55#if __loongarch_frlen == 64
56 #define SZFREG 8
57 #define FREG_L fld.d
58 #define FREG_S fst.d
59#elif __loongarch_frlen == 32
60 #define SZFREG 4
61 #define FREG_L fld.s
62 #define FREG_S fst.s
63#endif
64
65#define SZVREG 16
66#define SZXREG 32
67
68/* Declare leaf routine.
69 The usage of macro LEAF/ENTRY is as follows:
70 1. LEAF(fcn) -- the align value of fcn is .align 3 (default value)
71 2. LEAF(fcn, 6) -- the align value of fcn is .align 6
72*/
73#define LEAF_IMPL(symbol, aln, ...) \
74 .text; \
75 .globl symbol; \
76 .align aln; \
77 .type symbol, @function; \
78symbol: \
79 cfi_startproc;
80
81
82#define LEAF(...) LEAF_IMPL(__VA_ARGS__, 3)
83#define ENTRY(...) LEAF(__VA_ARGS__)
84
85#define LEAF_NO_ALIGN(symbol) \
86 .text; \
87 .globl symbol; \
88 .type symbol, @function; \
89symbol: \
90 cfi_startproc;
91
92#define ENTRY_NO_ALIGN(symbol) LEAF_NO_ALIGN(symbol)
93
94
95/* Mark end of function. */
96#undef END
97#define END(function) \
98 cfi_endproc; \
99 .size function, .- function;
100
101/* Stack alignment. */
102#define ALMASK ~15
103
104#endif /* sys/asm.h */
lib/libc/glibc/sysdeps/loongarch/sysdep.h created+94
...@@ -0,0 +1,94 @@
1/* Macros for LoongArch.
2 Copyright (C) 2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LOONGARCH_SYSDEP_H
20#define _LOONGARCH_SYSDEP_H
21
22#if __loongarch_grlen == 64
23
24#define PTRLOG 3
25/* Align reg to 2^n. Used in C. */
26#define REG_ALIGN_C(reg, n) \
27 "bstrins.d\t" __STRING(reg) ", $zero, (" __STRING(n) "-1), 0"
28
29#elif __loongarch_grlen == 32
30
31#define PTRLOG 2
32#define REG_ALIGN_C(reg, n) \
33 "srli.w\t" __STRING(reg)", " __STRING(reg)", " __STRING(n) "\n\t" \
34 "slli.w\t" __STRING(reg)", " __STRING(reg)", " __STRING(n)
35
36#else
37#error __loongarch_grlen must equal 32 or 64
38#endif
39
40#ifdef __ASSEMBLER__
41
42/* Stack alignment bytes. */
43#define STACK_ALIGN 16
44
45/* Macros to handle different pointer/register sizes for 32/64-bit code. */
46#if __loongarch_grlen == 64
47#define SRAI srai.d
48
49/* Align reg to 2^n. Used in assembly. */
50#define REG_ALIGN_ASM(reg, n) bstrins.d reg, zero, (n-1), 0
51
52#define LOAD_LOCAL(reg, sym) \
53 pcalau12i reg, %pc_hi20(sym); \
54 ld.d reg, reg, %pc_lo12(sym);
55
56#define LOAD_GLOBAL(reg, sym) \
57 la.got reg, sym; \
58 ld.d reg, reg, 0;
59
60#define LA_GOT(reg, sym) la.got reg, t0, sym
61
62#define CALL(sym) call36 sym
63#define TAIL(sym) tail36 t0, sym
64
65#elif __loongarch_grlen == 32 /* __loongarch_grlen == 64 */
66
67#define SRAI srai.w
68
69/* LA32R not have bstrins.w, use srli.w and slli.w on both LA32S and LA32R. */
70#define REG_ALIGN_ASM(reg, n) \
71 srli.w reg, reg, n; \
72 slli.w reg, reg, n;
73
74#define LOAD_LOCAL(reg, sym) \
75 1: pcaddu12i reg, %pcadd_hi20(sym); \
76 ld.w reg, reg, %pcadd_lo12(1b);
77
78#define LOAD_GLOBAL(reg, sym) \
79 1: pcaddu12i reg, %got_pcadd_hi20(sym); \
80 ld.w reg, reg, %pcadd_lo12(1b); \
81 ld.w reg, reg, 0;
82
83#define LA_GOT(reg, sym) la.got reg, sym
84
85#define CALL(sym) call30 sym
86#define TAIL(sym) tail30 t0, sym
87
88#else /* __loongarch_grlen == 64 */
89#error __loongarch_grlen must equal 32 or 64
90#endif /* __loongarch_grlen == 64 */
91
92#endif /* __ASSEMBLER__ */
93
94#endif /* _LOONGARCH_SYSDEP_H */
lib/libc/glibc/sysdeps/mach/libc-lock.h+10-10
...@@ -145,16 +145,16 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;...@@ -145,16 +145,16 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
145#define __rtld_lock_unlock_recursive(NAME) \145#define __rtld_lock_unlock_recursive(NAME) \
146 __libc_lock_unlock_recursive (NAME)146 __libc_lock_unlock_recursive (NAME)
147147
148/* XXX for now */148/* XXX for now, waiting for a futex-based pthread_rwlock implementation */
149#define __libc_rwlock_define __libc_lock_define149#define __mach_rwlock_define __libc_lock_define
150#define __libc_rwlock_define_initialized __libc_lock_define_initialized150#define __mach_rwlock_define_initialized __libc_lock_define_initialized
151#define __libc_rwlock_init __libc_lock_init151#define __mach_rwlock_init __libc_lock_init
152#define __libc_rwlock_fini __libc_lock_fini152#define __mach_rwlock_fini __libc_lock_fini
153#define __libc_rwlock_rdlock __libc_lock_lock153#define __mach_rwlock_rdlock __libc_lock_lock
154#define __libc_rwlock_wrlock __libc_lock_lock154#define __mach_rwlock_wrlock __libc_lock_lock
155#define __libc_rwlock_tryrdlock __libc_lock_trylock155#define __mach_rwlock_tryrdlock __libc_lock_trylock
156#define __libc_rwlock_trywrlock __libc_lock_trylock156#define __mach_rwlock_trywrlock __libc_lock_trylock
157#define __libc_rwlock_unlock __libc_lock_unlock157#define __mach_rwlock_unlock __libc_lock_unlock
158158
159struct __libc_cleanup_frame159struct __libc_cleanup_frame
160{160{
lib/libc/glibc/sysdeps/s390/s390-64/start-2.33.S deleted-107
...@@ -1,107 +0,0 @@
1/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39/*
40 This is the canonical entry point, usually the first thing in the text
41 segment. Most registers' values are unspecified, except for:
42
43 %r14 Contains a function pointer to be registered with `atexit'.
44 This is how the dynamic linker arranges to have DT_FINI
45 functions called for shared libraries that have been loaded
46 before this code runs.
47
48 %r15 The stack contains the arguments and environment:
49 0(%r15) argc
50 8(%r15) argv[0]
51 ...
52 (8*argc)(%r15) NULL
53 (8*(argc+1))(%r15) envp[0]
54 ...
55 NULL
56*/
57
58 .text
59 .globl _start
60 .type _start,@function
61_start:
62 cfi_startproc
63 /* Mark r14 as undefined in order to stop unwinding here! */
64 cfi_undefined (r14)
65 /* Load argc and argv from stack. */
66 la %r4,8(%r15) # get argv
67 lg %r3,0(%r15) # get argc
68
69 /* Align the stack to a double word boundary. */
70 lghi %r0,-16
71 ngr %r15,%r0
72
73 /* Setup a stack frame and a parameter area. */
74 aghi %r15,-176 # make room on stack
75 xc 0(8,%r15),0(%r15) # clear back-chain
76
77 /* Set up arguments for __libc_start_main:
78 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
79 Note that envp will be determined later in __libc_start_main.
80 */
81 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
82 la %r7,160(%r15)
83 larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
84 larl %r5,__libc_csu_init # load pointer to __libc_csu_init
85
86 /* Ok, now branch to the libc main routine. */
87#ifdef PIC
88 larl %r2,main@GOTENT # load pointer to main
89 lg %r2,0(%r2)
90 brasl %r14,__libc_start_main@plt
91#else
92 larl %r2,main # load pointer to main
93 brasl %r14,__libc_start_main
94#endif
95
96 /* Crash if __libc_start_main returns. */
97 .word 0
98
99 cfi_endproc
100
101 /* Define a symbol for the first piece of initialized data. */
102 .data
103 .globl __data_start
104__data_start:
105 .long 0
106 .weak data_start
107 data_start = __data_start
lib/libc/glibc/sysdeps/s390/s390-64/start.S deleted-134
...@@ -1,134 +0,0 @@
1/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/*
39 This is the canonical entry point, usually the first thing in the text
40 segment. Most registers' values are unspecified, except for:
41
42 %r14 Contains a function pointer to be registered with `atexit'.
43 This is how the dynamic linker arranges to have DT_FINI
44 functions called for shared libraries that have been loaded
45 before this code runs.
46
47 %r15 The stack contains the arguments and environment:
48 0(%r15) argc
49 8(%r15) argv[0]
50 ...
51 (8*argc)(%r15) NULL
52 (8*(argc+1))(%r15) envp[0]
53 ...
54 NULL
55*/
56
57 .text
58 .globl _start
59 .type _start,@function
60_start:
61 cfi_startproc
62 /* Mark r14 as undefined in order to stop unwinding here! */
63 cfi_undefined (r14)
64 /* Load argc and argv from stack. */
65 la %r4,8(%r15) # get argv
66 lg %r3,0(%r15) # get argc
67
68 /* Align the stack to a double word boundary. */
69 lghi %r0,-16
70 ngr %r15,%r0
71
72 /* Setup a stack frame and a parameter area. */
73 aghi %r15,-176 # make room on stack
74 xc 0(8,%r15),0(%r15) # clear back-chain
75
76 /* Set up arguments for __libc_start_main:
77 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
78 Note that envp will be determined later in __libc_start_main.
79 */
80 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
81 la %r7,160(%r15)
82 lghi %r6,0 # Used to be fini.
83 lghi %r5,0 # Used to be init.
84
85 /* Ok, now branch to the libc main routine. */
86#ifdef PIC
87# ifdef SHARED
88 /* Used for dynamic linked position independent executable.
89 => Scrt1.o */
90 larl %r2,main@GOTENT # load pointer to main
91 lg %r2,0(%r2)
92# else
93 /* Used for dynamic linked position dependent executable.
94 => crt1.o (glibc configured without --disable-default-pie:
95 PIC is defined)
96 Or for static linked position independent executable.
97 => rcrt1.o (only available if glibc configured without
98 --disable-default-pie: PIC is defined) */
99 larl %r2,__wrap_main
100# endif
101 brasl %r14,__libc_start_main@plt
102#else
103 /* Used for dynamic/static linked position dependent executable.
104 => crt1.o (glibc configured with --disable-default-pie:
105 PIC and SHARED are not defined) */
106 larl %r2,main # load pointer to main
107 brasl %r14,__libc_start_main
108#endif
109
110 /* Crash if __libc_start_main returns. */
111 .word 0
112
113 cfi_endproc
114
115#if defined PIC && !defined SHARED
116 /* When main is not defined in the executable but in a shared library
117 then a wrapper is needed in crt1.o of the static-pie enabled libc,
118 because crt1.o and rcrt1.o share code and the later must avoid the
119 use of GOT relocations before __libc_start_main is called. */
120__wrap_main:
121 cfi_startproc
122 larl %r1,main@GOTENT # load pointer to main
123 lg %r1,0(%r1)
124 br %r1
125 cfi_endproc
126#endif
127
128 /* Define a symbol for the first piece of initialized data. */
129 .data
130 .globl __data_start
131__data_start:
132 .long 0
133 .weak data_start
134 data_start = __data_start
lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h deleted-93
...@@ -1,93 +0,0 @@
1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Syntactic details of assembler. */
24
25/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
26#define ALIGNARG(log2) 1<<log2
27#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
28
29
30/* Define an entry point visible from C. */
31#define ENTRY(name) \
32 .globl C_SYMBOL_NAME(name); \
33 .type C_SYMBOL_NAME(name),@function; \
34 .align ALIGNARG(4); \
35 C_LABEL(name) \
36 cfi_startproc; \
37 CALL_MCOUNT
38
39#undef END
40#define END(name) \
41 cfi_endproc; \
42 ASM_SIZE_DIRECTIVE(name) \
43
44/* If compiled for profiling, call `mcount' at the start of each function. */
45#ifdef PROF
46#ifdef PIC
47#define CALL_MCOUNT \
48 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount@PLT ; lgr 14,0 ; \
49 .data ; .align 4 ; 0: .long 0 ; .text ;
50#else
51#define CALL_MCOUNT \
52 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount ; lgr 14,0 ; \
53 .data ; .align 4 ; 0: .long 0 ; .text ;
54#endif
55#else
56#define CALL_MCOUNT /* Do nothing. */
57#endif
58
59/* Since C identifiers are not normally prefixed with an underscore
60 on this system, the asm identifier `syscall_error' intrudes on the
61 C name space. Make sure we use an innocuous name. */
62#define syscall_error __syscall_error
63#define mcount _mcount
64
65#undef PSEUDO
66#define PSEUDO(name, syscall_name, args) \
67lose: SYSCALL_PIC_SETUP \
68 jg JUMPTARGET(syscall_error); \
69 .globl syscall_error; \
70 ENTRY (name) \
71 DO_CALL (syscall_name, args); \
72 jm lose
73
74#undef PSEUDO_END
75#define PSEUDO_END(name) \
76 END (name)
77
78#undef JUMPTARGET
79#ifdef SHARED
80#define JUMPTARGET(name) name##@PLT
81#define SYSCALL_PIC_SETUP \
82 larl %r12,_GLOBAL_OFFSET_TABLE_
83#else
84#define JUMPTARGET(name) name
85#define SYSCALL_PIC_SETUP /* Nothing. */
86#endif
87
88/* Local label name for asm code. */
89#ifndef L
90#define L(name) .L##name
91#endif
92
93#endif /* __ASSEMBLER__ */
lib/libc/glibc/sysdeps/s390/start-2.33.S created+107
...@@ -0,0 +1,107 @@
1/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39/*
40 This is the canonical entry point, usually the first thing in the text
41 segment. Most registers' values are unspecified, except for:
42
43 %r14 Contains a function pointer to be registered with `atexit'.
44 This is how the dynamic linker arranges to have DT_FINI
45 functions called for shared libraries that have been loaded
46 before this code runs.
47
48 %r15 The stack contains the arguments and environment:
49 0(%r15) argc
50 8(%r15) argv[0]
51 ...
52 (8*argc)(%r15) NULL
53 (8*(argc+1))(%r15) envp[0]
54 ...
55 NULL
56*/
57
58 .text
59 .globl _start
60 .type _start,@function
61_start:
62 cfi_startproc
63 /* Mark r14 as undefined in order to stop unwinding here! */
64 cfi_undefined (r14)
65 /* Load argc and argv from stack. */
66 la %r4,8(%r15) # get argv
67 lg %r3,0(%r15) # get argc
68
69 /* Align the stack to a double word boundary. */
70 lghi %r0,-16
71 ngr %r15,%r0
72
73 /* Setup a stack frame and a parameter area. */
74 aghi %r15,-176 # make room on stack
75 xc 0(8,%r15),0(%r15) # clear back-chain
76
77 /* Set up arguments for __libc_start_main:
78 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
79 Note that envp will be determined later in __libc_start_main.
80 */
81 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
82 la %r7,160(%r15)
83 larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
84 larl %r5,__libc_csu_init # load pointer to __libc_csu_init
85
86 /* Ok, now branch to the libc main routine. */
87#ifdef PIC
88 larl %r2,main@GOTENT # load pointer to main
89 lg %r2,0(%r2)
90 brasl %r14,__libc_start_main@plt
91#else
92 larl %r2,main # load pointer to main
93 brasl %r14,__libc_start_main
94#endif
95
96 /* Crash if __libc_start_main returns. */
97 .word 0
98
99 cfi_endproc
100
101 /* Define a symbol for the first piece of initialized data. */
102 .data
103 .globl __data_start
104__data_start:
105 .long 0
106 .weak data_start
107 data_start = __data_start
lib/libc/glibc/sysdeps/s390/start.S created+134
...@@ -0,0 +1,134 @@
1/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/*
39 This is the canonical entry point, usually the first thing in the text
40 segment. Most registers' values are unspecified, except for:
41
42 %r14 Contains a function pointer to be registered with `atexit'.
43 This is how the dynamic linker arranges to have DT_FINI
44 functions called for shared libraries that have been loaded
45 before this code runs.
46
47 %r15 The stack contains the arguments and environment:
48 0(%r15) argc
49 8(%r15) argv[0]
50 ...
51 (8*argc)(%r15) NULL
52 (8*(argc+1))(%r15) envp[0]
53 ...
54 NULL
55*/
56
57 .text
58 .globl _start
59 .type _start,@function
60_start:
61 cfi_startproc
62 /* Mark r14 as undefined in order to stop unwinding here! */
63 cfi_undefined (r14)
64 /* Load argc and argv from stack. */
65 la %r4,8(%r15) # get argv
66 lg %r3,0(%r15) # get argc
67
68 /* Align the stack to a double word boundary. */
69 lghi %r0,-16
70 ngr %r15,%r0
71
72 /* Setup a stack frame and a parameter area. */
73 aghi %r15,-176 # make room on stack
74 xc 0(8,%r15),0(%r15) # clear back-chain
75
76 /* Set up arguments for __libc_start_main:
77 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
78 Note that envp will be determined later in __libc_start_main.
79 */
80 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
81 la %r7,160(%r15)
82 lghi %r6,0 # Used to be fini.
83 lghi %r5,0 # Used to be init.
84
85 /* Ok, now branch to the libc main routine. */
86#ifdef PIC
87# ifdef SHARED
88 /* Used for dynamic linked position independent executable.
89 => Scrt1.o */
90 larl %r2,main@GOTENT # load pointer to main
91 lg %r2,0(%r2)
92# else
93 /* Used for dynamic linked position dependent executable.
94 => crt1.o (glibc configured without --disable-default-pie:
95 PIC is defined)
96 Or for static linked position independent executable.
97 => rcrt1.o (only available if glibc configured without
98 --disable-default-pie: PIC is defined) */
99 larl %r2,__wrap_main
100# endif
101 brasl %r14,__libc_start_main@plt
102#else
103 /* Used for dynamic/static linked position dependent executable.
104 => crt1.o (glibc configured with --disable-default-pie:
105 PIC and SHARED are not defined) */
106 larl %r2,main # load pointer to main
107 brasl %r14,__libc_start_main
108#endif
109
110 /* Crash if __libc_start_main returns. */
111 .word 0
112
113 cfi_endproc
114
115#if defined PIC && !defined SHARED
116 /* When main is not defined in the executable but in a shared library
117 then a wrapper is needed in crt1.o of the static-pie enabled libc,
118 because crt1.o and rcrt1.o share code and the later must avoid the
119 use of GOT relocations before __libc_start_main is called. */
120__wrap_main:
121 cfi_startproc
122 larl %r1,main@GOTENT # load pointer to main
123 lg %r1,0(%r1)
124 br %r1
125 cfi_endproc
126#endif
127
128 /* Define a symbol for the first piece of initialized data. */
129 .data
130 .globl __data_start
131__data_start:
132 .long 0
133 .weak data_start
134 data_start = __data_start
lib/libc/glibc/sysdeps/s390/sysdep.h created+93
...@@ -0,0 +1,93 @@
1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Syntactic details of assembler. */
24
25/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
26#define ALIGNARG(log2) 1<<log2
27#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
28
29
30/* Define an entry point visible from C. */
31#define ENTRY(name) \
32 .globl C_SYMBOL_NAME(name); \
33 .type C_SYMBOL_NAME(name),@function; \
34 .align ALIGNARG(4); \
35 C_LABEL(name) \
36 cfi_startproc; \
37 CALL_MCOUNT
38
39#undef END
40#define END(name) \
41 cfi_endproc; \
42 ASM_SIZE_DIRECTIVE(name) \
43
44/* If compiled for profiling, call `mcount' at the start of each function. */
45#ifdef PROF
46#ifdef PIC
47#define CALL_MCOUNT \
48 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount@PLT ; lgr 14,0 ; \
49 .data ; .align 4 ; 0: .long 0 ; .text ;
50#else
51#define CALL_MCOUNT \
52 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount ; lgr 14,0 ; \
53 .data ; .align 4 ; 0: .long 0 ; .text ;
54#endif
55#else
56#define CALL_MCOUNT /* Do nothing. */
57#endif
58
59/* Since C identifiers are not normally prefixed with an underscore
60 on this system, the asm identifier `syscall_error' intrudes on the
61 C name space. Make sure we use an innocuous name. */
62#define syscall_error __syscall_error
63#define mcount _mcount
64
65#undef PSEUDO
66#define PSEUDO(name, syscall_name, args) \
67lose: SYSCALL_PIC_SETUP \
68 jg JUMPTARGET(syscall_error); \
69 .globl syscall_error; \
70 ENTRY (name) \
71 DO_CALL (syscall_name, args); \
72 jm lose
73
74#undef PSEUDO_END
75#define PSEUDO_END(name) \
76 END (name)
77
78#undef JUMPTARGET
79#ifdef SHARED
80#define JUMPTARGET(name) name##@PLT
81#define SYSCALL_PIC_SETUP \
82 larl %r12,_GLOBAL_OFFSET_TABLE_
83#else
84#define JUMPTARGET(name) name
85#define SYSCALL_PIC_SETUP /* Nothing. */
86#endif
87
88/* Local label name for asm code. */
89#ifndef L
90#define L(name) .L##name
91#endif
92
93#endif /* __ASSEMBLER__ */
lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h+6-1
...@@ -155,7 +155,7 @@...@@ -155,7 +155,7 @@
155 similar to kernel:155 similar to kernel:
156156
157 - __ASSUME_CLONE_BACKWARDS: for variant 1.157 - __ASSUME_CLONE_BACKWARDS: for variant 1.
158 - __ASSUME_CLONE_BACKWARDS2: for variant 2 (s390).158 - __ASSUME_CLONE_BACKWARDS2: for variant 2 (s390x).
159 - __ASSUME_CLONE_BACKWARDS3: for variant 3 (microblaze).159 - __ASSUME_CLONE_BACKWARDS3: for variant 3 (microblaze).
160 - __ASSUME_CLONE_DEFAULT: for variant 4.160 - __ASSUME_CLONE_DEFAULT: for variant 4.
161 */161 */
...@@ -266,4 +266,9 @@...@@ -266,4 +266,9 @@
266/* zig patch: don't assume kernel version */266/* zig patch: don't assume kernel version */
267#define __ASSUME_MSEAL 0267#define __ASSUME_MSEAL 0
268268
269/* The PIDFD_GET_INFO ioctl was introduced across all architectures in Linux
270 6.13. */
271/* zig patch: don't assume kernel version */
272#define __ASSUME_PIDFD_GET_INFO 0
273
269#endif /* kernel-features.h */274#endif /* kernel-features.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/loongarch/sysdep.h+25-6
...@@ -19,6 +19,7 @@...@@ -19,6 +19,7 @@
19#ifndef _LINUX_LOONGARCH_SYSDEP_H19#ifndef _LINUX_LOONGARCH_SYSDEP_H
20#define _LINUX_LOONGARCH_SYSDEP_H 120#define _LINUX_LOONGARCH_SYSDEP_H 1
2121
22#include <sysdeps/loongarch/sysdep.h>
22#include <sysdeps/unix/sysv/linux/sysdep.h>23#include <sysdeps/unix/sysv/linux/sysdep.h>
23#include <sysdeps/unix/sysdep.h>24#include <sysdeps/unix/sysdep.h>
24#include <tls.h>25#include <tls.h>
...@@ -34,9 +35,9 @@...@@ -34,9 +35,9 @@
34#undef PSEUDO35#undef PSEUDO
35#define PSEUDO(name, syscall_name, args) \36#define PSEUDO(name, syscall_name, args) \
36 ENTRY (name); \37 ENTRY (name); \
37 li.d a7, SYS_ify (syscall_name); \38 LI a7, SYS_ify (syscall_name); \
38 syscall 0; \39 syscall 0; \
39 li.d a7, -4096; \40 LI a7, -4096; \
40 bltu a7, a0, .Lsyscall_error##name;41 bltu a7, a0, .Lsyscall_error##name;
4142
42#undef PSEUDO_END43#undef PSEUDO_END
...@@ -52,16 +53,16 @@...@@ -52,16 +53,16 @@
52 .Lsyscall_error##name : la t0, rtld_errno; \53 .Lsyscall_error##name : la t0, rtld_errno; \
53 sub.w a0, zero, a0; \54 sub.w a0, zero, a0; \
54 st.w a0, t0, 0; \55 st.w a0, t0, 0; \
55 li.d a0, -1;56 LI a0, -1;
5657
57#else58#else
5859
59#define SYSCALL_ERROR_HANDLER(name) \60#define SYSCALL_ERROR_HANDLER(name) \
60 .Lsyscall_error##name : la.tls.ie t0, errno; \61 .Lsyscall_error##name : la.tls.ie t0, errno; \
61 add.d t0, tp, t0; \62 ADD t0, tp, t0; \
62 sub.w a0, zero, a0; \63 sub.w a0, zero, a0; \
63 st.w a0, t0, 0; \64 st.w a0, t0, 0; \
64 li.d a0, -1;65 LI a0, -1;
6566
66#endif67#endif
67#else68#else
...@@ -74,7 +75,7 @@...@@ -74,7 +75,7 @@
74#undef PSEUDO_NEORRNO75#undef PSEUDO_NEORRNO
75#define PSEUDO_NOERRNO(name, syscall_name, args) \76#define PSEUDO_NOERRNO(name, syscall_name, args) \
76 ENTRY (name); \77 ENTRY (name); \
77 li.d a7, SYS_ify (syscall_name); \78 LI a7, SYS_ify (syscall_name); \
78 syscall 0;79 syscall 0;
7980
80#undef PSEUDO_END_NOERRNO81#undef PSEUDO_END_NOERRNO
...@@ -85,11 +86,17 @@...@@ -85,11 +86,17 @@
8586
86/* Performs a system call, returning the error code. */87/* Performs a system call, returning the error code. */
87#undef PSEUDO_ERRVAL88#undef PSEUDO_ERRVAL
89#if __loongarch_grlen == 64
88#define PSEUDO_ERRVAL(name, syscall_name, args) \90#define PSEUDO_ERRVAL(name, syscall_name, args) \
89 PSEUDO_NOERRNO (name, syscall_name, args); \91 PSEUDO_NOERRNO (name, syscall_name, args); \
90 slli.d a0, a0, 32; \92 slli.d a0, a0, 32; \
91 srai.d a0, a0, 32; /* sign_ext */ \93 srai.d a0, a0, 32; /* sign_ext */ \
92 sub.d a0, zero, a0;94 sub.d a0, zero, a0;
95#else
96#define PSEUDO_ERRVAL(name, syscall_name, args) \
97 PSEUDO_NOERRNO (name, syscall_name, args); \
98 sub.w a0, zero, a0;
99#endif
93100
94#undef PSEUDO_END_ERRVAL101#undef PSEUDO_END_ERRVAL
95#define PSEUDO_END_ERRVAL(name) END (name);102#define PSEUDO_END_ERRVAL(name) END (name);
...@@ -109,6 +116,18 @@...@@ -109,6 +116,18 @@
109#undef SYS_ify116#undef SYS_ify
110#define SYS_ify(syscall_name) __NR_##syscall_name117#define SYS_ify(syscall_name) __NR_##syscall_name
111118
119#if __WORDSIZE == 32
120/* Workarounds for generic code needing to handle 64-bit time_t. */
121#define __NR_clock_getres __NR_clock_getres_time64
122#define __NR_futex __NR_futex_time64
123#define __NR_ppoll __NR_ppoll_time64
124#define __NR_pselect6 __NR_pselect6_time64
125#define __NR_recvmmsg __NR_recvmmsg_time64
126#define __NR_rt_sigtimedwait __NR_rt_sigtimedwait_time64
127#define __NR_semtimedop __NR_semtimedop_time64
128#define __NR_utimensat __NR_utimensat_time64
129#endif /* __WORDSIZE == 32 */
130
112#ifndef __ASSEMBLER__131#ifndef __ASSEMBLER__
113132
114#define VDSO_NAME "LINUX_5.10"133#define VDSO_NAME "LINUX_5.10"
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h+14-22
...@@ -57,42 +57,34 @@...@@ -57,42 +57,34 @@
57#define __TIMER_T_TYPE void *57#define __TIMER_T_TYPE void *
58#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE58#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
59#define __FSID_T_TYPE struct { int __val[2]; }59#define __FSID_T_TYPE struct { int __val[2]; }
60#if defined __GNUC__ && __GNUC__ <= 260
61/* Compatibility with g++ 2.95.x. */61/* With s390-32, __SSIZE_T_TYPE was __SWORD_TYPE for compatibility with
62#define __SSIZE_T_TYPE __SWORD_TYPE62 g++ 2.95.x. Afterwards __SLONGWORD_TYPE was needed as size_t was
63#else63 unsigned long int on s390-32.
64/* size_t is unsigned long int on s390 -m31. */64 Now as only s390-64 exists, __SWORD_TYPE can be used as also used in the
65#define __SSIZE_T_TYPE __SLONGWORD_TYPE65 generic version as both types result in long int. */
66#endif66#define __SSIZE_T_TYPE __SWORD_TYPE
67
67#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE68#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
68#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE69#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
69#define __CPU_MASK_TYPE __ULONGWORD_TYPE70#define __CPU_MASK_TYPE __ULONGWORD_TYPE
7071
71#ifdef __s390x__
72/* Tell the libc code that off_t and off64_t are actually the same type72/* Tell the libc code that off_t and off64_t are actually the same type
73 for all ABI purposes, even if possibly expressed as different base types73 for all ABI purposes, even if possibly expressed as different base types
74 for C type-checking purposes. */74 for C type-checking purposes. */
75# define __OFF_T_MATCHES_OFF64_T 175#define __OFF_T_MATCHES_OFF64_T 1
7676
77/* Same for ino_t and ino64_t. */77/* Same for ino_t and ino64_t. */
78# define __INO_T_MATCHES_INO64_T 178#define __INO_T_MATCHES_INO64_T 1
7979
80/* And for __rlim_t and __rlim64_t. */80/* And for __rlim_t and __rlim64_t. */
81# define __RLIM_T_MATCHES_RLIM64_T 181#define __RLIM_T_MATCHES_RLIM64_T 1
8282
83/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */83/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
84# define __STATFS_MATCHES_STATFS64 184#define __STATFS_MATCHES_STATFS64 1
8585
86/* And for getitimer, setitimer and rusage */86/* And for getitimer, setitimer and rusage */
87# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 187#define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
88#else
89# define __RLIM_T_MATCHES_RLIM64_T 0
90
91# define __STATFS_MATCHES_STATFS64 0
92
93/* And for getitimer, setitimer and rusage */
94# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
95#endif
9688
97/* Number of descriptors that can fit in an `fd_set'. */89/* Number of descriptors that can fit in an `fd_set'. */
98#define __FD_SETSIZE 102490#define __FD_SETSIZE 1024
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/kernel-features.h-3
...@@ -47,9 +47,6 @@...@@ -47,9 +47,6 @@
47# undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS47# undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
48# undef __ASSUME_SYSVIPC_DEFAULT_IPC_6448# undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
49#endif49#endif
50#ifndef __s390x__
51# define __ASSUME_SYSVIPC_BROKEN_MODE_T
52#endif
5350
54#undef __ASSUME_CLONE_DEFAULT51#undef __ASSUME_CLONE_DEFAULT
55#define __ASSUME_CLONE_BACKWARDS252#define __ASSUME_CLONE_BACKWARDS2
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h deleted-178
...@@ -1,178 +0,0 @@
1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_S390_SYSDEP_H
20#define _LINUX_S390_SYSDEP_H
21
22#include <sysdeps/s390/s390-64/sysdep.h>
23#include <sysdeps/unix/sysdep.h>
24#include <sysdeps/unix/sysv/linux/s390/sysdep.h>
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
27#include <tls.h>
28
29/* For Linux we can use the system call table in the header file
30 /usr/include/asm/unistd.h
31 of the kernel. But these symbols do not follow the SYS_* syntax
32 so we have to redefine the `SYS_ify' macro here. */
33/* In newer 2.1 kernels __NR_syscall is missing so we define it here. */
34#define __NR_syscall 0
35
36#undef SYS_ify
37#define SYS_ify(syscall_name) __NR_##syscall_name
38
39#ifdef __ASSEMBLER__
40
41/* Linux uses a negative return value to indicate syscall errors, unlike
42 most Unices, which use the condition codes' carry flag.
43
44 Since version 2.1 the return value of a system call might be negative
45 even if the call succeeded. E.g., the `lseek' system call might return
46 a large offset. Therefore we must not anymore test for < 0, but test
47 for a real error by making sure the value in gpr2 is a real error
48 number. Linus said he will make sure that no syscall returns a value
49 in -1 .. -4095 as a valid result so we can safely test with -4095. */
50
51#undef PSEUDO
52#define PSEUDO(name, syscall_name, args) \
53 .text; \
54 ENTRY (name) \
55 DO_CALL (syscall_name, args); \
56 lghi %r4,-4095 ; \
57 clgr %r2,%r4 ; \
58 jgnl SYSCALL_ERROR_LABEL
59
60#undef PSEUDO_END
61#define PSEUDO_END(name) \
62 SYSCALL_ERROR_HANDLER; \
63 END (name)
64
65#undef PSEUDO_NOERRNO
66#define PSEUDO_NOERRNO(name, syscall_name, args) \
67 .text; \
68 ENTRY (name) \
69 DO_CALL (syscall_name, args)
70
71#undef PSEUDO_END_NOERRNO
72#define PSEUDO_END_NOERRNO(name) \
73 SYSCALL_ERROR_HANDLER; \
74 END (name)
75
76#undef PSEUDO_ERRVAL
77#define PSEUDO_ERRVAL(name, syscall_name, args) \
78 .text; \
79 ENTRY (name) \
80 DO_CALL (syscall_name, args); \
81 lcgr %r2,%r2
82
83#undef PSEUDO_END_ERRVAL
84#define PSEUDO_END_ERRVAL(name) \
85 SYSCALL_ERROR_HANDLER; \
86 END (name)
87
88#undef SYSCALL_ERROR_LABEL
89#ifndef PIC
90# undef SYSCALL_ERROR_LABEL
91# define SYSCALL_ERROR_LABEL syscall_error
92# define SYSCALL_ERROR_HANDLER
93#else
94# if RTLD_PRIVATE_ERRNO
95# undef SYSCALL_ERROR_LABEL
96# define SYSCALL_ERROR_LABEL 0f
97# define SYSCALL_ERROR_HANDLER \
980: larl %r1,rtld_errno; \
99 lcr %r2,%r2; \
100 st %r2,0(%r1); \
101 lghi %r2,-1; \
102 br %r14
103# elif defined _LIBC_REENTRANT
104# if IS_IN (libc)
105# define SYSCALL_ERROR_ERRNO __libc_errno
106# else
107# define SYSCALL_ERROR_ERRNO errno
108# endif
109# undef SYSCALL_ERROR_LABEL
110# define SYSCALL_ERROR_LABEL 0f
111# define SYSCALL_ERROR_HANDLER \
1120: lcr %r0,%r2; \
113 larl %r1,SYSCALL_ERROR_ERRNO@indntpoff; \
114 lg %r1,0(%r1); \
115 ear %r2,%a0; \
116 sllg %r2,%r2,32; \
117 ear %r2,%a1; \
118 st %r0,0(%r1,%r2); \
119 lghi %r2,-1; \
120 br %r14
121# else
122# undef SYSCALL_ERROR_LABEL
123# define SYSCALL_ERROR_LABEL 0f
124# define SYSCALL_ERROR_HANDLER \
1250: larl %r1,_GLOBAL_OFFSET_TABLE_; \
126 lg %r1,errno@GOT(%r1); \
127 lcr %r2,%r2; \
128 st %r2,0(%r1); \
129 lghi %r2,-1; \
130 br %r14
131# endif /* _LIBC_REENTRANT */
132#endif /* PIC */
133
134/* Linux takes system call arguments in registers:
135
136 syscall number 1 call-clobbered
137 arg 1 2 call-clobbered
138 arg 2 3 call-clobbered
139 arg 3 4 call-clobbered
140 arg 4 5 call-clobbered
141 arg 5 6 call-saved
142 arg 6 7 call-saved
143
144 (Of course a function with say 3 arguments does not have entries for
145 arguments 4 and 5.)
146 For system calls with 6 parameters a stack operation is required
147 to load the 6th parameter to register 7. Call saved register 7 is
148 moved to register 0 and back to avoid an additional stack frame.
149 */
150
151#define DO_CALL(syscall, args) \
152 .if args > 5; \
153 lgr %r0,%r7; \
154 lg %r7,160(%r15); \
155 .endif; \
156 lghi %r1,SYS_ify (syscall); \
157 svc 0; \
158 .if args > 5; \
159 lgr %r7,%r0; \
160 .endif
161
162#define ret \
163 br 14
164
165#define ret_NOERRNO \
166 br 14
167
168#define ret_ERRVAL \
169 br 14
170
171#else
172
173# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
174# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
175
176#endif /* __ASSEMBLER__ */
177
178#endif /* _LINUX_S390_SYSDEP_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/sysdep.h+186-37
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/* Syscall definitions, Linux s390 version.1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2019-2026 Free Software Foundation, Inc.2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.3 This file is part of the GNU C Library.
44
5 The GNU C Library is free software; you can redistribute it and/or5 The GNU C Library is free software; you can redistribute it and/or
...@@ -14,15 +14,163 @@...@@ -14,15 +14,163 @@
1414
15 You should have received a copy of the GNU Lesser General Public15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */17 <https://www.gnu.org/licenses/>. */
1818
19#ifndef __ASSEMBLY__19#ifndef _LINUX_S390_SYSDEP_H
20#define _LINUX_S390_SYSDEP_H
21
22#include <sysdeps/s390/sysdep.h>
23#include <sysdeps/unix/sysdep.h>
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
26#include <tls.h>
27
28/* For Linux we can use the system call table in the header file
29 /usr/include/asm/unistd.h
30 of the kernel. But these symbols do not follow the SYS_* syntax
31 so we have to redefine the `SYS_ify' macro here. */
32/* In newer 2.1 kernels __NR_syscall is missing so we define it here. */
33#define __NR_syscall 0
2034
21#undef SYS_ify35#undef SYS_ify
22#define SYS_ify(syscall_name) __NR_##syscall_name36#define SYS_ify(syscall_name) __NR_##syscall_name
2337
24#undef INTERNAL_SYSCALL_NCS38#ifdef __ASSEMBLER__
25#define INTERNAL_SYSCALL_NCS(no, nr, args...) \39
40/* Linux uses a negative return value to indicate syscall errors, unlike
41 most Unices, which use the condition codes' carry flag.
42
43 Since version 2.1 the return value of a system call might be negative
44 even if the call succeeded. E.g., the `lseek' system call might return
45 a large offset. Therefore we must not anymore test for < 0, but test
46 for a real error by making sure the value in gpr2 is a real error
47 number. Linus said he will make sure that no syscall returns a value
48 in -1 .. -4095 as a valid result so we can safely test with -4095. */
49
50# undef PSEUDO
51# define PSEUDO(name, syscall_name, args) \
52 .text; \
53 ENTRY (name) \
54 DO_CALL (syscall_name, args); \
55 lghi %r4,-4095 ; \
56 clgr %r2,%r4 ; \
57 jgnl SYSCALL_ERROR_LABEL
58
59# undef PSEUDO_END
60# define PSEUDO_END(name) \
61 SYSCALL_ERROR_HANDLER; \
62 END (name)
63
64# undef PSEUDO_NOERRNO
65# define PSEUDO_NOERRNO(name, syscall_name, args) \
66 .text; \
67 ENTRY (name) \
68 DO_CALL (syscall_name, args)
69
70# undef PSEUDO_END_NOERRNO
71# define PSEUDO_END_NOERRNO(name) \
72 SYSCALL_ERROR_HANDLER; \
73 END (name)
74
75# undef PSEUDO_ERRVAL
76# define PSEUDO_ERRVAL(name, syscall_name, args) \
77 .text; \
78 ENTRY (name) \
79 DO_CALL (syscall_name, args); \
80 lcgr %r2,%r2
81
82# undef PSEUDO_END_ERRVAL
83# define PSEUDO_END_ERRVAL(name) \
84 SYSCALL_ERROR_HANDLER; \
85 END (name)
86
87# undef SYSCALL_ERROR_LABEL
88# ifndef PIC
89# undef SYSCALL_ERROR_LABEL
90# define SYSCALL_ERROR_LABEL syscall_error
91# define SYSCALL_ERROR_HANDLER
92# else
93# if RTLD_PRIVATE_ERRNO
94# undef SYSCALL_ERROR_LABEL
95# define SYSCALL_ERROR_LABEL 0f
96# define SYSCALL_ERROR_HANDLER \
970: larl %r1,rtld_errno; \
98 lcr %r2,%r2; \
99 st %r2,0(%r1); \
100 lghi %r2,-1; \
101 br %r14
102# elif defined _LIBC_REENTRANT
103# if IS_IN (libc)
104# define SYSCALL_ERROR_ERRNO __libc_errno
105# else
106# define SYSCALL_ERROR_ERRNO errno
107# endif
108# undef SYSCALL_ERROR_LABEL
109# define SYSCALL_ERROR_LABEL 0f
110# define SYSCALL_ERROR_HANDLER \
1110: lcr %r0,%r2; \
112 larl %r1,SYSCALL_ERROR_ERRNO@indntpoff; \
113 lg %r1,0(%r1); \
114 ear %r2,%a0; \
115 sllg %r2,%r2,32; \
116 ear %r2,%a1; \
117 st %r0,0(%r1,%r2); \
118 lghi %r2,-1; \
119 br %r14
120# else
121# undef SYSCALL_ERROR_LABEL
122# define SYSCALL_ERROR_LABEL 0f
123# define SYSCALL_ERROR_HANDLER \
1240: larl %r1,_GLOBAL_OFFSET_TABLE_; \
125 lg %r1,errno@GOT(%r1); \
126 lcr %r2,%r2; \
127 st %r2,0(%r1); \
128 lghi %r2,-1; \
129 br %r14
130# endif /* _LIBC_REENTRANT */
131# endif /* PIC */
132
133/* Linux takes system call arguments in registers:
134
135 syscall number 1 call-clobbered
136 arg 1 2 call-clobbered
137 arg 2 3 call-clobbered
138 arg 3 4 call-clobbered
139 arg 4 5 call-clobbered
140 arg 5 6 call-saved
141 arg 6 7 call-saved
142
143 (Of course a function with say 3 arguments does not have entries for
144 arguments 4 and 5.)
145 For system calls with 6 parameters a stack operation is required
146 to load the 6th parameter to register 7. Call saved register 7 is
147 moved to register 0 and back to avoid an additional stack frame.
148 */
149
150# define DO_CALL(syscall, args) \
151 .if args > 5; \
152 lgr %r0,%r7; \
153 lg %r7,160(%r15); \
154 .endif; \
155 lghi %r1,SYS_ify (syscall); \
156 svc 0; \
157 .if args > 5; \
158 lgr %r7,%r0; \
159 .endif
160
161# define ret \
162 br 14
163
164# define ret_NOERRNO \
165 br 14
166
167# define ret_ERRVAL \
168 br 14
169
170#else /* not __ASSEMBLER__ */
171
172# undef INTERNAL_SYSCALL_NCS
173# define INTERNAL_SYSCALL_NCS(no, nr, args...) \
26 ({ \174 ({ \
27 DECLARGS_##nr(args) \175 DECLARGS_##nr(args) \
28 register unsigned long int _nr __asm__("1") = (unsigned long int)(no); \176 register unsigned long int _nr __asm__("1") = (unsigned long int)(no); \
...@@ -34,51 +182,52 @@...@@ -34,51 +182,52 @@
34 : "memory" ); \182 : "memory" ); \
35 _ret; })183 _ret; })
36184
37#undef INTERNAL_SYSCALL185# undef INTERNAL_SYSCALL
38#define INTERNAL_SYSCALL(name, nr, args...) \186# define INTERNAL_SYSCALL(name, nr, args...) \
39 INTERNAL_SYSCALL_NCS(__NR_##name, nr, args)187 INTERNAL_SYSCALL_NCS(__NR_##name, nr, args)
40188
41#define DECLARGS_0()189# define DECLARGS_0()
42#define DECLARGS_1(arg1) \190# define DECLARGS_1(arg1) \
43 register unsigned long int gpr2 __asm__ ("2") = (unsigned long int)(arg1);191 register unsigned long int gpr2 __asm__ ("2") = (unsigned long int)(arg1);
44#define DECLARGS_2(arg1, arg2) \192# define DECLARGS_2(arg1, arg2) \
45 DECLARGS_1(arg1) \193 DECLARGS_1(arg1) \
46 register unsigned long int gpr3 __asm__ ("3") = (unsigned long int)(arg2);194 register unsigned long int gpr3 __asm__ ("3") = (unsigned long int)(arg2);
47#define DECLARGS_3(arg1, arg2, arg3) \195# define DECLARGS_3(arg1, arg2, arg3) \
48 DECLARGS_2(arg1, arg2) \196 DECLARGS_2(arg1, arg2) \
49 register unsigned long int gpr4 __asm__ ("4") = (unsigned long int)(arg3);197 register unsigned long int gpr4 __asm__ ("4") = (unsigned long int)(arg3);
50#define DECLARGS_4(arg1, arg2, arg3, arg4) \198# define DECLARGS_4(arg1, arg2, arg3, arg4) \
51 DECLARGS_3(arg1, arg2, arg3) \199 DECLARGS_3(arg1, arg2, arg3) \
52 register unsigned long int gpr5 __asm__ ("5") = (unsigned long int)(arg4);200 register unsigned long int gpr5 __asm__ ("5") = (unsigned long int)(arg4);
53#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \201# define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
54 DECLARGS_4(arg1, arg2, arg3, arg4) \202 DECLARGS_4(arg1, arg2, arg3, arg4) \
55 register unsigned long int gpr6 __asm__ ("6") = (unsigned long int)(arg5);203 register unsigned long int gpr6 __asm__ ("6") = (unsigned long int)(arg5);
56#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \204# define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
57 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \205 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
58 register unsigned long int gpr7 __asm__ ("7") = (unsigned long int)(arg6);206 register unsigned long int gpr7 __asm__ ("7") = (unsigned long int)(arg6);
59207
60#define ASMFMT_0208# define ASMFMT_0
61#define ASMFMT_1 , "0" (gpr2)209# define ASMFMT_1 , "0" (gpr2)
62#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)210# define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
63#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)211# define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
64#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)212# define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
65#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)213# define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
66#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)214# define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
67215
68#define VDSO_NAME "LINUX_2.6.29"216# define VDSO_NAME "LINUX_2.6.29"
69#define VDSO_HASH 123718585217# define VDSO_HASH 123718585
70218
71/* List of system calls which are supported as vsyscalls. */219/* List of system calls which are supported as vsyscalls. */
72#ifdef __s390x__220# define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"
73#define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"221# define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime"
74#define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime"222# define HAVE_GETRANDOM_VSYSCALL "__kernel_getrandom"
75#define HAVE_GETRANDOM_VSYSCALL "__kernel_getrandom"223# define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday"
76#else224# define HAVE_GETCPU_VSYSCALL "__kernel_getcpu"
77#define HAVE_CLOCK_GETRES_VSYSCALL "__kernel_clock_getres"225
78#define HAVE_CLOCK_GETTIME_VSYSCALL "__kernel_clock_gettime"226# define HAVE_CLONE3_WRAPPER 1
79#endif227
80#define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday"228# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
81#define HAVE_GETCPU_VSYSCALL "__kernel_getcpu"229# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
82230
83#define HAVE_CLONE3_WRAPPER 1231#endif /* __ASSEMBLER__ */
84#endif232
233#endif /* _LINUX_S390_SYSDEP_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/xstatver.h+6-15
...@@ -1,19 +1,10 @@...@@ -1,19 +1,10 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */2 functions. */
33#define _STAT_VER_KERNEL 0
4#include <bits/wordsize.h>4#define _STAT_VER_LINUX 1
5
6#if __WORDSIZE == 64
7# define _STAT_VER_KERNEL 0
8# define _STAT_VER_LINUX 1
9# define _MKNOD_VER_LINUX 0
10#else
11# define _STAT_VER_LINUX_OLD 1
12# define _STAT_VER_KERNEL 1
13# define _STAT_VER_SVR4 2
14# define _STAT_VER_LINUX 3
15# define _MKNOD_VER_LINUX 1
16# define _MKNOD_VER_SVR4 2
17#endif
18#define _STAT_VER _STAT_VER_LINUX5#define _STAT_VER _STAT_VER_LINUX
6
7/* Versions of the 'xmknod' interface used in compatibility xmknod
8 functions. */
9#define _MKNOD_VER_LINUX 0
19#define _MKNOD_VER _MKNOD_VER_LINUX10#define _MKNOD_VER _MKNOD_VER_LINUX
src/libs/glibc.zig+1-3
...@@ -398,7 +398,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![...@@ -398,7 +398,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
398 try result.appendSlice("powerpc" ++ s ++ "powerpc32");398 try result.appendSlice("powerpc" ++ s ++ "powerpc32");
399 }399 }
400 } else if (arch == .s390x) {400 } else if (arch == .s390x) {
401 try result.appendSlice("s390" ++ s ++ "s390-64");401 try result.appendSlice("s390");
402 } else if (arch.isLoongArch()) {402 } else if (arch.isLoongArch()) {
403 try result.appendSlice("loongarch");403 try result.appendSlice("loongarch");
404 } else if (arch == .m68k) {404 } else if (arch == .m68k) {
...@@ -607,8 +607,6 @@ fn add_include_dirs_arch(...@@ -607,8 +607,6 @@ fn add_include_dirs_arch(
607 try args.append("-I");607 try args.append("-I");
608 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390", nptl }));608 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390", nptl }));
609 } else {609 } else {
610 try args.append("-I");
611 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" ++ s ++ "s390-64" }));
612 try args.append("-I");610 try args.append("-I");
613 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" }));611 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" }));
614 }612 }