Commit graph

41902 commits

Author SHA1 Message Date
Luna Lamb
aa6609feb2 AArch64: Improve codegen in SVE tans
Improves memory access.
Tan: MOVPRFX 7 -> 2, LD1RD 12 -> 5, move MOV away from return.
Tanf: MOV 2 -> 1, MOVPRFX 6 -> 3, LD1RW 5 -> 4, move mov away from return.
2025-01-03 21:39:56 +00:00
Luna Lamb
140b985e5a AArch64: Improve codegen in AdvSIMD asinh
Improves memory access and removes spills.
Load the polynomial evaluation coefficients into 2 vectors and use lanewise
MLAs.  Reduces MOVs 6->3 , LDR 11->5, STR/STP 2->0, ADRP 3->2.
2025-01-03 21:39:56 +00:00
H.J. Lu
bb4f241dba math: Add a reference to Clang's <tgmath.h> C23 issue
Clang's <tgmath.h> doesn't support all C23 functions in glibc's <tgmath.h>:

https://github.com/llvm/llvm-project/issues/121536

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-04 04:52:00 +08:00
H.J. Lu
1294926da3 Rename have-mtls-descriptor to have-test-mtls-descriptor
Since have-mtls-descriptor is only used for glibc testing, rename it to
have-test-mtls-descriptor.  Also enable tst-gnu2-tls2-amx only if
$(have-test-mtls-descriptor) == gnu2.

Tested with GCC 14 and Clang 19/18/17 on x86-64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-04 04:51:21 +08:00
Andreas K. Hüttel
3674004f3f
math: update powerpc ulps
Linux timberdoodle 6.1.60-gentoo-dist-hardened #1 SMP Fri Dec  1 22:10:49 UTC 2023 ppc64 POWER9 (architected), altivec supported CHRP IBM pSeries (emulated by qemu) GNU/Linux

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-03 19:34:53 +01:00
Andreas K. Hüttel
59b9c2b0ef
math: update sparc ulps
Linux catbus 6.1.112 #1 SMP Sun Oct 13 10:52:08 PDT 2024 sparc64 sun4v UltraSparc T5 (Niagara5) GNU/Linux

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-03 15:40:06 +01:00
Andreas K. Hüttel
e71b548fac
math: update s390 ulps
Linux lgentoo4 6.8.9-gentoo #1 SMP Tue May  7 09:52:48 EDT 2024 s390x 8561 IBM GNU/Linux

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-03 15:36:56 +01:00
Adhemerval Zanella
8ed53717c4 conform: Do not use __SIG_ATOMIC_TYPE__
clang does not define __SIG_ATOMIC_TYPE__, instead add another
directive ('size:') which instruct to use an integer type of
defined minimum size.

Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03 09:53:53 -03:00
H.J. Lu
e9eea05986 Redirect mempcpy and stpcpy only in libc.a
The mempcpy and stpcpy redirections to __mempcpy and __stpcpy were added
by

commit 939da41143
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Nov 12 22:36:34 2014 +0000

    Fix stpcpy / mempcpy namespace (bug 17573).

to fix the namespace bug since __mempcpy and __stpcpy were defined as
macros in <bits/string2.h>.  These macros call __builtin_mempcpy and
__builtin_stpcpy which may end up calling the C functions mempcpy
and stpcpy.  In libc.so, libc_hidden_builtin_proto ensures that calls
to mempcpy and stpcpy are in turn mapped to call __GI_mempcpy and
__GI_stpcpy.  The redirections were applied outside of libc.so, including
libc.a, to map mempcpy and stpcpy to __mempcpy and __stpcpy.  Since

commit 18b10de7ce
Author: Wilco Dijkstra <wdijkstr@arm.com>
Date:   Mon Jun 12 15:19:38 2017 +0100

    2017-06-12  Wilco Dijkstra  <wdijkstr@arm.com>

    There is no longer a need for string2.h, so remove it and all mention of it.
    Move the redirect for __stpcpy to include/string.h since it is
