]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
13 months agodebug: Fix clang open fortify wrapper (BZ 31927)
Adhemerval Zanella [Tue, 25 Jun 2024 14:57:15 +0000 (11:57 -0300)] 
debug: Fix clang open fortify wrapper (BZ 31927)

The fcntl.h fortify wrapper for clang added by 86889e22db329abac61
missed the __fortify_clang_overload_arg and and also added the
mode argument for the __fortify_function_error_function function,
which leads clang to be able to correct resolve which overloaded
function it should emit.

Checked on x86_64-linux-gnu.

Reported-by: Khem Raj <raj.khem@gmail.com>
Tested-by: Khem Raj <raj.khem@gmail.com>
13 months agodebug: Fix clang mq_open fortify wrapper (BZ 31917)
Adhemerval Zanella [Fri, 21 Jun 2024 14:08:38 +0000 (11:08 -0300)] 
debug: Fix clang mq_open fortify wrapper (BZ 31917)

The mqueue.h fortify wrapper for clang added by c23107effbfe5300
is not fully correct, where correct 4 argument usage are not
being correctly handled.  For instance, while building socat 1.8
with a yocto clang based system shows:

  ./socat-1.8.0.0/xio-posixmq.c:119:8: error: 'mq_open' is unavailable: mq_open can be called either with 2 or 4 arguments
    119 |         mqd = mq_open(name, oflag, opt_mode, NULL);
        |               ^
  [...] /usr/include/bits/mqueue2.h:66:8: note: 'mq_open' has been explicitly marked unavailable here
     66 | __NTH (mq_open (const char *__name, int __oflag, mode_t mode,
        |        ^
  1 error generated.

The correct way to define the wrapper is to set invalid usage
with __fortify_clang_unavailable (for the case with 5 or more
arguments), followed by the expected ones.  This fix make mq_open
similar to current open wrappers.

[1] http://www.dest-unreach.org/socat/

Reported-by: Khem Raj <raj.khem@gmail.com>
Acked-by: Khem Raj <raj.khem@gmail.com>
13 months agotests-mbwc: Silence gcc 14 -Werror=format-overflow=
Stefan Liebler [Thu, 27 Jun 2024 11:42:37 +0000 (13:42 +0200)] 
tests-mbwc: Silence gcc 14 -Werror=format-overflow=

With gcc 14, I get this warning/werror when building the localedata tests:
tests-mbwc/tsp_common.c: In function ‘result.constprop.isra’:
tests-mbwc/tsp_common.c:55:43: error: ‘%s’ directive writing up to 92 bytes into a region of size between 0 and 114 [-Werror=format-overflow=]
   55 |   sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no,
      |                                           ^~
In file included from ../include/bits/stdio2.h:1,
                 from ../libio/stdio.h:980,
                 from ../include/stdio.h:14,
                 from tests-mbwc/tsp_common.c:10:
In function ‘sprintf’,
    inlined from ‘result.constprop.isra’ at tests-mbwc/tsp_common.c:55:3:
../libio/bits/stdio2.h:30:10: note: ‘__builtin___sprintf_chk’ output between 20 and 234 bytes into a destination of size 132
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

This patch now gets rid of using sprintf and the result_rec buffer and just
prints to fp directly.

13 months agotime: Avoid memcmp overread in tzset (bug 31931)
Florian Weimer [Wed, 26 Jun 2024 17:36:58 +0000 (19:36 +0200)] 
time: Avoid memcmp overread in tzset (bug 31931)

The test does not necessarily trigger the crash, depending on memcmp
behavior.  A crash was observed in __memcmp_ia32 on i686 builds.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
13 months agoFix strnlen doc re array size
Paul Eggert [Wed, 26 Jun 2024 15:14:26 +0000 (16:14 +0100)] 
Fix strnlen doc re array size

* manual/string.texi: For strnlen (s, maxlen), do not say that s must
be of size maxlen, as it can be smaller if it is null-terminated.
This should help avoid confusion such as seen in
<https://lists.gnu.org/r/bug-gnulib/2024-06/msg00280.html>.
Mention that strnlen and wcsnlen have been in POSIX since
POSIX.1-2008.

13 months agoarm: Avoid UB in elf_machine_rel()
Palmer Dabbelt [Thu, 23 Jun 2022 21:49:32 +0000 (14:49 -0700)] 
arm: Avoid UB in elf_machine_rel()

This recently came up during a cleanup to remove misaligned accesses
from the RISC-V port.

Link: https://sourceware.org/pipermail/libc-alpha/2022-June/139961.html
Suggested-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Fangrui Song <maskray@google.com>
13 months agoLoongArch: Fix tst-gnu2-tls2 test case
mengqinggang [Fri, 21 Jun 2024 08:08:53 +0000 (16:08 +0800)] 
LoongArch: Fix tst-gnu2-tls2 test case

asm volatile ("movfcsr2gr $t0, $fcsr0" ::: "$t0");
asm volatile ("st.d $t0, %0" :"=m"(restore_fcsr));

generate to the following instructions with -Og flag:

movfcsr2gr      $t0, $zero
addi.d          $t0, $sp, 2047(0x7ff)
addi.d          $t0, $t0, 77(0x4d)
st.w            $t0, $t0, 0

fcsr0 register and restore_fcsr variable are both stored in t0 register.

Change to:

asm volatile ("movfcsr2gr %0, $fcsr0" :"=r"(restore_fcsr));

to avoid restore_fcsr address in t0.

Comparing float value using memcmp because float value cannot be
directly compared for equality.

Put LOAD_REGISTER_FCSR and SAVE_REGISTER_FCC after LOAD_REGISTER_FLOAT.
Some float instructions may change fcsr register.

13 months agoposix: Fix pidfd_spawn/pidfd_spawnp leak if execve fails (BZ 31695)
Adhemerval Zanella [Mon, 6 May 2024 16:20:56 +0000 (13:20 -0300)] 
posix: Fix pidfd_spawn/pidfd_spawnp leak if execve fails (BZ 31695)

If the pidfd_spawn/pidfd_spawnp helper process succeeds, but evecve
fails for some reason (either with an invalid/non-existent, memory
allocation, etc.) the resulting pidfd is never closed, nor returned
to caller (so it can call close).

Since the process creation failed, it should be up to posix_spawn to
also, close the file descriptor in this case (similar to what it
does to reap the process).

This patch also changes the waitpid with waitid (P_PIDFD) for pidfd
case, to avoid a possible pid re-use.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
13 months agoINSTALL: regenerate
Andreas K. Hüttel [Tue, 25 Jun 2024 07:05:20 +0000 (09:05 +0200)] 
INSTALL: regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agoRevert "MIPSr6/math: Use builtin fma and fmaf"
Andreas K. Hüttel [Mon, 24 Jun 2024 23:02:58 +0000 (01:02 +0200)] 
Revert "MIPSr6/math: Use builtin fma and fmaf"

Apologies, I mistakenly interpreted this to be already accepted.
Reverting until v6 or later is reviewed and approved.

This reverts commit 9e06e4a43b58519991acbed1d7f33abc40249226.

13 months agoINSTALL: Fix typo ibmlondouble to ibmlongdouble
Joe Simmons-Talbott [Thu, 13 Jul 2023 19:49:17 +0000 (15:49 -0400)] 
INSTALL: Fix typo ibmlondouble to ibmlongdouble

13 months agoRISC-V: Execute a PAUSE hint in spin loops
Christoph Müllner [Thu, 18 Apr 2024 21:58:58 +0000 (23:58 +0200)] 
RISC-V: Execute a PAUSE hint in spin loops

The atomic_spin_nop() macro can be used to run arch-specific
code in the body of a spin loop to potentially improve efficiency.
RISC-V's Zihintpause extension includes a PAUSE instruction for
this use-case, which is encoded as a HINT, which means that it
behaves like a NOP on systems that don't implement Zihintpause.

Binutils supports Zihintpause since 2.36, so this patch uses
the ".insn" directive to keep the code compatible with older
toolchains.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
13 months agoMIPSr6/math: Use builtin fma and fmaf
YunQiang Su [Tue, 4 Jun 2024 01:31:19 +0000 (09:31 +0800)] 
MIPSr6/math: Use builtin fma and fmaf

MIPSr6 has MADDF.s/MADDF.d instructions, which are fused.

In MIPS ISA, double support can be subsetted.  Only FMAF is enabled
for this case.

* sysdeps/mips/fpu/math-use-builtins-fma.h

Signed-off-by: YunQiang Su <syq@gcc.gnu.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13 months agopo: incorporate translations (cs, de, hr, ko, pl, ro, ru, sv, uk, zh_CN)
Andreas K. Hüttel [Mon, 24 Jun 2024 10:09:30 +0000 (12:09 +0200)] 
po: incorporate translations (cs, de, hr, ko, pl, ro, ru, sv, uk, zh_CN)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agomtrace: make shell commands robust against meta characters
Andreas Schwab [Thu, 20 Jun 2024 12:13:01 +0000 (14:13 +0200)] 
mtrace: make shell commands robust against meta characters

Use the list form of the open function to avoid interpreting meta
characters in the arguments.

13 months agohppa/vdso: Add wrappers for vDSO functions
John David Anglin [Sun, 23 Jun 2024 23:39:28 +0000 (19:39 -0400)] 
hppa/vdso: Add wrappers for vDSO functions

The upcoming parisc (hppa) v6.11 Linux kernel will include vDSO
support for gettimeofday(), clock_gettime() and clock_gettime64()
syscalls for 32- and 64-bit userspace.
The patch below adds the necessary glue code for glibc.

Signed-off-by: Helge Deller <deller@gmx.de>
Changes in v2:
- add vsyscalls for 64-bit too

13 months agoUpdate hppa libm-test-ulps
John David Anglin [Sun, 23 Jun 2024 17:51:25 +0000 (13:51 -0400)] 
Update hppa libm-test-ulps

13 months agoBenchtests: Remove broken walk benchmarks
Wilco Dijkstra [Thu, 20 Jun 2024 10:43:54 +0000 (11:43 +0100)] 
Benchtests: Remove broken walk benchmarks

The walk benchmarks don't measure anything useful - memory is not initialized
properly so doing a single walk in 32MB just measures reading the 4KB zero
page for reads and clear_page overhead for writes.  The memset variants don't
even manage to do a walk in the 32MB region due to using incorrect pointer
increments...  Neither is it clear why it is walking backwards since this
won't confuse modern prefetchers.  If you fix the benchmark and print the
bandwidth, the results are identical for all sizes larger than ~1KB since it
is just testing memory bandwidth of a single 32MB block.  This case is already
tested by the large benchmark, so overall it doesn't seem useful to keep these.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
13 months agoUpdate hppa libm-test-ulps
John David Anglin [Thu, 20 Jun 2024 23:44:04 +0000 (19:44 -0400)] 
Update hppa libm-test-ulps

13 months agoRISC-V: Update ulps
Julian Zhu [Wed, 19 Jun 2024 12:03:22 +0000 (20:03 +0800)] 
RISC-V: Update ulps

For the exp10m1, exp2m1, log10p1 and log2p1 implementations.

Signed-off-by: Julian Zhu <jz531210@gmail.com>
13 months agoMIPS: Update ulps
Julian Zhu [Wed, 19 Jun 2024 12:58:55 +0000 (20:58 +0800)] 
MIPS: Update ulps

Update mips32/mips64 ulps for the exp10m1, exp2m1, and log10p1 implementations.

Signed-off-by: Julian Zhu <jz531210@gmail.com>
13 months agomalloc: Replace shell/Perl gate in mtrace
Florian Weimer [Thu, 20 Jun 2024 18:55:10 +0000 (20:55 +0200)] 
malloc: Replace shell/Perl gate in mtrace

The previous version expanded $0 and $@ twice.

The new version defines a q no-op shell command.  The Perl syntax
error is masked by the eval Perl function.  The q { … } construct
is executed by the shell without errors because the q shell function
was defined, but treated as a non-expanding quoted string by Perl,
effectively hiding its context from the Perl interpreter.  As before
the script is read by require instead of executed directly, to avoid
infinite recursion because the #! line contains /bin/sh.

Introduce the “fatal” function to produce diagnostics that are not
suppressed by “do”.  Use “do” instead of “require” because it has
fewer requirements on the executed script than “require”.

Prefix relative paths with './' because “do” (and “require“ before)
searches for the script in @INC if the path is relative and does not
start with './'.  Use $_ to make the trampoline shorter.

Add an Emacs mode marker to indentify the script as a Perl script.

13 months agoi386: Update ulps
Florian Weimer [Thu, 20 Jun 2024 17:00:48 +0000 (19:00 +0200)] 
i386: Update ulps

This is from a -march=i686 -mtune=generic build with
--disable-multi-arch, running on a Cascade Lake CPU.

13 months agos390x: Capture grep output in static PIE check
Florian Weimer [Thu, 20 Jun 2024 08:40:02 +0000 (10:40 +0200)] 
s390x: Capture grep output in static PIE check

The test is not a run-time check, so update the description.
Also use readelf -W for a more stable output format and fix
an LC_ALL typo.

This avoids garbled configure messages:

checking for s390-specific static PIE requirements (runtime check)...  0x0000000000000017 (JMPREL)             0x280
yes

13 months agopowerpc: Update ulps
Florian Weimer [Thu, 20 Jun 2024 09:07:17 +0000 (11:07 +0200)] 
powerpc: Update ulps

Results based on POWER8 and POWER9 machines running
powerpc64-linux-gnu, with and without --disable-multi-arch.

13 months agoi386: Update ulps
Florian Weimer [Thu, 20 Jun 2024 09:09:37 +0000 (11:09 +0200)] 
i386: Update ulps

Based on a -march=x86-64-v4 -mfpmath=sse build, with and without
--disable-multi-arch, running on a Zen 4 CPU.  Also used different
-march=x8i6-64-v… settings.

13 months agomalloc: Always install mtrace (bug 31892)
Florian Weimer [Thu, 20 Jun 2024 08:32:16 +0000 (10:32 +0200)] 
malloc: Always install mtrace (bug 31892)

Generation of the Perl script does not depend on Perl, so we can
always install it even if $(PERL) is not set during the build.

Change the malloc/mtrace.pl text substition not to rely on $(PERL).
Instead use PATH at run time to find the Perl interpreter. The Perl
interpreter cannot execute directly a script that starts with
“#! /bin/sh”: it always executes it with /bin/sh.  There is no
perl command line switch to disable this behavior.  Instead, use
the Perl require function to execute the script.  The additional
shift calls remove the “.” shell arguments.  Perl interprets the
“.” as a string concatenation operator, making the expression
syntactically valid.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
13 months agoTranslations: Regenerate libc.pot
Andreas K. Hüttel [Wed, 19 Jun 2024 20:32:09 +0000 (22:32 +0200)] 
Translations: Regenerate libc.pot

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agoLoongArch: Update ulps
Xi Ruoyao [Wed, 19 Jun 2024 14:55:44 +0000 (22:55 +0800)] 
LoongArch: Update ulps

Add ulps for recently added C23 exp10m1, exp2m1, and log10p1 functions.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
13 months agosparc: Regenerate ULPs
Andreas K. Hüttel [Wed, 19 Jun 2024 12:58:32 +0000 (14:58 +0200)] 
sparc: Regenerate ULPs

Linux catbus 5.15.110-gentoo-r1 #1 SMP Fri Jun 9 17:53:23 PDT 2023 sparc64 sun4v UltraSparc T5 (Niagara5) GNU/Linux

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agos390x: Regenerate ULPs.
Stefan Liebler [Wed, 19 Jun 2024 06:42:30 +0000 (08:42 +0200)] 
s390x: Regenerate ULPs.

Needed due to:
- "Implement C23 log10p1"
  commit ID 55eb99e9a9d840ba452b128be14d6529c2dde039
- "Implement C23 exp2m1, exp10m1"
  commit ID 7ec903e028271d029818378fd60ddaf6b76b89ac

13 months agoLoongArch: Fix _dl_tlsdesc_dynamic in LSX case
mengqinggang [Fri, 14 Jun 2024 03:58:30 +0000 (11:58 +0800)] 
LoongArch: Fix _dl_tlsdesc_dynamic in LSX case

HWCAP value is overwritten at the first comparison of the LASX case.
The second comparison at LSX get incorrect result.
Change to use t0 to save HWCAP value, and use t1 to save comparison
result.

13 months agoarm: Update ulps
Adhemerval Zanella [Tue, 18 Jun 2024 20:02:34 +0000 (20:02 +0000)] 
arm: Update ulps

For the exp10m1, exp2m1, and log10p1 implementations.

13 months agoaarch64: Update ulps
Adhemerval Zanella [Tue, 18 Jun 2024 20:01:40 +0000 (20:01 +0000)] 
aarch64: Update ulps

For the exp10m1, exp2m1, and log10p1 implementations.

13 months agopowerpc: Update ulps
Adhemerval Zanella [Tue, 18 Jun 2024 20:02:48 +0000 (23:02 +0300)] 
powerpc: Update ulps

For the exp10m1, exp2m1, and log10p1 implementations.

13 months agoLinux: Include <dl-symbol-redir-ifunc.h> in dl-sysdep.c
Florian Weimer [Tue, 18 Jun 2024 08:56:34 +0000 (10:56 +0200)] 
Linux: Include <dl-symbol-redir-ifunc.h> in dl-sysdep.c

The _dl_sysdep_parse_arguments function contains initalization
of a large on-stack variable:

  dl_parse_auxv_t auxv_values = { 0, };

This uses a non-inline version of memset on powerpc64le-linux-gnu,
so it must use the baseline memset.

13 months agolinux: add definitions for hugetlb page size encodings
Carlos Llamas [Tue, 18 Jun 2024 08:56:34 +0000 (10:56 +0200)] 
linux: add definitions for hugetlb page size encodings

A desired hugetlb page size can be encoded in the flags parameter of
system calls such as mmap() and shmget(). The Linux UAPI headers have
included explicit definitions for these encodings since v4.14.

This patch adds these definitions that are used along with MAP_HUGETLB
and SHM_HUGETLB flags as specified in the corresponding man pages. This
relieves programs from having to duplicate and/or compute the encodings
manually.

Additionally, the filter on these definitions in tst-mman-consts.py is
removed, as suggested by Florian. I then ran this tests successfully,
confirming the alignment with the kernel headers.

  PASS: misc/tst-mman-consts
  original exit status 0

Signed-off-by: Carlos Llamas <cmllamas@google.com>
Tested-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
13 months agoelf: Remove HWCAP_IMPORTANT
Stefan Liebler [Fri, 7 Jun 2024 11:42:44 +0000 (13:42 +0200)] 
elf: Remove HWCAP_IMPORTANT

Remove the definitions of HWCAP_IMPORTANT after removal of
LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask.  There HWCAP_IMPORTANT
was used as default value.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask
Stefan Liebler [Fri, 7 Jun 2024 11:42:43 +0000 (13:42 +0200)] 
elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask

Remove the environment variable LD_HWCAP_MASK and the tunable
glibc.cpu.hwcap_mask as those are not used anymore in common-code
after removal in elf/dl-cache.c:search_cache().

The only remaining user is sparc32 where it is used in
elf_machine_matches_host().  If sparc32 does not need it anymore,
we can get rid of it at all.  Otherwise we could also move
LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask to be sparc32 specific.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove _DL_PLATFORMS_COUNT
Stefan Liebler [Fri, 7 Jun 2024 11:42:42 +0000 (13:42 +0200)] 
elf: Remove _DL_PLATFORMS_COUNT

Remove the definitions of _DL_PLATFORMS_COUNT as those are not used
anymore after removal in elf/dl-cache.c:search_cache().

Note: On x86, we can also get rid of the definitions
HWCAP_PLATFORMS_START and HWCAP_PLATFORMS_COUNT.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove _DL_FIRST_PLATFORM
Stefan Liebler [Fri, 7 Jun 2024 11:42:41 +0000 (13:42 +0200)] 
elf: Remove _DL_FIRST_PLATFORM

Remove the definitions of _DL_FIRST_PLATFORM as those were only used
in the _DL_HWCAP_PLATFORM definitions and in _dl_string_platform().
Both were removed.

Note: Removed on every architecture despite of powerpc, where
_dl_string_platform() is still used.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove _DL_HWCAP_PLATFORM
Stefan Liebler [Fri, 7 Jun 2024 11:42:40 +0000 (13:42 +0200)] 
elf: Remove _DL_HWCAP_PLATFORM

Remove the definitions of _DL_HWCAP_PLATFORM as those are not used
anymore after removal in elf/dl-cache.c:search_cache().
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove platform strings in dl-procinfo.c
Stefan Liebler [Wed, 12 Jun 2024 07:32:36 +0000 (09:32 +0200)] 
elf: Remove platform strings in dl-procinfo.c

Remove the platform strings in dl-procinfo.c where also
the implementation of _dl_string_platform() was removed.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove _dl_string_platform
Stefan Liebler [Fri, 7 Jun 2024 11:42:38 +0000 (13:42 +0200)] 
elf: Remove _dl_string_platform

Despite of powerpc where the returned integer is stored in tcb,
and the diagnostics output, there is no user anymore.

Thus this patch removes the diagnostics output and
_dl_string_platform for all other platforms.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoelf: Remove loading legacy hwcaps/platform entries in dynamic loader
Stefan Liebler [Fri, 7 Jun 2024 11:42:37 +0000 (13:42 +0200)] 
elf: Remove loading legacy hwcaps/platform entries in dynamic loader

The legacy hwcaps mechanism was removed with glibc 2.37:
See this commit series:
d178c67535f0d159df73843e7c18cbdb39b4d25d
x86_64: Remove platform directory library loading test
6099908fb84debee4c3bcb05d88769410c2aecd1
elf: Remove legacy hwcaps support from the dynamic loader
b78ff5a25dc8ba9d8c6df10bb0a533254bdd193f
elf: Remove legacy hwcaps support from ldconfig
4a7094119ce05cadf927f52cc5d723e2195e65f9
elf: Remove hwcap parameter from add_to_cache signature
cfbf883db36727a84ef7929af49ef68c195b5972
elf: Remove hwcap and bits_hwcap fields from struct cache_entry
78d9a1620b840deb0880686e4159eaf70708866a
Add NEWS entry for legacy hwcaps removal
ab40f20364f4a417a63dd51fdd943742070bfe96
elf: Remove _dl_string_hwcap
e76369ed6371734f77f468eab097ef4e5b5db1c5
elf: Simplify output of hwcap subdirectories in ld.so help

According to Florian Weimer, this was an oversight and should also
have been removed.

As ldconfig does not generate ld.so.cache entries with hwcap/platform
bits in the hwcap-field anymore, this patch now skips those entries.
Thus currently only named-hwcap-entries and the default entries are
allowed.
For named-hwcap entries bit 62 is set and also the isa-level bits can
be set.
For the default entries the hwcap-field is 0.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agox86: Remove HWCAP_START and HWCAP_COUNT
Stefan Liebler [Fri, 7 Jun 2024 11:42:36 +0000 (13:42 +0200)] 
x86: Remove HWCAP_START and HWCAP_COUNT

Both defines are not used anymore.  Those were only used for
_dl_string_hwcap(), which itself was removed with commit
ab40f20364f4a417a63dd51fdd943742070bfe96
"elf: Remove _dl_string_hwcap"

Just clean up.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agomath: Update mips32/mips64 ulps for log2p1
YunQiang Su [Fri, 31 May 2024 15:50:38 +0000 (23:50 +0800)] 
math: Update mips32/mips64 ulps for log2p1

13 months agoConvert to autoconf 2.72 (vanilla release, no distribution patches)
Andreas K. Hüttel [Tue, 11 Jun 2024 21:34:54 +0000 (23:34 +0200)] 
Convert to autoconf 2.72 (vanilla release, no distribution patches)

As discussed at the patch review meeting

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Simon Chopin <simon.chopin@canonical.com>
13 months agoImplement C23 exp2m1, exp10m1
Joseph Myers [Mon, 17 Jun 2024 16:31:49 +0000 (16:31 +0000)] 
Implement C23 exp2m1, exp10m1

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the exp2m1 and exp10m1 functions (exp2(x)-1 and
exp10(x)-1, like expm1).

As with other such functions, these use type-generic templates that
could be replaced with faster and more accurate type-specific
implementations in future.  Test inputs are copied from those for
expm1, plus some additions close to the overflow threshold (copied
from exp2 and exp10) and also some near the underflow threshold.

exp2m1 has the unusual property of having an input (M_MAX_EXP) where
whether the function overflows (under IEEE semantics) depends on the
rounding mode.  Although these could reasonably be XFAILed in the
testsuite (as we do in some cases for arguments very close to a
function's overflow threshold when an error of a few ulps in the
implementation can result in the implementation not agreeing with an
ideal one on whether overflow takes place - the testsuite isn't smart
enough to handle this automatically), since these functions aren't
required to be correctly rounding, I made the implementation check for
and handle this case specially.

The Makefile ordering expected by lint-makefiles for the new functions
is a bit peculiar, but I implemented it in this patch so that the test
passes; I don't know why log2 also needed moving in one Makefile
variable setting when it didn't in my previous patches, but the
failure showed a different place was expected for that function as
well.

The powerpc64le IFUNC setup seems not to be as self-contained as one
might hope; it shouldn't be necessary to add IFUNCs for new functions
such as these simply to get them building, but without setting up
IFUNCs for the new functions, there were undefined references to
__GI___expm1f128 (that IFUNC machinery results in no such function
being defined, but doesn't stop include/math.h from doing the
redirection resulting in the exp2m1f128 and exp10m1f128
implementations expecting to call it).

Tested for x86_64 and x86, and with build-many-glibcs.py.

13 months agoImplement C23 log10p1
Joseph Myers [Mon, 17 Jun 2024 13:48:13 +0000 (13:48 +0000)] 
Implement C23 log10p1

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the log10p1 functions (log10(1+x): like log1p, but for
base-10 logarithms).

This is directly analogous to the log2p1 implementation (except that
whereas log2p1 has a smaller underflow range than log1p, log10p1 has a
larger underflow range).  The test inputs are copied from those for
log1p and log2p1, plus a few more inputs in that wider underflow
range.

Tested for x86_64 and x86, and with build-many-glibcs.py.

13 months agoImplement C23 logp1
Joseph Myers [Mon, 17 Jun 2024 13:47:09 +0000 (13:47 +0000)] 
Implement C23 logp1

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the logp1 functions (aliases for log1p functions - the
name is intended to be more consistent with the new log2p1 and
log10p1, where clearly it would have been very confusing to name those
functions log21p and log101p).  As aliases rather than new functions,
the content of this patch is somewhat different from those actually
adding new functions.

Tests are shared with log1p, so this patch *does* mechanically update
all affected libm-test-ulps files to expect the same errors for both
functions.

The vector versions of log1p on aarch64 and x86_64 are *not* updated
to have logp1 aliases (and thus there are no corresponding header,
tests, abilist or ulps changes for vector functions either).  It would
be reasonable for such vector aliases and corresponding changes to
other files to be made separately.  For now, the log1p tests instead
avoid testing logp1 in the vector case (a Makefile change is needed to
avoid problems with grep, used in generating the .c files for vector
function tests, matching more than one ALL_RM_TEST line in a file
testing multiple functions with the same inputs, when it assumes that
the .inc file only has a single such line).

Tested for x86_64 and x86, and with build-many-glibcs.py.

13 months agosupport: Include <limits.h> for NAME_MAX use in temp_file.c
Florian Weimer [Mon, 17 Jun 2024 13:14:05 +0000 (15:14 +0200)] 
support: Include <limits.h> for NAME_MAX use in temp_file.c

13 months agosupport: Include <stdlib.h> for atoi use in support_wait_for_thread_exit
Florian Weimer [Mon, 17 Jun 2024 13:14:05 +0000 (15:14 +0200)] 
support: Include <stdlib.h> for atoi use in support_wait_for_thread_exit

13 months agoExtend tst-getconf.sh test with NPROCESSORS_CONF and NPROCESSORS_ONLN
Jan Kurik [Fri, 14 Jun 2024 18:49:39 +0000 (20:49 +0200)] 
Extend tst-getconf.sh test with NPROCESSORS_CONF and NPROCESSORS_ONLN

Reviewed-by: Arjun Shankar <arjun@redhat.com>
13 months agoDefine ISO 639-3 "ltg" (Latgalian) and add ltg_LV locale
Mike FABIAN [Mon, 10 Jun 2024 17:54:42 +0000 (19:54 +0200)] 
Define ISO 639-3 "ltg" (Latgalian) and add ltg_LV locale

Resolves: BZ # 31411

References:
https://iso639-3.sil.org/code/ltg
https://en.wikipedia.org/wiki/Latgalian_language
https://github.com/unicode-org/cldr/blob/main/common/main/ltg.xml

13 months agoINSTALL: regenerate
Paul Eggert [Sat, 15 Jun 2024 17:32:34 +0000 (10:32 -0700)] 
INSTALL: regenerate

13 months agoMinor code improvement to timespec_subtract example
Paul Eggert [Sat, 15 Jun 2024 15:40:41 +0000 (08:40 -0700)] 
Minor code improvement to timespec_subtract example

This saves a few instructions.
BORROW cannot be -1, since NSEC_DIFF is at most 999999999.
Idea taken from Gnulib, here:
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=fe33f943054b93af8b965ce6564b8713b0979a21

13 months agoModernize and fix doc’s “Date and Time” (BZ 31876)
Paul Eggert [Sat, 8 Jun 2024 16:48:25 +0000 (09:48 -0700)] 
Modernize and fix doc’s “Date and Time” (BZ 31876)

POSIX.1-2024 (now official) specifies tm_gmtoff and tm_zone.
This is a good time to update the manual’s “Date and Time”
chapter so I went through it, fixed some outdated
stuff that had been in there for decades, and improved it to match
POSIX.1-2024 better and to clarify some implementation-defined
behavior.  Glibc already conforms to POSIX.1-2024 in these matters, so
this is merely a documentation change.

* manual/examples/strftim.c: Use snprintf instead of now-deprecated
  function asctime.  Check for localtime failure.  Simplify by using
  puts instead of fputs.  Prefer ‘buf, sizeof buf’ to less-obvious
  ‘buffer, SIZE’.

* manual/examples/timespec_subtract.c: Modernize to use struct
  timespec not struct timeval, and rename from timeval_subtract.c.
  All uses changed.  Check for overflow.  Do not check for negative
  return value, which ought to be OK since negative time_t is OK.
  Use GNU indenting style.

* manual/time.texi:

  Document CLOCKS_PER_SEC, TIME_UTC, timespec_get, timespec_getres,
  strftime_l.

  Document the storage lifetime of tm_zone and of tzname.

  Caution against use of tzname, timezone and daylight, saying that
  these variables have unspecified values when TZ is geographic.
  This is what glibc actually does (contrary to what the manual said
  before this patch), and POSIX is planned to say the same thing
  <https://austingroupbugs.net/view.php?id=1816>.
  Also say that directly accessing the variables is not thread-safe.

  Say that localtime_r and ctime_r don’t necessarily set time zone
  state.  Similarly, in the tzset documentation, say that it is called
  by ctime, localtime, mktime, strftime, not that it is called by all
  time conversion functions that depend on the time zone.

  Say that tm_isdst is useful mostly just for mktime, and that
  other uses should prefer tm_gmtoff and tm_zone instead.

  Do not say that strftime ignores tm_gmtoff and tm_zone, because
  it doesn’t do that.

  Document what gmtime does to tm_gmtoff and tm_zone.

  Say that the asctime, asctime_r, ctime, and ctime_r are now deprecated
  and/or obsolescent, and that behavior is undefined if the year is <
  1000 or > 9999.  Document strftime before these now-obsolescent
  functions, so that readers see the useful function first.

  Coin the terms “geographical format” and “proleptic format” for the
  two main formats of TZ settings, to simplify exposition.  Use this
  wording consistently.

  Update top-level proleptic syntax to match POSIX.1-2024, which glibc
  already implements.  Document the angle-bracket quoted forms of time
  zone abbreviations in proleptic TZ.  Say that time zone abbreviations
  can contain only ASCII alphanumerics, ‘+’, and ‘-’.

  Document what happens if the proleptic form specifies a DST
  abbreviation and offset but omits the rules.  POSIX says this is
  implementation-defined so we need to document it.  Although this
  documentation mentions ‘posixrules’ tersely, we need to rethink
  ‘posixrules’ since I think it stops working after 2038.

  Clarify wording about TZ settings beginning with ‘;’.

  Say that timegm is in ISO C (as of C23).

  Say that POSIX.1-2024 removed gettimeofday.

  Say that tm_gmtoff and tm_zone are extensions to ISO C, which is
  clearer than saying they are invisible in a struct ISO C enviroment,
  and gives us more wiggle room if we want to make them visible in
  strict ISO C, something that ISO C allows.

  Drop mention of old standards like POSIX.1c and POSIX.2-1992 in the
  text when the history is so old that it’s no longer useful in a
  general-purpose manual.

  Define Coordinated Universal Time (UTC), time zone, time zone ruleset,
  and POSIX Epoch, and use these phrases more consistently.

  Improve TZ examples to show more variety, and to reflect current
  practice and timestamps.  Remove obsolete example about Argentina.
  Add an example for Ireland.

  Don’t rely on GCC extensions when explaining ctime_r.

  Do not say that difftime produces the mathematically correct result,
  since it might be inexact.

  For clock_t don’t say “as in the example above” when there is no
  such example, and don’t say that casting to double works “properly
  and consistently no matter what”, as it suffers from rounding and
  overflow.

  Don’t say broken-down time is not useful for calculations; it’s
  merely painful.

  Say that UTC is not defined before 1960.

  Rename Time Zone Functions to Time Zone State.  All uses changed.

  Update Internet RFC 822 → 5322, 1305 → 5905.  Drop specific years of
  ISO 8601 as they don’t matter.

  Minor style changes: @code{"..."} → @t{"..."} to avoid overquoting in
  info files, @code → @env for environment variables, Daylight Saving
  Time → daylight saving time, white space → whitespace, prime meridian
  → Prime Meridian.

13 months agomanual: minor language fix (bz 31340)
Andreas K. Hüttel [Sat, 15 Jun 2024 13:41:22 +0000 (15:41 +0200)] 
manual: minor language fix (bz 31340)

Resolves: https://sourceware.org/bugzilla/show_bug.cgi?id=31340
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agox86: Fix value for `x86_memset_non_temporal_threshold` when it is undesirable
Noah Goldstein [Fri, 14 Jun 2024 18:01:58 +0000 (13:01 -0500)] 
x86: Fix value for `x86_memset_non_temporal_threshold` when it is undesirable

When we don't want to use non-temporal stores for memset, we set
`x86_memset_non_temporal_threshold` to SIZE_MAX.

The current code, however, we using `maximum_non_temporal_threshold`
as the upper bound which is `SIZE_MAX >> 4` so we ended up with a
value of `0`.

Fix is to just use `SIZE_MAX` as the upper bound for when setting the
tunable.
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
13 months agoelf: Change module-names to modules-names in comments
H.J. Lu [Fri, 14 Jun 2024 20:29:21 +0000 (13:29 -0700)] 
elf: Change module-names to modules-names in comments

module-names should be modules-names.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
13 months agoi686: Regenerate ulps
Andreas K. Hüttel [Fri, 14 Jun 2024 19:23:10 +0000 (21:23 +0200)] 
i686: Regenerate ulps

Linux pinacolada 6.6.32-gentoo #1 SMP PREEMPT Sun Jun  9 14:18:17 CEST 2024 x86_64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz GenuineIntel GNU/Linux
32bit build for multilib environment

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
13 months agoLoongArch: Ensure sp 16-byte aligned for tlsdesc
Xi Ruoyao [Thu, 13 Jun 2024 11:04:05 +0000 (19:04 +0800)] 
LoongArch: Ensure sp 16-byte aligned for tlsdesc

"ADDI sp, sp, 24" and "ADDI sp, sp, SZFCSREG" (SZFCSREG = 4) are
misaligning the stack: the ABI mandates a 16-byte alignment.  Fix it
by changing the first one to "ADDI sp, sp, 32", and reuse the spare 4th
slot for saving fcsr.

Reported-by: Jinyang He <hejinyang@loongson.cn>
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
13 months agoresolv: Track single-request fallback via _res._flags (bug 31476)
Florian Weimer [Thu, 13 Jun 2024 16:56:30 +0000 (18:56 +0200)] 
resolv: Track single-request fallback via _res._flags (bug 31476)

This avoids changing _res.options, which inteferes with change
detection as part of automatic reloading of /etc/resolv.conf.

Reviewed-by: DJ Delorie <dj@redhat.com>
13 months agox86: Properly set x86 minimum ISA level [BZ #31883]
H.J. Lu [Wed, 12 Jun 2024 03:14:56 +0000 (20:14 -0700)] 
x86: Properly set x86 minimum ISA level [BZ #31883]

Properly set libc_cv_have_x86_isa_level in shell for MINIMUM_X86_ISA_LEVEL
defined as

(__X86_ISA_V1 + __X86_ISA_V2 + __X86_ISA_V3 + __X86_ISA_V4)

Also set __X86_ISA_V2 to 1 for i386 if __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
is defined.  There are no changes in config.h nor in config.make on x86-64.
On i386, -march=x86-64-v2 with GCC generates

 #define MINIMUM_X86_ISA_LEVEL 2

in config.h and

have-x86-isa-level = 2

in config.make.  This fixes BZ #31883.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
13 months agotunables: sort tunables list (BZ 30027)
DJ Delorie [Tue, 11 Jun 2024 23:28:36 +0000 (19:28 -0400)] 
tunables: sort tunables list (BZ 30027)

Sort tunables list at the time it's generated.  Note: adding new
tunables will cause other tunable IDs to change, but that was
the case before anyway.  POSIX does not guarantee the order of "foo
in bar" AWK operators, so the order was indeterminate before anyway.
Even depending on the order to be the same across multiple calls,
such as in this script, is undefined, so sorting the list resolves
that also.

Note that sorting is not dependent on the user's locale.

13 months agolinux: Remove __stack_prot
Adhemerval Zanella [Tue, 11 Jun 2024 15:27:04 +0000 (12:27 -0300)] 
linux: Remove __stack_prot

The __stack_prot is used by Linux to make the stack executable if
a modules requires it.  It is also marked as RELRO, which requires
to change the segment permission to RW to update it.

Also, there is no need to keep track of the flags: either the stack
will have the default permission of the ABI or should be change to
PROT_READ | PROT_WRITE | PROT_EXEC.  The only additional flag,
PROT_GROWSDOWN or PROT_GROWSUP, is Linux only and can be deducted
from _STACK_GROWS_DOWN/_STACK_GROWS_UP.

Also, the check_consistency function was already removed some time
ago.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
13 months ago<stdio.h>: Acknowledge that getdelim/getline are in POSIX
Philip Kaludercic [Sun, 9 Jun 2024 11:14:59 +0000 (13:14 +0200)] 
<stdio.h>: Acknowledge that getdelim/getline are in POSIX

These comments were written in 2003 (added in 2c008571c3a), predating
the addition of getdelim(3)/getline(3) in POSIX.1-2008.

Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
13 months agolocaledata: Lowercase day and abday in cs_CZ
Mike FABIAN [Mon, 10 Jun 2024 17:54:42 +0000 (19:54 +0200)] 
localedata: Lowercase day and abday in cs_CZ

Resolves: BZ # 25119

Also to sync with CLDR

13 months agox86: Properly set MINIMUM_X86_ISA_LEVEL for i386 [BZ #31867]
H.J. Lu [Mon, 10 Jun 2024 20:02:06 +0000 (13:02 -0700)] 
x86: Properly set MINIMUM_X86_ISA_LEVEL for i386 [BZ #31867]

On i386, set the default minimum ISA level to 0, not 1 (baseline which
includes SSE2).  There are no changes in config.h nor in config.make on
x86-64.  This fixes BZ #31867.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Tested-by: Ian Jordan <immoloism@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
13 months agox86: Enable non-temporal memset tunable for AMD
Joe Damato [Fri, 7 Jun 2024 23:04:47 +0000 (23:04 +0000)] 
x86: Enable non-temporal memset tunable for AMD

In commit 46b5e98ef6f1 ("x86: Add seperate non-temporal tunable for
memset") a tunable threshold for enabling non-temporal memset was added,
but only for Intel hardware.

Since that commit, new benchmark results suggest that non-temporal
memset is beneficial on AMD, as well, so allow this tunable to be set
for AMD.

See:
https://docs.google.com/spreadsheets/d/1opzukzvum4n6-RUVHTGddV6RjAEil4P2uMjjQGLbLcU/edit?usp=sharing
which has been updated to include data using different stategies for
large memset on AMD Zen2, Zen3, and Zen4.

Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
13 months agohurd: Fix getxattr/listxattr returning ERANGE
Samuel Thibault [Mon, 10 Jun 2024 20:01:40 +0000 (22:01 +0200)] 
hurd: Fix getxattr/listxattr returning ERANGE

The manpage says that when the passed size is zero, they should set the
expected size and return 0. ERANGE shall be returned only when the non-zero
passed size is not large enough.

13 months agohurd: Fix setxattr return value on replacing
Samuel Thibault [Mon, 10 Jun 2024 20:00:20 +0000 (22:00 +0200)] 
hurd: Fix setxattr return value on replacing

When XATTR_REPLACE is set we shall succeed when the value already
exists, and fail with ENODATA otherwise, instead of the converse.

13 months agohurd: Fix getxattr("gnu.translator") returning ENODATA
Samuel Thibault [Mon, 10 Jun 2024 19:57:53 +0000 (21:57 +0200)] 
hurd: Fix getxattr("gnu.translator") returning ENODATA

When no translator is set, __file_get_translator would return EINVAL
which is a confusing value. Better check for a passive translation
before getting the value.

13 months agohurd: Fix lsetxattr return value
Samuel Thibault [Mon, 10 Jun 2024 19:56:13 +0000 (21:56 +0200)] 
hurd: Fix lsetxattr return value

The manpage says that lsetxattr returns 0 on success, like setxattr.

13 months agolocaledata: add new locales scn_IT
David Paleino [Wed, 15 May 2024 18:39:46 +0000 (20:39 +0200)] 
localedata: add new locales scn_IT

Signed-off-by: David Paleino <dapal@debian.org>
13 months agosupport: Fix typo in xgetsockname error message
Avinal Kumar [Fri, 17 May 2024 15:28:04 +0000 (20:58 +0530)] 
support: Fix typo in xgetsockname error message

The error message in xgetsockname was incorrectly referring to a
different function.  This commit fixes that.

Suggested-by: Arjun Shankar <arjun@redhat.com>
Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
13 months agogetconf: Add NPROCESSORS_{CONF,ONLN} [BZ #31661]
Mohamed Akram [Thu, 30 May 2024 14:05:50 +0000 (18:05 +0400)] 
getconf: Add NPROCESSORS_{CONF,ONLN} [BZ #31661]

These are required by the upcoming POSIX standard and are available on
other platforms.

Link: https://austingroupbugs.net/view.php?id=339
Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
13 months agoLinux: Add epoll ioctls
Joe Damato [Tue, 28 May 2024 17:37:06 +0000 (17:37 +0000)] 
Linux: Add epoll ioctls

As of Linux kernel 6.9, some ioctls and a parameters structure have been
introduced which allow user programs to control whether a particular
epoll context will busy poll.

Update the headers to include these for the convenience of user apps.

The ioctls were added in Linux kernel 6.9 commit 18e2bf0edf4dd
("eventpoll: Add epoll ioctl for epoll_params") [1] to
include/uapi/linux/eventpoll.h.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/?h=v6.9&id=18e2bf0edf4dd

Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agoImprove doc for time_t range (BZ 31808)
Paul Eggert [Tue, 28 May 2024 17:07:47 +0000 (10:07 -0700)] 
Improve doc for time_t range (BZ 31808)

13 months agodifftime can throw exceptions
Paul Eggert [Tue, 28 May 2024 17:07:47 +0000 (10:07 -0700)] 
difftime can throw exceptions

difftime can signal an inexact conversion when converting to double,
so it should not be marked as pure or nothrow (BZ 31808).

Although we could do something more complicated, in which difftime is
plain on modern platforms but const and nothrow on obsolescent
platforms with 32-bit time_t, it hardly seems worth the trouble.
difftime is used so rarely that it's not worth taking pains to
optimize calls to it on obsolescent platforms.

Reviewed-by: DJ Delorie <dj@redhat.com>
13 months agomalloc: New test to check malloc alternate path using memory obstruction
sayan paul [Wed, 29 May 2024 10:01:04 +0000 (15:31 +0530)] 
malloc: New test to check malloc alternate path using memory obstruction

The test aims to ensure that malloc uses the alternate path to
allocate memory when sbrk() or brk() fails.To achieve this,
the test first creates an obstruction at current program break,
tests that obstruction with a failing sbrk(), then checks if malloc
is still returning a valid ptr thus inferring that malloc() used
mmap() instead of brk() or sbrk() to allocate the memory.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
Reviewed-by: Zack Weinberg <zack@owlfolio.org>
13 months agomath: Fix exp10 undefined left shift
Szabolcs Nagy [Wed, 22 May 2024 15:33:43 +0000 (16:33 +0100)] 
math: Fix exp10 undefined left shift

Left shift of ki is undefined when ki<0, copy the logic from exp,
which uses unsigned arithmetics, to fix it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 months agolibio: Test for fdopen memory leak without SEEK_END support (bug 31840)
Florian Weimer [Tue, 4 Jun 2024 12:37:35 +0000 (14:37 +0200)] 
libio: Test for fdopen memory leak without SEEK_END support (bug 31840)

The bug report used /dev/mem, but /proc/self/mem works as well
(if available).

13 months agoRemove memory leak in fdopen (bug 31840)
Andreas Schwab [Tue, 4 Jun 2024 09:01:11 +0000 (11:01 +0200)] 
Remove memory leak in fdopen (bug 31840)

Deallocate the memory for the FILE structure when seeking to the end fails
in append mode.

Fixes: ea33158c96 ("Fix offset caching for streams and use it for ftell (BZ #16680)")
13 months agoAdd new AArch64 HWCAP2 definitions from Linux 6.9 to bits/hwcap.h
Joseph Myers [Tue, 4 Jun 2024 12:25:05 +0000 (12:25 +0000)] 
Add new AArch64 HWCAP2 definitions from Linux 6.9 to bits/hwcap.h

Linux 6.9 adds 15 new HWCAP2_* values for AArch64; add them to
bits/hwcap.h in glibc.

Tested with build-many-glibcs.py for aarch64-linux-gnu.

13 months agoAdd more NT_ARM_* constants from Linux kernel to elf.h
Joseph Myers [Tue, 4 Jun 2024 12:24:37 +0000 (12:24 +0000)] 
Add more NT_ARM_* constants from Linux kernel to elf.h

Linux 6.9 adds the ELF note type NT_ARM_FPMR.  Add this to glibc's
elf.h, along with the previously missed NT_ARM_SSVE, NT_ARM_ZA and
NT_ARM_ZT (added in older kernel versions).

Tested for x86_64.

13 months agostdlib: Describe __cxa_finalize usage in function comment
Florian Weimer [Mon, 3 Jun 2024 17:04:58 +0000 (19:04 +0200)] 
stdlib: Describe __cxa_finalize usage in function comment

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
13 months agoelf: Avoid some free (NULL) calls in _dl_update_slotinfo
Florian Weimer [Mon, 3 Jun 2024 08:49:40 +0000 (10:49 +0200)] 
elf: Avoid some free (NULL) calls in _dl_update_slotinfo

This has been confirmed to work around some interposed mallocs.  Here
is a discussion of the impact test ust/libc-wrapper/test_libc-wrapper
in lttng-tools:

  New TLS usage in libgcc_s.so.1, compatibility impact
  <https://inbox.sourceware.org/libc-alpha/8734v1ieke.fsf@oldenburg.str.redhat.com/>

Reportedly, this patch also papers over a similar issue when tcmalloc
2.9.1 is not compiled with -ftls-model=initial-exec.  Of course the
goal really should be to compile mallocs with the initial-exec TLS
model, but this commit appears to be a useful interim workaround.

Fixes commit d2123d68275acc0f061e73d5f86ca504e0d5a344 ("elf: Fix slow
tls access after dlopen [BZ #19924]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
14 months agox86: Add seperate non-temporal tunable for memset
Noah Goldstein [Fri, 24 May 2024 17:38:51 +0000 (12:38 -0500)] 
x86: Add seperate non-temporal tunable for memset

The tuning for non-temporal stores for memset vs memcpy is not always
the same. This includes both the exact value and whether non-temporal
stores are profitable at all for a given arch.

This patch add `x86_memset_non_temporal_threshold`. Currently we
disable non-temporal stores for non Intel vendors as the only
benchmarks showing its benefit have been on Intel hardware.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
14 months agox86: Improve large memset perf with non-temporal stores [RHEL-29312]
Noah Goldstein [Fri, 24 May 2024 17:38:50 +0000 (12:38 -0500)] 
x86: Improve large memset perf with non-temporal stores [RHEL-29312]

Previously we use `rep stosb` for all medium/large memsets. This is
notably worse than non-temporal stores for large (above a
few MBs) memsets.
See:
https://docs.google.com/spreadsheets/d/1opzukzvum4n6-RUVHTGddV6RjAEil4P2uMjjQGLbLcU/edit?usp=sharing
For data using different stategies for large memset on ICX and SKX.

Using non-temporal stores can be up to 3x faster on ICX and 2x faster
on SKX. Historically, these numbers would not have been so good
because of the zero-over-zero writeback optimization that `rep stosb`
is able to do. But, the zero-over-zero writeback optimization has been
removed as a potential side-channel attack, so there is no longer any
good reason to only rely on `rep stosb` for large memsets. On the flip
size, non-temporal writes can avoid data in their RFO requests saving
memory bandwidth.

All of the other changes to the file are to re-organize the
code-blocks to maintain "good" alignment given the new code added in
the `L(stosb_local)` case.

The results from running the GLIBC memset benchmarks on TGL-client for
N=20 runs:

Geometric Mean across the suite New / Old EXEX256: 0.979
Geometric Mean across the suite New / Old EXEX512: 0.979
Geometric Mean across the suite New / Old AVX2   : 0.986
Geometric Mean across the suite New / Old SSE2   : 0.979

Most of the cases are essentially unchanged, this is mostly to show
that adding the non-temporal case didn't add any regressions to the
other cases.

The results on the memset-large benchmark suite on TGL-client for N=20
runs:

Geometric Mean across the suite New / Old EXEX256: 0.926
Geometric Mean across the suite New / Old EXEX512: 0.925
Geometric Mean across the suite New / Old AVX2   : 0.928
Geometric Mean across the suite New / Old SSE2   : 0.924

So roughly a 7.5% speedup. This is lower than what we see on servers
(likely because clients typically have faster single-core bandwidth so
saving bandwidth on RFOs is less impactful), but still advantageous.

Full test-suite passes on x86_64 w/ and w/o multiarch.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
14 months agoelf: add note identifier for dlopen metadata
Luca Boccassi [Wed, 15 May 2024 00:10:35 +0000 (01:10 +0100)] 
elf: add note identifier for dlopen metadata

This new note type is defined at https://systemd.io/ELF_DLOPEN_METADATA/
and is used to list shared library dependencies loaded via dlopen().
Distro packagers can use this, via tools like those available at
https://github.com/systemd/package-notes to automatically generate
dependencies when building projects that make use of this
specification.

By defining the note id here we can use it in other projects as a
stable identifier, for example in 'readelf' to pretty-print its
content.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
14 months agoelf: update NT_FDO_PACKAGING_METADATA spec URL
Luca Boccassi [Wed, 15 May 2024 00:10:34 +0000 (01:10 +0100)] 
elf: update NT_FDO_PACKAGING_METADATA spec URL

Page was renamed some time ago, there's a redirect but better
to point to the right one

Signed-off-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
14 months agoLoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
Xi Ruoyao [Mon, 29 Apr 2024 07:26:24 +0000 (15:26 +0800)] 
LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW

Clang inline-asm parser does not allow using "$r0" in
movfcsr2gr/movgr2fcsr, so everything using _FPU_{GET,SET}CW is now
failing to build with Clang on LoongArch.  As we now requires Binutils
>= 2.41 which supports using "$fcsr0" here, use it instead of "$r0" to
fix the issue.

Link: https://github.com/loongson-community/discussions/issues/53#issuecomment-2081507390
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4142b2368353
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
14 months agox86_64: Reformat elf_machine_rela
Xin Wang [Mon, 27 May 2024 19:06:41 +0000 (03:06 +0800)] 
x86_64: Reformat elf_machine_rela

A space is added before the left bracket of the x86_64 elf_machine_rela
function, in order to harmonize with the rest of the implementation of
the function and to make it easier to retrieve the function. The lines
where the function definition is located has been re-indented, as well
as its left curly bracket placed in the correct position.

Signed-off-by: Xin Wang <yw987194828@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
14 months agoi386: Disable Intel Xeon Phi tests for GCC 15 and above (BZ 31782)
Sunil K Pandey [Mon, 27 May 2024 17:08:18 +0000 (10:08 -0700)] 
i386: Disable Intel Xeon Phi tests for GCC 15 and above (BZ 31782)

This patch disables Intel Xeon Phi tests for GCC 15 and above.

GCC 15 removed Intel Xeon Phi ISA support.
commit e1a7e2c54d52d0ba374735e285b617af44841ace
Author: Haochen Jiang <haochen.jiang@intel.com>
Date:   Mon May 20 10:43:44 2024 +0800

    i386: Remove Xeon Phi ISA support

Fixes BZ 31782.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
14 months agodifftime is pure, not const
Paul Eggert [Mon, 27 May 2024 00:37:17 +0000 (17:37 -0700)] 
difftime is pure, not const

Because difftime's behavior depends on the floating-point environment,
the function is pure, not const (BZ 31802).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
14 months agoparse_fdinfo: Don't advance pointer twice [BZ #31798]
H.J. Lu [Sat, 25 May 2024 12:13:41 +0000 (05:13 -0700)] 
parse_fdinfo: Don't advance pointer twice [BZ #31798]

pidfd_getpid.c has

      /* Ignore invalid large values.  */
      if (INT_MULTIPLY_WRAPV (10, n, &n)
          || INT_ADD_WRAPV (n, *l++ - '0', &n))
        return -1;

For GCC older than GCC 7, INT_ADD_WRAPV(a, b, r) is defined as

   _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)

and *l++ - '0' is evaluated twice.  Fix BZ #31798 by moving "l++" out of
the if statement.  Tested with GCC 6.4 and GCC 14.1.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
14 months agoelf/Makefile: Split and sort PIE tests
H.J. Lu [Sat, 25 May 2024 21:53:30 +0000 (14:53 -0700)] 
elf/Makefile: Split and sort PIE tests

Put each item on a separate line and sort PIE tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
14 months agoRevert "Test fscanf of long double without <stdio.h>"
H.J. Lu [Fri, 24 May 2024 23:24:49 +0000 (16:24 -0700)] 
Revert "Test fscanf of long double without <stdio.h>"

This reverts commit 30a745450e01e4c6f484dc691c16a54a6ea72288.

On ppc64le, without <stdio.h>, vfscanf is used and with <stdio.h>
__isoc23_vfscanfieee128 is used.  I am reverting this since it doesn't
work on all targets.