Commit 21ff35590c
Changed files (21)
lib
libc
glibc
elf
include
signal
stdlib
sysdeps
time
lib/libc/glibc/bits/libc-header-start.h
@@ -44,23 +44,23 @@
/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__
macro. Most but not all symbols enabled by that macro in TS
- 18661-1 are enabled unconditionally in C2X. In C2X, the symbols in
+ 18661-1 are enabled unconditionally in C23. In C23, the symbols in
Annex F still require a new feature test macro
- __STDC_WANT_IEC_60559_EXT__ instead (C2X does not define
+ __STDC_WANT_IEC_60559_EXT__ instead (C23 does not define
__STDC_WANT_IEC_60559_BFP_EXT__), while a few features from TS
- 18661-1 are not included in C2X (and thus should depend on
- __STDC_WANT_IEC_60559_BFP_EXT__ even when C2X features are
+ 18661-1 are not included in C23 (and thus should depend on
+ __STDC_WANT_IEC_60559_BFP_EXT__ even when C23 features are
enabled).
__GLIBC_USE (IEC_60559_BFP_EXT) controls those features from TS
- 18661-1 not included in C2X.
+ 18661-1 not included in C23.
- __GLIBC_USE (IEC_60559_BFP_EXT_C2X) controls those features from TS
- 18661-1 that are also included in C2X (with no feature test macro
- required in C2X).
+ __GLIBC_USE (IEC_60559_BFP_EXT_C23) controls those features from TS
+ 18661-1 that are also included in C23 (with no feature test macro
+ required in C23).
__GLIBC_USE (IEC_60559_EXT) controls those features from TS 18661-1
- that are included in C2X but conditional on
+ that are included in C23 but conditional on
__STDC_WANT_IEC_60559_EXT__. (There are currently no features
conditional on __STDC_WANT_IEC_60559_EXT__ that are not in TS
18661-1.) */
@@ -70,11 +70,11 @@
#else
# define __GLIBC_USE_IEC_60559_BFP_EXT 0
#endif
-#undef __GLIBC_USE_IEC_60559_BFP_EXT_C2X
-#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X)
-# define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 1
+#undef __GLIBC_USE_IEC_60559_BFP_EXT_C23
+#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC23)
+# define __GLIBC_USE_IEC_60559_BFP_EXT_C23 1
#else
-# define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0
+# define __GLIBC_USE_IEC_60559_BFP_EXT_C23 0
#endif
#undef __GLIBC_USE_IEC_60559_EXT
#if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__
@@ -86,18 +86,18 @@
/* ISO/IEC TS 18661-4:2015 defines the
__STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction
functions, the symbols from this TS are enabled unconditionally in
- C2X. */
+ C23. */
#undef __GLIBC_USE_IEC_60559_FUNCS_EXT
#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__
# define __GLIBC_USE_IEC_60559_FUNCS_EXT 1
#else
# define __GLIBC_USE_IEC_60559_FUNCS_EXT 0
#endif
-#undef __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X
-#if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC2X)
-# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 1
+#undef __GLIBC_USE_IEC_60559_FUNCS_EXT_C23
+#if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC23)
+# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C23 1
#else
-# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0
+# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C23 0
#endif
/* ISO/IEC TS 18661-3:2015 defines the
lib/libc/glibc/elf/elf.h
@@ -831,6 +831,10 @@ typedef struct
control. */
#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* AArch64 pointer authentication
enabled keys. */
+#define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers. */
+#define NT_ARM_ZA 0x40c /* ARM SME ZA registers. */
+#define NT_ARM_ZT 0x40d /* ARM SME ZT registers. */
+#define NT_ARM_FPMR 0x40e /* ARM floating point mode register. */
#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
@@ -1234,6 +1238,10 @@ typedef struct
#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size. */
#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment. */
+/* More machine-dependent hints about processor capabilities. */
+#define AT_HWCAP3 29 /* extension of AT_HWCAP. */
+#define AT_HWCAP4 30 /* extension of AT_HWCAP. */
+
#define AT_EXECFN 31 /* Filename of executable. */
/* Pointer to the global system page used for system calls and other
@@ -1333,9 +1341,13 @@ typedef struct
#define NT_GNU_PROPERTY_TYPE_0 5
/* Packaging metadata as defined on
- https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
+ https://systemd.io/ELF_PACKAGE_METADATA/ */
#define NT_FDO_PACKAGING_METADATA 0xcafe1a7e
+/* dlopen metadata as defined on
+ https://systemd.io/ELF_DLOPEN_METADATA/ */
+#define NT_FDO_DLOPEN_METADATA 0x407c0c0a
+
/* Note section name of program property. */
#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
@@ -4237,6 +4249,8 @@ enum
#define R_LARCH_TLS_TPREL32 10
#define R_LARCH_TLS_TPREL64 11
#define R_LARCH_IRELATIVE 12
+#define R_LARCH_TLS_DESC32 13
+#define R_LARCH_TLS_DESC64 14
/* Reserved for future relocs that the dynamic linker must understand. */
@@ -4331,6 +4345,23 @@ enum
#define R_LARCH_ADD_ULEB128 107
#define R_LARCH_SUB_ULEB128 108
#define R_LARCH_64_PCREL 109
+#define R_LARCH_CALL36 110
+#define R_LARCH_TLS_DESC_PC_HI20 111
+#define R_LARCH_TLS_DESC_PC_LO12 112
+#define R_LARCH_TLS_DESC64_PC_LO20 113
+#define R_LARCH_TLS_DESC64_PC_HI12 114
+#define R_LARCH_TLS_DESC_HI20 115
+#define R_LARCH_TLS_DESC_LO12 116
+#define R_LARCH_TLS_DESC64_LO20 117
+#define R_LARCH_TLS_DESC64_HI12 118
+#define R_LARCH_TLS_DESC_LD 119
+#define R_LARCH_TLS_DESC_CALL 120
+#define R_LARCH_TLS_LE_HI20_R 121
+#define R_LARCH_TLS_LE_ADD_R 122
+#define R_LARCH_TLS_LE_LO12_R 123
+#define R_LARCH_TLS_LD_PCREL20_S2 124
+#define R_LARCH_TLS_GD_PCREL20_S2 125
+#define R_LARCH_TLS_DESC_PCREL20_S2 126
/* ARC specific declarations. */
lib/libc/glibc/include/libc-symbols.h
@@ -679,9 +679,9 @@ for linking")
#endif
/* Helper / base macros for indirect function symbols. */
-#define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \
+#define __ifunc_resolver(type_name, name, expr, init, classifier, ...) \
classifier inhibit_stack_protector \
- __typeof (type_name) *name##_ifunc (arg) \
+ __typeof (type_name) *name##_ifunc (__VA_ARGS__) \
{ \
init (); \
__typeof (type_name) *res = expr; \
@@ -689,13 +689,13 @@ for linking")
}
#ifdef HAVE_GCC_IFUNC
-# define __ifunc(type_name, name, expr, arg, init) \
+# define __ifunc_args(type_name, name, expr, init, ...) \
extern __typeof (type_name) name __attribute__ \
((ifunc (#name "_ifunc"))); \
- __ifunc_resolver (type_name, name, expr, arg, init, static)
+ __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__)
-# define __ifunc_hidden(type_name, name, expr, arg, init) \
- __ifunc (type_name, name, expr, arg, init)
+# define __ifunc_args_hidden(type_name, name, expr, init, ...) \
+ __ifunc_args (type_name, name, expr, init, __VA_ARGS__)
#else
/* Gcc does not support __attribute__ ((ifunc (...))). Use the old behaviour
as fallback. But keep in mind that the debug information for the ifunc
@@ -706,18 +706,24 @@ for linking")
different signatures. (Gcc support is disabled at least on a ppc64le
Ubuntu 14.04 system.) */
-# define __ifunc(type_name, name, expr, arg, init) \
+# define __ifunc_args(type_name, name, expr, init, ...) \
extern __typeof (type_name) name; \
- __typeof (type_name) *name##_ifunc (arg) __asm__ (#name); \
- __ifunc_resolver (type_name, name, expr, arg, init,) \
+ __typeof (type_name) *name##_ifunc (__VA_ARGS__) __asm__ (#name); \
+ __ifunc_resolver (type_name, name, expr, init, , __VA_ARGS__) \
__asm__ (".type " #name ", %gnu_indirect_function");
-# define __ifunc_hidden(type_name, name, expr, arg, init) \
+# define __ifunc_args_hidden(type_name, name, expr, init, ...) \
extern __typeof (type_name) __libc_##name; \
- __ifunc (type_name, __libc_##name, expr, arg, init) \
+ __ifunc (type_name, __libc_##name, expr, __VA_ARGS__, init) \
strong_alias (__libc_##name, name);
#endif /* !HAVE_GCC_IFUNC */
+#define __ifunc(type_name, name, expr, arg, init) \
+ __ifunc_args (type_name, name, expr, init, arg)
+
+#define __ifunc_hidden(type_name, name, expr, arg, init) \
+ __ifunc_args_hidden (type_name, name, expr, init, arg)
+
/* The following macros are used for indirect function symbols in libc.so.
First of all, you need to have the function prototyped somewhere,
say in foo.h:
lib/libc/glibc/include/stdlib.h
@@ -53,8 +53,8 @@ libc_hidden_proto (__isoc23_strtoul_l)
libc_hidden_proto (__isoc23_strtoll_l)
libc_hidden_proto (__isoc23_strtoull_l)
-#if __GLIBC_USE (C2X_STRTOL)
-/* Redirect internal uses of these functions to the C2X versions; the
+#if __GLIBC_USE (C23_STRTOL)
+/* Redirect internal uses of these functions to the C23 versions; the
redirection in the installed header does not work with
libc_hidden_proto. */
# undef strtol
lib/libc/glibc/io/sys/stat.h
@@ -209,7 +209,7 @@ extern int stat (const char *__restrict __file,
that file descriptor FD is open on and put them in BUF. */
extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
#else
-# ifdef __USE_TIME_BITS64
+# ifdef __USE_TIME64_REDIRECTS
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
struct stat *__restrict __buf),
@@ -236,7 +236,7 @@ extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
# endif
#endif
#ifdef __USE_LARGEFILE64
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int stat64 (const char *__restrict __file,
struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
@@ -265,7 +265,7 @@ extern int fstatat (int __fd, const char *__restrict __file,
struct stat *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
# else
-# ifdef __USE_TIME_BITS64
+# ifdef __USE_TIME64_REDIRECTS
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
struct stat *__restrict __buf,
@@ -287,7 +287,7 @@ extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
# endif
# ifdef __USE_LARGEFILE64
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int fstatat64 (int __fd, const char *__restrict __file,
struct stat64 *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
@@ -313,7 +313,7 @@ extern int __REDIRECT_NTH (fstatat64, (int __fd,
extern int lstat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
# else
-# ifdef __USE_TIME_BITS64
+# ifdef __USE_TIME64_REDIRECTS
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
(const char *__restrict __file,
@@ -334,7 +334,7 @@ extern int __REDIRECT_NTH (lstat,
# endif
# endif
# ifdef __USE_LARGEFILE64
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int lstat64 (const char *__restrict __file,
struct stat64 *__restrict __buf)
__THROW __nonnull ((1, 2));
@@ -427,7 +427,7 @@ extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
#endif
#ifdef __USE_ATFILE
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
/* Set file access and modification times relative to directory file
descriptor. */
extern int utimensat (int __fd, const char *__path,
@@ -447,7 +447,7 @@ extern int __REDIRECT_NTH (utimensat, (int fd, const char *__path,
#endif
#ifdef __USE_XOPEN2K8
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
/* Set file access and modification times of the file associated with FD. */
extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
lib/libc/glibc/io/fcntl.h
@@ -176,7 +176,7 @@ typedef __pid_t pid_t;
This function is a cancellation point and therefore not marked with
__THROW. */
-#ifndef __USE_TIME_BITS64
+#ifndef __USE_TIME64_REDIRECTS
# ifndef __USE_FILE_OFFSET64
extern int fcntl (int __fd, int __cmd, ...);
# else
@@ -189,7 +189,7 @@ extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
# ifdef __USE_LARGEFILE64
extern int fcntl64 (int __fd, int __cmd, ...);
# endif
-#else /* __USE_TIME_BITS64 */
+#else /* __USE_TIME64_REDIRECTS */
# ifdef __REDIRECT
extern int __REDIRECT_NTH (fcntl, (int __fd, int __request, ...),
__fcntl_time64);
@@ -344,8 +344,7 @@ extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
/* Define some inlines helping to catch common problems. */
-#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
- && defined __va_arg_pack_len
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
# include <bits/fcntl2.h>
#endif
lib/libc/glibc/misc/sys/cdefs.h
@@ -145,6 +145,14 @@
#endif
+/* The overloadable attribute was added on clang 2.6. */
+#if defined __clang_major__ \
+ && (__clang_major__ + (__clang_minor__ >= 6) > 2)
+# define __attribute_overloadable__ __attribute__((__overloadable__))
+#else
+# define __attribute_overloadable__
+#endif
+
/* Fortify support. */
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
@@ -187,27 +195,173 @@
__s, __osz)) \
&& !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
+/* To correctly instrument the fortify wrapper clang requires the
+ pass_object_size attribute, and the attribute has the restriction that the
+ argument needs to be 'const'. Furthermore, to make it usable with C
+ interfaces, clang provides the overload attribute, which provides a C++
+ like function overload support. The overloaded fortify wrapper with the
+ pass_object_size attribute has precedence over the default symbol.
+
+ Also, clang does not support __va_arg_pack, so variadic functions are
+ expanded to issue va_arg implementations. The error function must not have
+ bodies (address takes are expanded to nonfortified calls), and with
+ __fortify_function compiler might still create a body with the C++
+ mangling name (due to the overload attribute). In this case, the function
+ is defined with __fortify_function_error_function macro instead.
+
+ The argument size check is also done with a clang-only attribute,
+ __attribute__ ((__diagnose_if__ (...))), different than gcc which calls
+ symbol_chk_warn alias with uses __warnattr attribute.
+
+ The pass_object_size was added on clang 4.0, __diagnose_if__ on 5.0,
+ and pass_dynamic_object_size on 9.0. */
+#if defined __clang_major__ && __clang_major__ >= 5
+# define __fortify_use_clang 1
+
+# define __fortify_function_error_function static __attribute__((__unused__))
+
+# define __fortify_clang_pass_object_size_n(n) \
+ __attribute__ ((__pass_object_size__ (n)))
+# define __fortify_clang_pass_object_size0 \
+ __fortify_clang_pass_object_size_n (0)
+# define __fortify_clang_pass_object_size \
+ __fortify_clang_pass_object_size_n (__USE_FORTIFY_LEVEL > 1)
+
+# if __clang_major__ >= 9
+# define __fortify_clang_pass_dynamic_object_size_n(n) \
+ __attribute__ ((__pass_dynamic_object_size__ (n)))
+# define __fortify_clang_pass_dynamic_object_size0 \
+ __fortify_clang_pass_dynamic_object_size_n (0)
+# define __fortify_clang_pass_dynamic_object_size \
+ __fortify_clang_pass_dynamic_object_size_n (1)
+# else
+# define __fortify_clang_pass_dynamic_object_size_n(n)
+# define __fortify_clang_pass_dynamic_object_size0
+# define __fortify_clang_pass_dynamic_object_size
+# endif
+
+# define __fortify_clang_bos_static_lt_impl(bos_val, n, s) \
+ ((bos_val) != -1ULL && (n) > (bos_val) / (s))
+# define __fortify_clang_bos_static_lt2(__n, __e, __s) \
+ __fortify_clang_bos_static_lt_impl (__bos (__e), __n, __s)
+# define __fortify_clang_bos_static_lt(__n, __e) \
+ __fortify_clang_bos_static_lt2 (__n, __e, 1)
+# define __fortify_clang_bos0_static_lt2(__n, __e, __s) \
+ __fortify_clang_bos_static_lt_impl (__bos0 (__e), __n, __s)
+# define __fortify_clang_bos0_static_lt(__n, __e) \
+ __fortify_clang_bos0_static_lt2 (__n, __e, 1)
+
+# define __fortify_clang_bosn_args(bos_fn, n, buf, div, complaint) \
+ (__fortify_clang_bos_static_lt_impl (bos_fn (buf), n, div)), (complaint), \
+ "warning"
+
+# define __fortify_clang_warning(__c, __msg) \
+ __attribute__ ((__diagnose_if__ ((__c), (__msg), "warning")))
+# define __fortify_clang_error(__c, __msg) \
+ __attribute__ ((__diagnose_if__ ((__c), (__msg), "error")))
+# define __fortify_clang_warning_only_if_bos0_lt(n, buf, complaint) \
+ __attribute__ ((__diagnose_if__ \
+ (__fortify_clang_bosn_args (__bos0, n, buf, 1, complaint))))
+# define __fortify_clang_warning_only_if_bos0_lt2(n, buf, div, complaint) \
+ __attribute__ ((__diagnose_if__ \
+ (__fortify_clang_bosn_args (__bos0, n, buf, div, complaint))))
+# define __fortify_clang_warning_only_if_bos_lt(n, buf, complaint) \
+ __attribute__ ((__diagnose_if__ \
+ (__fortify_clang_bosn_args (__bos, n, buf, 1, complaint))))
+# define __fortify_clang_warning_only_if_bos_lt2(n, buf, div, complaint) \
+ __attribute__ ((__diagnose_if__ \
+ (__fortify_clang_bosn_args (__bos, n, buf, div, complaint))))
+
+# define __fortify_clang_prefer_this_overload \
+ __attribute__ ((enable_if (1, "")))
+# define __fortify_clang_unavailable(__msg) \
+ __attribute__ ((unavailable(__msg)))
+
+# if __USE_FORTIFY_LEVEL == 3
+# define __fortify_clang_overload_arg(__type, __attr, __name) \
+ __type __attr const __fortify_clang_pass_dynamic_object_size __name
+# define __fortify_clang_overload_arg0(__type, __attr, __name) \
+ __type __attr const __fortify_clang_pass_dynamic_object_size0 __name
+# else
+# define __fortify_clang_overload_arg(__type, __attr, __name) \
+ __type __attr const __fortify_clang_pass_object_size __name
+# define __fortify_clang_overload_arg0(__type, __attr, __name) \
+ __type __attr const __fortify_clang_pass_object_size0 __name
+# endif
+
+# define __fortify_clang_mul_may_overflow(size, n) \
+ ((size | n) >= (((size_t)1) << (8 * sizeof (size_t) / 2)))
+
+# define __fortify_clang_size_too_small(__bos, __dest, __len) \
+ (__bos (__dest) != (size_t) -1 && __bos (__dest) < __len)
+# define __fortify_clang_warn_if_src_too_large(__dest, __src) \
+ __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize, \
+ __dest, \
+ __builtin_strlen (__src) + 1), \
+ "destination buffer will always be overflown by source")
+# define __fortify_clang_warn_if_dest_too_small(__dest, __len) \
+ __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize, \
+ __dest, \
+ __len), \
+ "function called with bigger length than the destination buffer")
+# define __fortify_clang_warn_if_dest_too_small0(__dest, __len) \
+ __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize0, \
+ __dest, \
+ __len), \
+ "function called with bigger length than the destination buffer")
+#else
+# define __fortify_use_clang 0
+# define __fortify_clang_warning(__c, __msg)
+# define __fortify_clang_warning_only_if_bos0_lt(__n, __buf, __complaint)
+# define __fortify_clang_warning_only_if_bos0_lt2(__n, __buf, __div, complaint)
+# define __fortify_clang_warning_only_if_bos_lt(__n, __buf, __complaint)
+# define __fortify_clang_warning_only_if_bos_lt2(__n, __buf, div, __complaint)
+# define __fortify_clang_overload_arg(__type, __attr, __name) \
+ __type __attr __name
+# define __fortify_clang_overload_arg0(__type, __attr, __name) \
+ __fortify_clang_overload_arg (__type, __attr, __name)
+# define __fortify_clang_warn_if_src_too_large(__dest, __src)
+# define __fortify_clang_warn_if_dest_too_small(__dest, __len)
+# define __fortify_clang_warn_if_dest_too_small0(__dest, __len)
+#endif
+
+
/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
declared. */
-#define __glibc_fortify(f, __l, __s, __osz, ...) \
+#if !__fortify_use_clang
+# define __glibc_fortify(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
: __ ## f ## _chk (__VA_ARGS__, __osz)))
+#else
+# define __glibc_fortify(f, __l, __s, __osz, ...) \
+ (__osz == (__SIZE_TYPE__) -1) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : __ ## f ## _chk (__VA_ARGS__, __osz)
+#endif
/* Fortify function f, where object size argument passed to f is the number of
elements and not total size. */
-#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
+#if !__fortify_use_clang
+# define __glibc_fortify_n(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
: __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
+# else
+# define __glibc_fortify_n(f, __l, __s, __osz, ...) \
+ (__osz == (__SIZE_TYPE__) -1) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))
#endif
+#endif /* __USE_FORTIFY_LEVEL > 0 */
+
#if __GNUC_PREREQ (4,3)
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
@@ -683,10 +837,10 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
# define __attr_access(x) __attribute__ ((__access__ x))
/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
use the access attribute to get object sizes from function definition
- arguments, so we can't use them on functions we fortify. Drop the object
- size hints for such functions. */
+ arguments, so we can't use them on functions we fortify. Drop the access
+ attribute for such functions. */
# if __USE_FORTIFY_LEVEL == 3
-# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
+# define __fortified_attr_access(a, o, s)
# else
# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
# endif
@@ -720,4 +874,13 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
# define __attribute_returns_twice__ /* Ignore. */
#endif
+/* Mark struct types as aliasable. Restricted to compilers that
+ support forward declarations of structs in the presence of the
+ attribute. */
+#if __GNUC_PREREQ (7, 1) || defined __clang__
+# define __attribute_struct_may_alias__ __attribute__ ((__may_alias__))
+#else
+# define __attribute_struct_may_alias__
+#endif
+
#endif /* sys/cdefs.h */
lib/libc/glibc/misc/sys/select.h
@@ -98,7 +98,7 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
-#ifndef __USE_TIME_BITS64
+#ifndef __USE_TIME64_REDIRECTS
extern int select (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
@@ -123,7 +123,7 @@ extern int __REDIRECT (select,
This function is a cancellation point and therefore not marked with
__THROW. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pselect (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
lib/libc/glibc/signal/signal.h
@@ -269,7 +269,7 @@ extern int sigwaitinfo (const sigset_t *__restrict __set,
This function is a cancellation point and therefore not marked with
__THROW. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int sigtimedwait (const sigset_t *__restrict __set,
siginfo_t *__restrict __info,
const struct timespec *__restrict __timeout)
lib/libc/glibc/stdlib/stdlib.h
@@ -210,7 +210,7 @@ extern unsigned long long int strtoull (const char *__restrict __nptr,
/* Versions of the above functions that handle '0b' and '0B' prefixes
in base 0 or 2. */
-#if __GLIBC_USE (C2X_STRTOL)
+#if __GLIBC_USE (C23_STRTOL)
# ifdef __REDIRECT
extern long int __REDIRECT_NTH (strtol, (const char *__restrict __nptr,
char **__restrict __endptr,
@@ -274,7 +274,7 @@ extern unsigned long long int __isoc23_strtoull (const char *__restrict __nptr,
#endif
/* Convert a floating-point number to a string. */
-#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
+#if __GLIBC_USE (IEC_60559_BFP_EXT_C23)
extern int strfromd (char *__dest, size_t __size, const char *__format,
double __f)
__THROW __nonnull ((3));
@@ -360,7 +360,7 @@ extern unsigned long long int strtoull_l (const char *__restrict __nptr,
/* Versions of the above functions that handle '0b' and '0B' prefixes
in base 0 or 2. */
-# if __GLIBC_USE (C2X_STRTOL)
+# if __GLIBC_USE (C23_STRTOL)
# ifdef __REDIRECT
extern long int __REDIRECT_NTH (strtol_l, (const char *__restrict __nptr,
char **__restrict __endptr,
lib/libc/glibc/sysdeps/htl/pthread.h
@@ -891,6 +891,17 @@ extern int pthread_setschedparam (pthread_t __thr, int __policy,
/* Set thread THREAD's scheduling priority. */
extern int pthread_setschedprio (pthread_t __thr, int __prio) __THROW;
+#ifdef __USE_GNU
+/* Get thread name visible in the kernel and its interfaces. */
+extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
+ size_t __buflen)
+ __THROW __nonnull ((2)) __attr_access ((__write_only__, 2));
+
+/* Set thread name visible in the kernel and its interfaces. */
+extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
+ __THROW __nonnull ((2)) __attr_access ((__read_only__, 2));
+#endif
+
#ifdef __USE_GNU
/* Yield the processor to another thread or process.
This function is similar to the POSIX `sched_yield' function but
lib/libc/glibc/sysdeps/nptl/pthread.h
@@ -223,7 +223,7 @@ extern int pthread_join (pthread_t __th, void **__thread_return);
the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
/* Make calling thread wait for termination of the thread TH, but only
until TIMEOUT. The exit status of the thread is stored in
*THREAD_RETURN, if THREAD_RETURN is not NULL.
@@ -796,7 +796,7 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
#ifdef __USE_XOPEN2K
/* Wait until lock becomes available, or specified time passes. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -813,7 +813,7 @@ extern int __REDIRECT_NTHNL (pthread_mutex_timedlock,
#endif
#ifdef __USE_GNU
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
clockid_t __clockid,
const struct timespec *__restrict
@@ -982,7 +982,7 @@ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
# ifdef __USE_XOPEN2K
/* Try to acquire read lock for RWLOCK or return after specified time. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -1000,7 +1000,7 @@ extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock,
# endif
# ifdef __USE_GNU
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
clockid_t __clockid,
const struct timespec *__restrict
@@ -1029,7 +1029,7 @@ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
# ifdef __USE_XOPEN2K
/* Try to acquire write lock for RWLOCK or return after specified time. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -1047,7 +1047,7 @@ extern int __REDIRECT_NTHNL (pthread_rwlock_timedwrlock,
# endif
# ifdef __USE_GNU
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
clockid_t __clockid,
const struct timespec *__restrict
@@ -1141,7 +1141,7 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
This function is a cancellation point and therefore not marked with
__THROW. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
const struct timespec *__restrict __abstime)
@@ -1167,7 +1167,7 @@ extern int __REDIRECT (pthread_cond_timedwait,
This function is a cancellation point and therefore not marked with
__THROW. */
-# ifndef __USE_TIME_BITS64
+# ifndef __USE_TIME64_REDIRECTS
extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
__clockid_t __clock_id,
lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h
@@ -25,7 +25,7 @@
struct timex
{
-# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32)
+# if defined __USE_TIME64_REDIRECTS || (__TIMESIZE == 64 && __WORDSIZE == 32)
unsigned int modes; /* mode selector */
int :32; /* pad */
long long offset; /* time offset (usec) */
lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -468,6 +468,15 @@ L(pre_end): ASM_LINE_SEP \
#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
+#define VDSO_NAME "LINUX_6.11"
+#define VDSO_HASH 182951793
+
+#ifdef __LP64__
+# define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime"
+#else
+# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime64"
+#endif /* __LP64__ */
+
#endif /* __ASSEMBLER__ */
#endif /* _LINUX_HPPA_SYSDEP_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -156,6 +156,7 @@
/* List of system calls which are supported as vsyscalls (for RV32 and
RV64). */
# define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
+# define HAVE_RISCV_HWPROBE "__vdso_riscv_hwprobe"
# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
lib/libc/glibc/sysdeps/unix/sysv/linux/sys/timex.h
@@ -54,7 +54,7 @@ struct ntptimeval
__BEGIN_DECLS
-#ifndef __USE_TIME_BITS64
+#ifndef __USE_TIME64_REDIRECTS
extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW __nonnull ((1));
lib/libc/glibc/sysdeps/x86/bits/wordsize.h
@@ -8,10 +8,9 @@
#define __WORDSIZE32_PTRDIFF_LONG 0
#endif
+#define __WORDSIZE_TIME64_COMPAT32 1
+
#ifdef __x86_64__
-# define __WORDSIZE_TIME64_COMPAT32 1
/* Both x86-64 and x32 use the 64-bit system call interface. */
# define __SYSCALL_WORDSIZE 64
-#else
-# define __WORDSIZE_TIME64_COMPAT32 0
#endif
lib/libc/glibc/sysdeps/x86/sysdep.h
@@ -21,14 +21,118 @@
#include <sysdeps/generic/sysdep.h>
+/* The extended state feature IDs in the state component bitmap. */
+#define X86_XSTATE_X87_ID 0
+#define X86_XSTATE_SSE_ID 1
+#define X86_XSTATE_AVX_ID 2
+#define X86_XSTATE_BNDREGS_ID 3
+#define X86_XSTATE_BNDCFG_ID 4
+#define X86_XSTATE_K_ID 5
+#define X86_XSTATE_ZMM_H_ID 6
+#define X86_XSTATE_ZMM_ID 7
+#define X86_XSTATE_PKRU_ID 9
+#define X86_XSTATE_TILECFG_ID 17
+#define X86_XSTATE_TILEDATA_ID 18
+#define X86_XSTATE_APX_F_ID 19
+
+#ifdef __x86_64__
/* Offset for fxsave/xsave area used by _dl_runtime_resolve. Also need
space to preserve RCX, RDX, RSI, RDI, R8, R9 and RAX. It must be
- aligned to 16 bytes for fxsave and 64 bytes for xsave. */
-#define STATE_SAVE_OFFSET (8 * 7 + 8)
+ aligned to 16 bytes for fxsave and 64 bytes for xsave. It is non-zero
+ because MOV, instead of PUSH, is used to save registers onto stack.
+
+ +==================+<- stack frame start aligned at 8 or 16 bytes
+ | |<- paddings for stack realignment of 64 bytes
+ |------------------|<- xsave buffer end aligned at 64 bytes
+ | |<-
+ | |<-
+ | |<-
+ |------------------|<- xsave buffer start at STATE_SAVE_OFFSET(%rsp)
+ | |<- 8-byte padding for 64-byte alignment
+ | |<- R9
+ | |<- R8
+ | |<- RDI
+ | |<- RSI
+ | |<- RDX
+ | |<- RCX
+ | |<- RAX
+ +==================+<- RSP aligned at 64 bytes
+
+ */
+# define STATE_SAVE_OFFSET (8 * 7 + 8)
+
+/* _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning
+ stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 and
+ R11. Allocate space for RDI, RSI and RBX to avoid clobbering saved
+ RDI, RSI and RBX values on stack by xsave.
+
+ +==================+<- stack frame start aligned at 8 or 16 bytes
+ | |<- RDI saved in the red zone
+ | |<- RSI saved in the red zone
+ | |<- RBX saved in the red zone
+ | |<- paddings for stack realignment of 64 bytes
+ |------------------|<- xsave buffer end aligned at 64 bytes
+ | |<-
+ | |<-
+ | |<-
+ |------------------|<- xsave buffer start at STATE_SAVE_OFFSET(%rsp)
+ | |<- 8-byte padding for 64-byte alignment
+ | |<- 8-byte padding for 64-byte alignment
+ | |<- R11
+ | |<- R10
+ | |<- R9
+ | |<- R8
+ | |<- RDX
+ | |<- RCX
+ +==================+<- RSP aligned at 64 bytes
+
+ Define the total register save area size for all integer registers by
+ adding 24 to STATE_SAVE_OFFSET since RDI, RSI and RBX are saved onto
+ stack without adjusting stack pointer first, using the red-zone. */
+# define TLSDESC_CALL_REGISTER_SAVE_AREA (STATE_SAVE_OFFSET + 24)
+
+/* Save SSE, AVX, AVX512, mask, bound and APX registers. Bound and APX
+ registers are mutually exclusive. */
+# define STATE_SAVE_MASK \
+ ((1 << X86_XSTATE_SSE_ID) \
+ | (1 << X86_XSTATE_AVX_ID) \
+ | (1 << X86_XSTATE_BNDREGS_ID) \
+ | (1 << X86_XSTATE_K_ID) \
+ | (1 << X86_XSTATE_ZMM_H_ID) \
+ | (1 << X86_XSTATE_ZMM_ID) \
+ | (1 << X86_XSTATE_APX_F_ID))
+
+/* AMX state mask. */
+# define AMX_STATE_SAVE_MASK \
+ ((1 << X86_XSTATE_TILECFG_ID) | (1 << X86_XSTATE_TILEDATA_ID))
+
+/* States to be included in xsave_state_full_size. */
+# define FULL_STATE_SAVE_MASK \
+ (STATE_SAVE_MASK | AMX_STATE_SAVE_MASK)
+#else
+/* Offset for fxsave/xsave area used by _dl_tlsdesc_dynamic. Since i386
+ uses PUSH to save registers onto stack, use 0 here. */
+# define STATE_SAVE_OFFSET 0
+# define TLSDESC_CALL_REGISTER_SAVE_AREA 0
+
+/* Save SSE, AVX, AXV512, mask and bound registers. */
+# define STATE_SAVE_MASK \
+ ((1 << X86_XSTATE_SSE_ID) \
+ | (1 << X86_XSTATE_AVX_ID) \
+ | (1 << X86_XSTATE_BNDREGS_ID) \
+ | (1 << X86_XSTATE_K_ID) \
+ | (1 << X86_XSTATE_ZMM_H_ID))
+
+/* States to be included in xsave_state_size. */
+# define FULL_STATE_SAVE_MASK STATE_SAVE_MASK
+#endif
-/* Save SSE, AVX, AVX512, mask and bound registers. */
-#define STATE_SAVE_MASK \
- ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | (1 << 7))
+/* States which should be saved for TLSDESC_CALL and TLS_DESC_CALL.
+ Compiler assumes that all registers, including AMX and x87 FPU
+ stack registers, are unchanged after CALL, except for EFLAGS and
+ RAX/EAX. */
+#define TLSDESC_CALL_STATE_SAVE_MASK \
+ (FULL_STATE_SAVE_MASK | (1 << X86_XSTATE_X87_ID))
/* Constants for bits in __x86_string_control: */
lib/libc/glibc/time/bits/types/struct_timespec.h
@@ -10,14 +10,14 @@
has nanoseconds instead of microseconds. */
struct timespec
{
-#ifdef __USE_TIME_BITS64
+#ifdef __USE_TIME64_REDIRECTS
__time64_t tv_sec; /* Seconds. */
#else
__time_t tv_sec; /* Seconds. */
#endif
#if __WORDSIZE == 64 \
|| (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
- || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
+ || (__TIMESIZE == 32 && !defined __USE_TIME64_REDIRECTS)
__syscall_slong_t tv_nsec; /* Nanoseconds. */
#else
# if __BYTE_ORDER == __BIG_ENDIAN
lib/libc/glibc/time/bits/types/struct_timeval.h
@@ -7,7 +7,7 @@
microsecond but also has a range of years. */
struct timeval
{
-#ifdef __USE_TIME_BITS64
+#ifdef __USE_TIME64_REDIRECTS
__time64_t tv_sec; /* Seconds. */
__suseconds64_t tv_usec; /* Microseconds. */
#else
lib/libc/glibc/time/bits/types/time_t.h
@@ -4,7 +4,7 @@
#include <bits/types.h>
/* Returned by `time'. */
-#ifdef __USE_TIME_BITS64
+#ifdef __USE_TIME64_REDIRECTS
typedef __time64_t time_t;
#else
typedef __time_t time_t;