still required
    until all internal uses have been renamed.
    This fixes several linknamespace/localplt failures when building with -Os.

removed the __mempcpy and __stpcpy macros from the public header file,
limit these redirections to libc.a to avoid Clang error:

In file included from tst-iconv-sticky-input-error.c:22:
In file included from ./gconv_int.h:24:
../include/string.h:182:44: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
  182 | extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
      |                                            ^
../string/bits/string_fortified.h:42:8: note: previous definition is here
   42 | __NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
      |        ^

when testing with Clang for fortify build.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03 05:30:44 +08:00
H.J. Lu
ed97ef7a4b not-cancel.h: Support testing fortify build with Clang
When Clang is used to test fortify glibc build configured with

--enable-fortify-source=N

clang issues errors like

In file included from tst-rfc3484.c:60:
In file included from ./getaddrinfo.c:81:
../sysdeps/unix/sysv/linux/not-cancel.h:36:10: error: reference to overloaded function could not be resolved; did you mean to call it?
   36 | __typeof (open64) __open64_nocancel;
      |          ^~~~~~~~
../include/bits/../../io/bits/fcntl2.h:127:1: note: possible target for call
  127 | open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag,
      | ^
../include/bits/../../io/bits/fcntl2.h:118:1: note: possible target for call
  118 | open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
      | ^
../include/bits/../../io/bits/fcntl2.h:114:1: note: possible target for call
  114 | open64 (const char *__path, int __oflag, mode_t __mode, ...)
      | ^
../io/fcntl.h:219:12: note: possible target for call
  219 | extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
      |            ^

because clang fortify support for functions with variable arguments relies
on function overload.  Update not-cancel.h to avoid __typeof on functions
with variable arguments.

Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03 04:56:48 +08:00
H.J. Lu
dbc9a40007 tst-unique[34].cc: Use explicit instantiation declaration/definition
Use explicit instantiation declaration and definition to silence Clang
error:

tst-unique3.cc:6:18: error: instantiation of variable 'S<char>::i' required here, but no definition is available [-Werror,-Wundefined-var-template]
    6 | int t = S<char>::i;
      |                  ^
./tst-unique3.h:5:14: note: forward declaration of template entity is here
    5 |   static int i;
      |              ^
tst-unique3.cc:6:18: note: add an explicit instantiation declaration to suppress this warning if 'S<char>::i' is explicitly instantiated in another translation unit
    6 | int t = S<char>::i;
      |                  ^

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03 04:54:44 +08:00
Aurelien Jarno
d4b16e22e7
RISC-V: Regenerate ULPs
Generated on a VisionFive 2 board running Linux version 6.12.6 and
GCC 14.2.0.

Needed due to:
- commit bbd578b38d ("math: Use expm1f from CORE-MATH")
- commit 8ae9e51376 ("math: Use log1pf from CORE-MATH")
- commit 0ae0af68d8 ("Implement C23 cospi")
- commit 776938e8b8 ("Implement C23 sinpi")
- commit f9e90e4b4c ("Implement C23 tanpi")
- commit 28d102d15c ("Implement C23 acospi")
- commit f962932206 ("Implement C23 asinpi")
- commit ffe79c446c ("Implement C23 atanpi")
- commit 3374de9038 ("Implement C23 atan2pi")
- commit a357d6273f ("math: Use atanf from CORE-MATH")
- commit 6f9bacf36b ("math: Use atan2f from CORE-MATH")
- commit e5ca265a9c ("new inputs with large errors for [a]cospi,
  [a]sinpi, [a]tanpi, atan2pi")

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2025-01-02 20:46:24 +01:00
Sam James
e9be7701e6
mlock, mlock2, munlock: Use __attr_access_none macro
This fixes build failures using GCC 7.5.0 against glibc headers,
see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118194#c5.

Followup to 013106ae67.

Reported-by: vvinayag@arm.com
2025-01-02 17:58:06 +00:00
Wilco Dijkstra
0ab62fa4f6 AArch64: Update libm-test-ulps
Update ulps for (a)cospi, (a)sinpi, (a)tanpi, atan2pi.
2025-01-02 17:53:07 +00:00
Paul Zimmermann
e5ca265a9c new inputs with large errors for [a]cospi, [a]sinpi, [a]tanpi, atan2pi
These inputs were generated with the programs from
https://gitlab.inria.fr/zimmerma/math_accuracy,
with rounding to nearest:

* for univariate binary32 functions by exhaustive search
* for other functions with the "threshold" parameter up to 10^6
2025-01-02 18:26:36 +01:00
Sam James
6d556522c3
stdlib: fix lint failure
Fixes: d5bceac99d
2025-01-02 17:09:24 +00:00
Sam James
d5bceac99d
stdlib: random_r: fix unaligned access in initstate and initstate_r [BZ #30584]
The initstate{,_r} interfaces are documented in BSD as needing an aligned
array of 32-bit values, but neither POSIX nor glibc's own documentation
require it to be aligned. glibc's documentation says it "should" be a power
of 2, but not must.

Use memcpy to read and write to `state` to handle such an unaligned
argument.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-02 16:47:51 +00:00
Adhemerval Zanella
6f0ea84f17 assert: Remove the use of %n from __assert_fail_base (BZ #32456)
The require size for mmap can be inferred from __vasprintf return
value.  It also fixes tst-assert-2 when building with --enable-fortify,
where even if the format is not translated, __readonly_area fails
because malloc can not be used.

Checked on aarch64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-02 10:19:42 -03:00
Adhemerval Zanella
37d0a3e55a Translations: Regenerate libc.pot
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-02 10:19:42 -03:00
Florian Weimer
cc74583f23 elf: Remove the remaining uses of GET_ADDR_OFFSET
Expand the macro where it is used in static definitions of
__tls_get_addr.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-02 13:45:27 +01:00
Florian Weimer
30e32da6aa elf: Use TLS_DTV_OFFSET in __tls_get_addr
This fixes commit 5e249192ca ("elf:
Remove the GET_ADDR_ARGS and related macros from the TLS code"):
GET_ADDR_ARGS was indeed unused, but GET_ADDR_OFFSET was used
on several targets, those that define TLS_DTV_OFFSET.  Instead
of reintroducing GET_ADDR_OFFSET, use TLS_DTV_OFFSET directly,
now that it is defined on all targets.

In the new tls_get_addr_adjust helper function, add a cast to
uintptr_t to help the s390 case, where the offset can be positive or
negative, depending on the addresses malloc returns.  The cast avoids
pointer wraparound/overflow.  The outer uintptr_t cast is needed
to suppress a warning on x86-64 x32 about mismatched integer/pointer
sizes.

Eventually this offset should be folded into the DTV addresses
themselves, to eliminate the subtraction on the TLS fast path.
This will require an adjustment to libthread_db because the
debugger interface currently returns unadjusted pointers.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-02 13:45:27 +01:00
Florian Weimer
91ee75abcf s390: Define TLS_DTV_OFFSET instead of GET_ADDR_OFFSET
This will be used in __tls_get_addr to adjust the returned pointer
value.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-02 13:45:27 +01:00
Florian Weimer
ceae7e2770 elf: Introduce generic <dl-tls.h>
On arc, the definition of TLS_DTV_UNALLOCATED now comes from
<dl-dtv.h>.

For x86-64 x32, a separate version is needed because unsigned long int
is 32 bits on this target.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-02 13:45:27 +01:00
Florian Weimer
64d07e117d powerpc: Update acosf ulps
As seen on powerpc64le-linux-gnu with GCC 11 defaulting to POWER9
instructions.
2025-01-02 11:57:39 +01:00
gfleury
396048fa5a htl: move pthread_mutexattr_setprioceiling, pthread_mutexattr_getprioceiling into libc.
Message-ID: <20241231134909.1166440-9-gfleury@disroot.org>
2025-01-02 01:20:21 +01:00
gfleury
4371b11c86 htl: move pthread_mutexattr_{setrobust, setrobust_np}, pthread_mutexattr_{getrobust, getrobust_np} into libc.
Message-ID: <20241231134909.1166440-8-gfleury@disroot.org>
2025-01-02 01:20:20 +01:00
gfleury
1e5b39a5e0 htl: move pthread_mutexattr_setpshared, pthread_mutexattr_getpshared into libc.
Message-ID: <20241231134909.1166440-7-gfleury@disroot.org>
2025-01-02 01:19:29 +01:00
gfleury
b386295727 htl: move pthread_mutexattr_settype, pthread_mutexattr_gettype into libc.
Message-ID: <20241231134909.1166440-6-gfleury@disroot.org>
2025-01-02 00:51:35 +01:00
Samuel Thibault
3cd1cf5fe0 htl: move pthread_mutexattr_setprotocol into libc.
Message-ID: <20241231134909.1166440-5-gfleury@disroot.org>
2025-01-02 00:51:17 +01:00
gfleury
15686aa188 htl: move pthread_mutexattr_getprotocol into libc.
Message-ID: <20241231134909.1166440-4-gfleury@disroot.org>
2025-01-02 00:51:05 +01:00
gfleury
beabc5dff5 htl: move pthread_mutexattr_destroy into libc.
Message-ID: <20241231134909.1166440-3-gfleury@disroot.org>
2025-01-01 23:46:19 +01:00
gfleury
826b1bbcca htl: move pthread_mutexattr_init into libc.
Message-ID: <20241231134909.1166440-2-gfleury@disroot.org>
2025-01-01 23:44:32 +01:00
Samuel Thibault
cf13f740a9 bits/socket.h: Update to recent BSD definition
The old BSD 4.4 definition (not used by Linux) was not 64b-proof: the
cmsg_data field is supposed to CMSG_ALIGN'ed (as can be also seen in the
CMSG_LEN macro).

Suggested-by: Diego Nieto Cid <dnietoc@gmail.com>
2025-01-01 22:11:13 +01:00
Paul Eggert
6e177ca635 Don't update copyright notices in Linux licenses
* scripts/update-copyrights: Do not update copyright notices
in licenses imported from the Linux kernel.
This should prevent glitches such as those fixed in my
recent commit.
2025-01-01 12:16:24 -08:00
Paul Eggert
2d7029f20f Fix license typo induced by update-copyrighyt 2025-01-01 11:22:09 -08:00
Paul Eggert
ba995af76d Update copyright dates not handled by scripts/update-copyrights
I've updated copyright dates in glibc for 2025.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.
2025-01-01 11:22:09 -08:00
Paul Eggert
ad16577ae1 Update copyright in generated files by running "make" 2025-01-01 11:22:09 -08:00
Paul Eggert
2642002380 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
Paul Eggert
b1da163a21 Pass glibc pre-commit checks
This is needed for the next patch which updates copyright dates.
* assert/test-assert-2.c: Remove trailing white space.
* elf/tst-startup-errno.c: Remove trailing empty lines.
2025-01-01 11:20:43 -08:00
Xi Ruoyao
013106ae67
mlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
Since https://gcc.gnu.org/r11-959, the compiler emits
-Wmaybe-uninitialized if a const pointer to an uninitialized buffer is
passed.  Tell the compiler we don't dereference the pointer to remove
the false alarm.

Link: https://gcc.gnu.org/PR118194
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Sam James <sam@gentoo.org>
2025-01-01 16:08:36 +01:00
Adhemerval Zanella
58272284b6 elf: Add glibc.rtld.execstack
The new tunable can be used to control whether executable stacks are
allowed from either the main program or dependencies.  The default is
to allow executable stacks.

The executable stacks default permission is checked agains the one
provided by the PT_GNU_STACK from program headers (if present).  The
tunable also disables the stack permission change if any dependency
requires an executable stack at loading time.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-31 09:04:20 -03:00
Adhemerval Zanella
c9540704ac elf: Add tst-execstack-prog-static
Similar to tst-execstack-prog, check if executable stacks works for
statically linked programs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-31 09:04:20 -03:00
Adhemerval Zanella
0ca8785a28 elf: Do not change stack permission on dlopen/dlmopen
If some shared library loaded with dlopen/dlmopen requires an executable
stack, either implicitly because of a missing GNU_STACK ELF header
(where the ABI default flags implies in the executable bit) or explicitly
because of the executable bit from GNU_STACK; the loader will try to set
the both the main thread and all thread stacks (from the pthread cache)
as executable.

Besides the issue where any __nptl_change_stack_perm failure does not
undo the previous executable transition (meaning that if the library
fails to load, there can be thread stacks with executable stacks), this
behavior was used on a CVE [1] as a vector for RCE.

This patch changes that if a shared library requires an executable
stack, and the current stack is not executable, dlopen fails.  The
change is done only for dynamically loaded modules, if the program
or any dependency requires an executable stack, the loader will still
change the main thread before program execution and any thread created
with default stack configuration.

[1] https://www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-31 09:04:20 -03:00
Adhemerval Zanella
ca96ea06b3 elf: Cleanup and improve tst-execstack
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-31 09:04:20 -03:00
H.J. Lu
7962fa38e2 Use GCC 14 branch in build-many-glibcs.py
Tested with build-many-glibcs.py with

--exclude m68k-linux-gnu-coldfire-soft

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-31 16:08:57 +08:00
Andreas K. Hüttel
0feb6da94c
INSTALL, NEWS: Document requirement of gawk with MPFR support
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2024-12-30 17:03:36 +01:00
Adhemerval Zanella
29531b122c Mention CORE-MATH optimize routines on NEWS
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
2024-12-30 09:39:05 -03:00
Florian Weimer
0ee6e13f7f x86-64: Reorder dynamic linker list in ldd script (bug 32508)
Move the x86-64 loader first, before the i386 and x32 loaders.  In
most cases, it's the loader the script needs.  This avoids an error
message if the i386 loader does not work.

The effect of this change to the generated ldd script looks like this:

-RTLDLIST="/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2 /libx32/ld-linux-x32.so.2"
+RTLDLIST="/lib64/ld-linux-x86-64.so.2 /lib/ld-linux.so.2 /libx32/ld-linux-x32.so.2"

Reviewed-by: Sam James <sam@gentoo.org>
2024-12-30 13:24:36 +01:00
Michael Jeanson
0852c4aab7 nptl: hppa: replace __get_cr27 with __thread_pointer
The addition of the new thread_pointer.h header on HPPA resulted in
duplicated inline asm to get the current thread pointer from the cr27
register.

Include thread_pointer.h in tls.h and replace __get/set_cr27() with
__set_/thread_pointer() with the appropriate casts.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
2024-12-27 17:41:02 +01:00
Michael Jeanson
6fdb6abeb2 nptl: Add <thread_pointer.h> for hppa
This will be required by the rseq extensible ABI implementation on all
Linux architectures exposing the '__rseq_size' and '__rseq_offset'
symbols to set the initial value of the 'cpu_id' field which can be used
by applications to test if rseq is available and registered. As long as
the symbols are exposed it is valid for an application to perform this
test even if rseq is not yet implemented in libc for this architecture.

Compile tested with build-many-glibcs.py but I don't have access to any
hardware to run the tests.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
2024-12-27 17:41:02 +01:00