]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
6 months agoFix license typo induced by update-copyrighyt
Paul Eggert [Wed, 1 Jan 2025 19:07:29 +0000 (11:07 -0800)] 
Fix license typo induced by update-copyrighyt

6 months agoUpdate copyright dates not handled by scripts/update-copyrights
Paul Eggert [Wed, 1 Jan 2025 18:31:31 +0000 (10:31 -0800)] 
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.

6 months agoUpdate copyright in generated files by running "make"
Paul Eggert [Wed, 1 Jan 2025 18:25:08 +0000 (10:25 -0800)] 
Update copyright in generated files by running "make"

6 months agoUpdate copyright dates with scripts/update-copyrights
Paul Eggert [Wed, 1 Jan 2025 18:14:45 +0000 (10:14 -0800)] 
Update copyright dates with scripts/update-copyrights

6 months agoPass glibc pre-commit checks
Paul Eggert [Wed, 1 Jan 2025 19:16:35 +0000 (11:16 -0800)] 
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.

6 months agomlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
Xi Ruoyao [Thu, 26 Dec 2024 04:51:18 +0000 (12:51 +0800)] 
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>
6 months agoelf: Add glibc.rtld.execstack
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:45 +0000 (14:36 -0300)] 
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>
6 months agoelf: Add tst-execstack-prog-static
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:44 +0000 (14:36 -0300)] 
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>
6 months agoelf: Do not change stack permission on dlopen/dlmopen
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:43 +0000 (14:36 -0300)] 
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>
6 months agoelf: Cleanup and improve tst-execstack
Adhemerval Zanella [Thu, 26 Dec 2024 14:25:28 +0000 (11:25 -0300)] 
elf: Cleanup and improve tst-execstack

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoUse GCC 14 branch in build-many-glibcs.py
H.J. Lu [Tue, 31 Dec 2024 07:56:23 +0000 (15:56 +0800)] 
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>
7 months agoINSTALL, NEWS: Document requirement of gawk with MPFR support
Andreas K. Hüttel [Fri, 27 Dec 2024 18:31:07 +0000 (19:31 +0100)] 
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>
7 months agoMention CORE-MATH optimize routines on NEWS
Adhemerval Zanella [Thu, 26 Dec 2024 12:11:06 +0000 (09:11 -0300)] 
Mention CORE-MATH optimize routines on NEWS

Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
7 months agox86-64: Reorder dynamic linker list in ldd script (bug 32508)
Florian Weimer [Mon, 30 Dec 2024 11:41:51 +0000 (12:41 +0100)] 
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>
7 months agonptl: hppa: replace __get_cr27 with __thread_pointer
Michael Jeanson [Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)] 
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>
7 months agonptl: Add <thread_pointer.h> for hppa
Michael Jeanson [Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)] 
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>
7 months agolibio: asprintf should write NULL upon failure
Florian Weimer [Fri, 27 Dec 2024 08:17:41 +0000 (09:17 +0100)] 
libio: asprintf should write NULL upon failure

This was suggested most recently by Solar Designer, noting
that code replacing vsprintf with vasprintf in a security fix
was subtly wrong:

  Re: GStreamer Security Advisory 2024-0003: Orc compiler
  stack-based buffer overflow
  <https://www.openwall.com/lists/oss-security/2024/07/26/2>

Previous libc-alpha discussions:

  I: [PATCH] asprintf error handling fix
  <https://inbox.sourceware.org/libc-alpha/20011205185828.GA8376@ldv.office.alt-linux.org/>

  asprintf() issue
  <https://inbox.sourceware.org/libc-alpha/CANSoFxt-cdc-+C4u-rTENMtY4X9RpRSuv+axDswSPxbDgag8_Q@mail.gmail.com/>

I don't think we need a compatibility symbol for this.  As the
GStreamer example shows, this change is much more likely to fix bugs
than cause compatibility issues.

Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
Suggested-by: Archie Cobbs <archie.cobbs@gmail.com>
Suggested-by: Solar Designer <solar@openwall.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agonptl: More useful padding in struct pthread
Florian Weimer [Tue, 17 Dec 2024 08:20:20 +0000 (09:20 +0100)] 
nptl: More useful padding in struct pthread

The previous use of padding within a union made it impossible to
re-use the padding for GLIBC_PRIVATE ABI preservation because
tcbhead_t could use up all of the padding (as was historically the
case on x86-64).  Allocating padding unconditionally addresses this
issue.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Remove the GET_ADDR_ARGS and related macros from the TLS code
Florian Weimer [Mon, 23 Dec 2024 12:55:49 +0000 (13:55 +0100)] 
elf: Remove the GET_ADDR_ARGS and related macros from the TLS code

This was used to manage an IA-64 ABI divergence is no longere needed
after the IA-64 removal.

(It should be possible to encode all the required information in
one machine word, so the pointer indirection is really unnecessary.
Technically, none of this is part of the ABI, so perhaps it's
possible to do this retroactively.  See bug 27404.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agohurd: Avoid asm statements which return
Samuel Thibault [Thu, 26 Dec 2024 22:11:28 +0000 (23:11 +0100)] 
hurd: Avoid asm statements which return

They are not supposed to change flow control.

This fixes miscompilation with gcc 14.2.0 which then drops code, see
https://lists.gnu.org/archive/html/bug-hurd/2024-11/msg00145.html

7 months agobuild-many-glibcs.py: Add --exclude option
H.J. Lu [Tue, 24 Dec 2024 21:05:31 +0000 (05:05 +0800)] 
build-many-glibcs.py: Add --exclude option

m68k-linux-gnu-coldfire-soft GCC and glibc often won't build due to

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103370

which results in build-many-glibcs.py failure.  Add an option, --exclude,
to exclude some targets.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio-common: Tweak comment in Makefile
Sam James [Tue, 24 Dec 2024 11:38:09 +0000 (11:38 +0000)] 
stdio-common: Tweak comment in Makefile

Followup to 5a96da210c15e18c3c5298dc23a9e2e57691b6c6.

7 months agostdio-common: Use clang with bugfix for bug28
Dmitry Chestnykh [Tue, 24 Dec 2024 08:52:35 +0000 (11:52 +0300)] 
stdio-common: Use clang with bugfix for bug28

The issue that was the cause of hang was fixed in upstream.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoNEWS: Mention testing glibc build with a different set of compilers
H.J. Lu [Mon, 23 Dec 2024 21:20:43 +0000 (05:20 +0800)] 
NEWS: Mention testing glibc build with a different set of compilers

Also document C and C++ compilers used to test glibc should come from
the same set of compilers.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agosupport: Add support_record_failure_barrier
Florian Weimer [Mon, 23 Dec 2024 12:57:55 +0000 (13:57 +0100)] 
support: Add support_record_failure_barrier

This can be used to stop execution after a TEST_COMPARE_BLOB
failure, for example.

7 months agoio: statx, fstatat: Drop nonnull attribute on the path argument
Miao Wang [Mon, 23 Dec 2024 09:30:43 +0000 (10:30 +0100)] 
io: statx, fstatat: Drop nonnull attribute on the path argument

Since Linux 6.11 the kernel allows path to be NULL if flags &
AT_EMPTY_PATH.  Let's allow users to take the advantage if they don't
care running on old kernels.

Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agoconfigure: Improve configure output for C++ Compiler
H.J. Lu [Mon, 23 Dec 2024 00:11:58 +0000 (08:11 +0800)] 
configure: Improve configure output for C++ Compiler

Change configure output for C++ Compiler from

...
checking -finput-charset=ascii in testing... -finput-charset=ascii
checking -finput-charset=ascii in testing... -finput-charset=ascii
...

to

...
checking -finput-charset=ascii in testing... -finput-charset=ascii
checking g++ -finput-charset=ascii in testing... -finput-charset=ascii
...

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agogetaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]
H.J. Lu [Tue, 17 Dec 2024 07:18:36 +0000 (15:18 +0800)] 
getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]

Add valid_decimal_value to check valid decimal value in a string to
avoid uninitialized endp in add_prefixlist and gaiconf_init as reported
by Clang 19:

./getaddrinfo.c:1884:11: error: variable 'endp' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
 1884 |       && (cp == NULL
      |           ^~~~~~~~~~
./getaddrinfo.c:1887:11: note: uninitialized use occurs here
 1887 |       && *endp == '\0'
      |           ^~~~
./getaddrinfo.c:1884:11: note: remove the '||' if its condition is always false
 1884 |       && (cp == NULL
      |           ^~~~~~~~~~
 1885 |           || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
      |           ~~
./getaddrinfo.c:1875:13: note: initialize the variable 'endp' to silence this warning
 1875 |   char *endp;
      |             ^
      |              = NULL

This fixes BZ #32465.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agohtl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait into...
gfleury [Thu, 19 Dec 2024 20:37:27 +0000 (22:37 +0200)] 
htl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait into libc.

Message-ID: <20241219203727.669825-9-gfleury@disroot.org>

7 months agohtl: move __pthread_mutex_checklocked into libc.
gfleury [Thu, 19 Dec 2024 20:37:26 +0000 (22:37 +0200)] 
htl: move __pthread_mutex_checklocked into libc.

move out __getpid from pt-mutex.h
and in pt-mutex-* include <unistd.h> where
__getpid was called

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-8-gfleury@disroot.org>

7 months agohtl: move __pthread_timedblock, __pthread_timedblock_intr, __pthread_block, __pthread...
gfleury [Thu, 19 Dec 2024 20:37:25 +0000 (22:37 +0200)] 
htl: move __pthread_timedblock, __pthread_timedblock_intr, __pthread_block, __pthread_block_intr into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-7-gfleury@disroot.org>

7 months agohtl: move pthread_cond_signal into libc.
gfleury [Thu, 19 Dec 2024 20:37:24 +0000 (22:37 +0200)] 
htl: move pthread_cond_signal into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-6-gfleury@disroot.org>

7 months agohtl: move pthread_cond_broadcast into libc.
gfleury [Thu, 19 Dec 2024 20:37:23 +0000 (22:37 +0200)] 
htl: move pthread_cond_broadcast into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-5-gfleury@disroot.org>

7 months agohtl: move pthread_cond_destroy into libc.
gfleury [Thu, 19 Dec 2024 20:37:22 +0000 (22:37 +0200)] 
htl: move pthread_cond_destroy into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-4-gfleury@disroot.org>

7 months agohtl: move __pthread_wakeup into libc.
gfleury [Thu, 19 Dec 2024 20:37:21 +0000 (22:37 +0200)] 
htl: move __pthread_wakeup into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-3-gfleury@disroot.org>

7 months agohtl: move pthread_cond_init into libc.
gfleury [Thu, 19 Dec 2024 20:37:20 +0000 (22:37 +0200)] 
htl: move pthread_cond_init into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-2-gfleury@disroot.org>

7 months agoassert/test-assert-2.c: Include <unistd.h>
Samuel Thibault [Sun, 22 Dec 2024 22:33:27 +0000 (23:33 +0100)] 
assert/test-assert-2.c: Include <unistd.h>

For _exit declaration.

7 months agostdio-common: Suppress Clang warnings on scanf13.c
H.J. Lu [Sun, 22 Dec 2024 21:12:03 +0000 (05:12 +0800)] 
stdio-common: Suppress Clang warnings on scanf13.c

Suppress Clang warnings on stdio-common/scanf13.c:

1. Before this commit:

scanf13.c:43:17: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                    ~~~~^
scanf13.c:43:22: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                         ~~~~^
scanf13.c:43:50: error: data argument not used by format string [-Werror,-Wformat-extra-args]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~                ^
scanf13.c:145:27: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                     ~~~~~~^
scanf13.c:145:31: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                            ~~~^
scanf13.c:145:43: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                    ~~~~~~~~~~~~~~         ^
scanf13.c:161:31: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                         ~~~~~~^
scanf13.c:161:42: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                                ~~~~~~~~~~^
scanf13.c:161:53: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                                           ~~~~~~~~~~^
scanf13.c:162:15: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  162 |               &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                      ^
10 errors generated.

2. With DIAG_IGNORE_NEEDS_COMMENT_CLANG changes in stdio-common/scanf13.c:

scanf13.c:28:40: error: 'sscanf' may overflow; destination buffer in argument 4 has size 8, but the corresponding specifier may require size 11 [-Werror,-Wfortify-source]
   28 |               "A%ms%10ms%4m[bcd]%4mcB", &sp1, &sp2, &sp3, &sp4) != 4)
      |                                               ^
scanf13.c:94:34: error: 'sscanf' may overflow; destination buffer in argument 3 has size 8, but the corresponding specifier may require size 2049 [-Werror,-Wfortify-source]
   94 |   if (sscanf (buf, "%2048ms%mc", &sp3, &sp4) != 2)
      |                                  ^
scanf13.c:110:61: error: 'sscanf' may overflow; destination buffer in argument 4 has size 8, but the corresponding specifier may require size 1501 [-Werror,-Wfortify-source]
  110 |   if (sscanf (buf, "%4mc%1500m[dr/]%548m[abc/d]%3mc", &sp1, &sp2, &sp3, &sp4)
      |                                                             ^
scanf13.c:110:67: error: 'sscanf' may overflow; destination buffer in argument 5 has size 8, but the corresponding specifier may require size 549 [-Werror,-Wfortify-source]
  110 |   if (sscanf (buf, "%4mc%1500m[dr/]%548m[abc/d]%3mc", &sp1, &sp2, &sp3, &sp4)
      |                                                                   ^
4 errors generated.

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>
7 months agostring: Suppress Clang warnings on tester.c
H.J. Lu [Sun, 22 Dec 2024 21:12:02 +0000 (05:12 +0800)] 
string: Suppress Clang warnings on tester.c

Add a configure check for -Wno-fortify-source to suppress Clang warnings
on string/tester.c, like:

tester.c:385:10: error: 'strncat' size argument is too large; destination buffer has size 50, but size argument is 99 [-Werror,-Wfortify-source]
  385 |   check (strncat (one, "lmn", 99) == one, 1);   /* Returned value. */

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAdd a reference to Clang /usr/include/tgmath.h dependency
H.J. Lu [Sun, 22 Dec 2024 21:12:01 +0000 (05:12 +0800)] 
Add a reference to Clang /usr/include/tgmath.h dependency

The fake Clang /usr/include/tgmath.h dependency bug is:

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

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoSuppress Clang -Wimplicit-fallthrough warnings
H.J. Lu [Sun, 22 Dec 2024 21:12:00 +0000 (05:12 +0800)] 
Suppress Clang -Wimplicit-fallthrough warnings

Since Clang doesn't properly handle

/* FALLTHROUGH */

in elf/tst-align2.c nor

/* fall through */

in misc/tst-tsearch.c

tst-align2.c:100:9: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
  100 |         case 'A':
      |         ^
tst-align2.c:100:9: note: insert '__attribute__((fallthrough));' to silence this warning
  100 |         case 'A':
      |         ^
      |         __attribute__((fallthrough));
tst-align2.c:100:9: note: insert 'break;' to avoid fall-through
  100 |         case 'A':
      |         ^
      |         break;

suppress them when compiled with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio: Suppress -Wformat only for gcc in tst-sprintf-errno.c
Adhemerval Zanella [Sun, 22 Dec 2024 21:11:59 +0000 (05:11 +0800)] 
stdio: Suppress -Wformat only for gcc in tst-sprintf-errno.c

Since Clang doesn't support

DIAG_IGNORE_NEEDS_COMMENT (11, "-Wformat=");

and for unknown reasons, it doesn't warn the %#m specifier, suppress
-Wformat only for gcc in tst-sprintf-errno.c.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoinclude/sys/cdefs.h: Add __attribute_optimization_barrier__
Adhemerval Zanella [Sun, 22 Dec 2024 21:11:58 +0000 (05:11 +0800)] 
include/sys/cdefs.h: Add __attribute_optimization_barrier__

Add __attribute_optimization_barrier__ to disable inlining and cloning on a
function.  For Clang, expand it to

__attribute__ ((optnone))

Otherwise, expand it to

__attribute__ ((noinline, clone))

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoassert: Use __writev in assert.c [BZ #32492]
DJ Delorie [Sun, 22 Dec 2024 04:12:41 +0000 (23:12 -0500)] 
assert: Use __writev in assert.c [BZ #32492]

Replace writev with __writev in assert/assert.c.  This fixes [BZ #32492].

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoFix build without stack protector [BZ #32494]
H.J. Lu [Sun, 22 Dec 2024 19:58:54 +0000 (03:58 +0800)] 
Fix build without stack protector [BZ #32494]

Without stack protector, inhibit_stack_protector is undefined during build:

In file included from <command-line>:
./../include/libc-symbols.h:665:3: error: expected ';' before '__typeof'
  665 |   __typeof (type_name) *name##_ifunc (__VA_ARGS__)
         \
      |   ^~~~~~~~
./../include/libc-symbols.h:676:3: note: in expansion of macro
'__ifunc_resolver'
  676 |   __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__)
      |   ^~~~~~~~~~~~~~~~
./../include/libc-symbols.h:703:3: note: in expansion of macro '__ifunc_args'
  703 |   __ifunc_args (type_name, name, expr, init, arg)
      |   ^~~~~~~~~~~~
./../include/libc-symbols.h:790:3: note: in expansion of macro '__ifunc'
  790 |   __ifunc (redirected_name, name, expr, void, INIT_ARCH)
      |   ^~~~~~~
../sysdeps/x86_64/multiarch/memchr.c:29:1: note: in expansion of macro
'libc_ifunc_redirected'
   29 | libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR ());
      | ^~~~~~~~~~~~~~~~~~~~~

1. Fix a typo in include/libc-symbols.h to define inhibit_stack_protector
for build.
2. Don't include <config.h> in include/libc-symbols.h since it has been
included in include/libc-misc.h.
3. Change #include "libc-misc.h" to #include <libc-misc.h> in
string/test-string.h.

This fixes BZ #32494.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoCheck if TEST_CC supports -Wno-restrict before using it
Adhemerval Zanella [Thu, 27 Jul 2023 18:49:52 +0000 (15:49 -0300)] 
Check if TEST_CC supports -Wno-restrict before using it

Check if TEST_CC supports -Wno-restrict before using it to avoid Clang
error:

error: unknown warning option '-Wno-restrict' [-Werror,-Wunknown-warning-option]

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agohppa: Simplify handling of sanity check errors in clone.S.
John David Anglin [Sun, 22 Dec 2024 14:58:02 +0000 (09:58 -0500)] 
hppa: Simplify handling of sanity check errors in clone.S.

This simplifies the handling of sanity check errors in clone.S.
Adjusted a couple of comments to reflect current code.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
7 months agohppa: add cacheflush() syscall wrapper
John David Anglin [Sun, 22 Dec 2024 14:51:54 +0000 (09:51 -0500)] 
hppa: add cacheflush() syscall wrapper

The hppa Linux kernel supports the cacheflush() syscall
since version 6.5. This adds the glibc syscall wrapper.

Signed-off-by: Helge Deller <deller@gmx.de>
---
v2: This patch was too late in release cycle for GLIBC_2.40,
    so update now to GLIBC_2.41 instead.

7 months agohppa: Update libm-test-ulps
John David Anglin [Sun, 22 Dec 2024 14:45:34 +0000 (09:45 -0500)] 
hppa: Update libm-test-ulps

Signed-off-by: John David Anglin <dave.anglin@bell.net>
7 months agohurd: make mprotect translate KERN_PROTECTION_FAILURE to EACCESS
Samuel Thibault [Sun, 22 Dec 2024 10:40:18 +0000 (11:40 +0100)] 
hurd: make mprotect translate KERN_PROTECTION_FAILURE to EACCESS

Suggested-by: Sergey Bugaev <bugaevc@gmail.com>
7 months agoCompile tst-deadline.c with -Wno-ignored-attributes for Clang
H.J. Lu [Thu, 19 Dec 2024 21:52:56 +0000 (05:52 +0800)] 
Compile tst-deadline.c with -Wno-ignored-attributes for Clang

Since tst-deadline.c is an internal test, compile tst-deadline.c with
-Wno-ignored-attributes for Clang to silence -Werror,-Wunknown-attributes
errors.  Also suppress -Wmaybe-uninitialized only for GCC in net-internal.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agomalloc: Only enable -Waggressive-loop-optimizations suppression for gcc
Adhemerval Zanella [Fri, 25 Mar 2022 12:00:12 +0000 (09:00 -0300)] 
malloc: Only enable -Waggressive-loop-optimizations suppression for gcc

Reviewed-by: Sam James <sam@gentoo.org>
7 months agoSuppress -Wmaybe-uninitialized only for GCC
H.J. Lu [Thu, 19 Dec 2024 21:02:14 +0000 (05:02 +0800)] 
Suppress -Wmaybe-uninitialized only for GCC

Clang doesn't support -Wmaybe-uninitialized.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoSuppress Clang -Wgnu-folding-constant warnings
H.J. Lu [Thu, 19 Dec 2024 20:51:03 +0000 (04:51 +0800)] 
Suppress Clang -Wgnu-folding-constant warnings

Suppress Clang -Wgnu-folding-constant warnings, like

tst-freopen.c:44:13: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
   44 |   char temp[strlen (test) + 1];
      |             ^~~~~~~~~~~~~~~~~

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio: Suppress clang warnings for tst-vprintf-width-i18n.c
Adhemerval Zanella [Fri, 3 Jun 2022 13:43:42 +0000 (10:43 -0300)] 
stdio: Suppress clang warnings for tst-vprintf-width-i18n.c

Clang issues the following warning:

  tst-vfprintf-width-i18n.c:51:34: error: invalid conversion specifier '1'
  [-Werror,-Wformat-invalid-specifier]
    TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16);
                                 ~~^

since it does not how to handle %I.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio: Fix clang warnings on tests
Adhemerval Zanella [Thu, 27 Jul 2023 18:27:08 +0000 (15:27 -0300)] 
stdio: Fix clang warnings on tests

clang does not support 'I' specifier and handles it as a 'length
modifier'.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agomath: Fix clang warnings for math/test-tgmath-ret.c
Adhemerval Zanella [Tue, 15 Mar 2022 18:33:02 +0000 (15:33 -0300)] 
math: Fix clang warnings for math/test-tgmath-ret.c

clang warns that since the global variables are only used to function
calls (without being actually used), they are not needed and will
not be emitted.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoSuppress Clang warning on adding an integer to a string
Adhemerval Zanella [Fri, 25 Mar 2022 14:23:35 +0000 (11:23 -0300)] 
Suppress Clang warning on adding an integer to a string

Suppress Clang warning on adding an integer to a string, like:

tst-iconv-sticky-input-error.c:125:42: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
  125 |                 expected_output = "ABXY" + skip;
      |                                   ~~~~~~~^~~~~~
tst-iconv-sticky-input-error.c:125:42: note: use array indexing to silence this warning
  125 |                 expected_output = "ABXY" + skip;
      |                                          ^
      |                                   &      [     ]

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio: Suppress %Z format for clang
Adhemerval Zanella [Thu, 1 Sep 2022 12:29:23 +0000 (09:29 -0300)] 
stdio: Suppress %Z format for clang

clang does not handle %Z on print, and just suppressing
-Wformat-invalid-specifier might trigger another warning for extra
arguments (since %Z is ignored).  So suppress -Wformat-extra-args
as well.

For tst-fphex.c a heavy hammer is used since the printf is more
complex and clang throws a more generic warning.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio: Suppress clang warnings for tst-unlockedio.c
Adhemerval Zanella [Thu, 24 Mar 2022 19:03:16 +0000 (16:03 -0300)] 
stdio: Suppress clang warnings for tst-unlockedio.c

Suppress the following -Wgnu-folding-constant and -Wliteral-conversion
warnings from Clang:

  tst-unlockedio.c:35:12: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
   35 |   char buf[strlen (blah) + 1];
      |            ^~~~~~~~~~~~~~~~~

  tst-unlockedio.c:63:36: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from -0 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (blah, 0, -0.0, fp) != 0
           ~~~~~~~~~~~~~~~           ^~~~
  tst-unlockedio.c:61:33: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (--cp, 0.25, 16, fp) != 0
           ~~~~~~~~~~~~~~~        ^~~~
  tst-unlockedio.c:59:37: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (cp++, 16, 0.25, fp) != 0
           ~~~~~~~~~~~~~~~            ^~~~
  tst-unlockedio.c:116:34: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from -0 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (buf, 0, -0.0, fp) != 0
           ~~~~~~~~~~~~~~          ^~~~
  tst-unlockedio.c:114:32: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (--wp, 0.25, 16, fp) != 0
           ~~~~~~~~~~~~~~        ^~~~
  tst-unlockedio.c:112:36: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (wp++, 16, 0.25, fp) != 0
           ~~~~~~~~~~~~~~            ^~~~

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agolocaledata: Fix clang warnings on tests
Adhemerval Zanella [Tue, 15 Mar 2022 18:29:47 +0000 (15:29 -0300)] 
localedata: Fix clang warnings on tests

clang does not support 'I' specifier and handles it as a 'length
modifier'.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoelf: Suppress clang warning on tst-unique4
Adhemerval Zanella [Fri, 25 Mar 2022 14:21:33 +0000 (11:21 -0300)] 
elf: Suppress clang warning on tst-unique4

clang warns that the instantiation of the variable is required,
but no definition is available.  They are implemented on
tst-unique4lib.so.

Checked on x86_64-linux-gnu.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoelf: Enable tst-dlopen-nodelete-reloc if TEST_CXX supports STB_GNU_UNIQUE
H.J. Lu [Thu, 19 Dec 2024 20:32:49 +0000 (04:32 +0800)] 
elf: Enable tst-dlopen-nodelete-reloc if TEST_CXX supports STB_GNU_UNIQUE

tst-dlopen-nodelete-reloc requires STB_GNU_UNIQUE support so that NODELETE
is propagated by do_lookup_unique.  Enable it only if TEST_CXX supports
STB_GNU_UNIQUE,

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoelf: Check PDE load address with non-empty text section
H.J. Lu [Sun, 22 Dec 2024 00:31:25 +0000 (08:31 +0800)] 
elf: Check PDE load address with non-empty text section

Check PDE load address with non-empty text section:

.globl _start
_start:
.globl __start
.byte 0

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agox86: Define __HAVE_FLOAT128 for Clang and use __builtin_*f128 code path
Fangrui Song [Sun, 10 Oct 2021 21:38:00 +0000 (14:38 -0700)] 
x86: Define __HAVE_FLOAT128 for Clang and use __builtin_*f128 code path

Clang supports __builtin_fabsf128 (despite not supporting _Float128) but
it does not support __builtin_fabsq.  Fallback to back to
`typedef __float128 _Float128;` it clang is used.

Originally developed by Fangrui Song <maskray@google.com>.
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAdd clang specific warning suppression macros
Adhemerval Zanella [Tue, 12 Sep 2023 18:45:24 +0000 (15:45 -0300)] 
Add clang specific warning suppression macros

Four new macros are added:

  * DIAG_{PUSH,POP}_NEEDS_COMMENT_CLANG are similar to
    DIAG_{PUSH,POP}_NEEDS_COMMENT, but enable clang specific pragmas to
    handle warnings for options only supported by clang.

  * DIAG_IGNORE_NEEDS_COMMENT_{CLANG,GCC} are similar to
    DIAG_IGNORE_NEEDS_COMMENT, but enable the warning suppression only
    for the referenced compiler.

Reviewed-by: Sam James <sam@gentoo.org>
7 months agox86: Use inhibit_stack_protector on tst-ifunc-isa.h
Adhemerval Zanella [Thu, 25 Aug 2022 12:48:57 +0000 (09:48 -0300)] 
x86: Use inhibit_stack_protector on tst-ifunc-isa.h

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoelf: Compile test modules with -fsemantic-interposition
H.J. Lu [Tue, 17 Dec 2024 23:24:38 +0000 (07:24 +0800)] 
elf: Compile test modules with -fsemantic-interposition

Compiler may default to -fno-semantic-interposition. But some elf test
modules must be compiled with -fsemantic-interposition to function properly.
Add a TEST_CC check for -fsemantic-interposition and use it on elf test
modules.  This fixed

FAIL: elf/tst-dlclose-lazy
FAIL: elf/tst-pie1
FAIL: elf/tst-plt-rewrite1
FAIL: elf/unload4

when Clang 19 is used to test glibc.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agotst-printf-bz18872.sh: stdio: Use __attribute__ ((optnone)) for Clang
Adhemerval Zanella [Thu, 24 Mar 2022 18:54:10 +0000 (15:54 -0300)] 
tst-printf-bz18872.sh: stdio: Use __attribute__ ((optnone)) for Clang

Use

__attribute__ ((optnone))

instead of

__attribute__ ((optimize ("-O0")))

to disable optimization for Clang.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoHandle pragma GCC optimize for clang
Adhemerval Zanella [Thu, 24 Mar 2022 19:17:59 +0000 (16:17 -0300)] 
Handle pragma GCC optimize for clang

Reviewed-by: Sam James <sam@gentoo.org>
7 months agodirent: Remove variable length array structure for tst-getdents64.c
Adhemerval Zanella [Fri, 25 Mar 2022 12:03:03 +0000 (09:03 -0300)] 
dirent: Remove variable length array structure for tst-getdents64.c

Clang emits the following warnings:

  ../sysdeps/unix/sysv/linux/tst-getdents64.c:111:18: error: fields must
  have a constant size: 'variable length array in structure' extension
  will never be supported
              char buffer[buffer_size];
                   ^

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAdd include/libc-misc.h
H.J. Lu [Thu, 19 Dec 2024 21:31:05 +0000 (05:31 +0800)] 
Add include/libc-misc.h

Add include/libc-misc.h to provide miscellaneous definitions for both
glibc build and test:

1. Move inhibit_stack_protector to libc-misc.h and add Clang support.
2. Add test_inhibit_stack_protector for glibc testing.
3. Move inhibit_loop_to_libcall to libc-misc.h.
4. Add test_cc_inhibit_loop_to_libcall to handle TEST_CC != CC and
replace inhibit_loop_to_libcall with test_cc_inhibit_loop_to_libcall
in glibc tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAdd test-config-cflags-float-store for -ffloat-store
H.J. Lu [Sun, 15 Dec 2024 13:24:14 +0000 (21:24 +0800)] 
Add test-config-cflags-float-store for -ffloat-store

Clang doesn't support -ffloat-store:

clang: error: optimization flag '-ffloat-store' is not supported [-Werror,-Wignored-optimization-argument]

Define test-config-cflags-float-store for -ffloat-store and use it in
math/Makefile for testing.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agolocaledata: Use hexadecimal character escape on tests
Adhemerval Zanella [Mon, 28 Mar 2022 18:50:07 +0000 (15:50 -0300)] 
localedata: Use hexadecimal character escape on tests

Instead of latin1 ones.

Reviewed-by: Sam James <sam@gentoo.org>
7 months agotst-atomic.c: Mark as UNSUPPORTED when compiled with Clang
H.J. Lu [Mon, 16 Dec 2024 10:56:55 +0000 (18:56 +0800)] 
tst-atomic.c: Mark as UNSUPPORTED when compiled with Clang

Since Clang can't remove the dead statement and issues an error:

tst-atomic.c:463:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*&mem)' (aka 'int')
  463 |   if (catomic_exchange_and_add (&mem, 11) != 2
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst-atomic.c:487:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int')
  487 |   if (catomic_increment_val (&mem) != 3)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/atomic.h:313:38: note: expanded from macro 'catomic_increment_val'
  313 | # define catomic_increment_val(mem) (catomic_exchange_and_add ((mem), 1) + 1)
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst-atomic.c:501:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int')
  501 |   if (catomic_decrement_val (&mem) != 15)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/atomic.h:340:38: note: expanded from macro 'catomic_decrement_val'
  340 | # define catomic_decrement_val(mem) (catomic_exchange_and_add ((mem), -1) - 1)
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

mark tst-atomic.c as UNSUPPORTED when compiled with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoEnable execstack tests only if compiler supports trampoline
H.J. Lu [Mon, 16 Dec 2024 11:20:54 +0000 (19:20 +0800)] 
Enable execstack tests only if compiler supports trampoline

Since trampoline is required to test execstack, enable execstack tests
only if compiler supports trampoline.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agox86: Include test-flt-eval-method-387 if -mfpmath=387 works
H.J. Lu [Thu, 19 Dec 2024 04:08:00 +0000 (12:08 +0800)] 
x86: Include test-flt-eval-method-387 if -mfpmath=387 works

Since Clang doesn't support -mfpmath=387 on x86-64, on x86, include
test-flt-eval-method-387 only if -mfpmath=387 works.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agox86-64: Disable libmvec ABI test for Clang
H.J. Lu [Sun, 15 Dec 2024 21:11:26 +0000 (05:11 +0800)] 
x86-64: Disable libmvec ABI test for Clang

Unlike GCC, libmvec support in Clang is hard-coded.  Clang doesn't use
macros defined in <bits/libm-simd-decl-stubs.h> to support new libmvec
functions added to glibc and can't vectorize all test loops to test
libmvec ABI:

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

disable libmvec ABI test for Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoRemove Clang /usr/include/tgmath.h dependency
H.J. Lu [Sun, 15 Dec 2024 23:30:44 +0000 (07:30 +0800)] 
Remove Clang /usr/include/tgmath.h dependency

Remove the /usr/include/tgmath.h dependency generated by Clang even though
Clang never reads /usr/include/tgmath.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoDon't redefine INFINITY nor NAN
H.J. Lu [Sun, 15 Dec 2024 01:56:34 +0000 (09:56 +0800)] 
Don't redefine INFINITY nor NAN

Since math/math.h isn't a system header, clang issues errors:

In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:91:11: error: 'INFINITY' macro redefined [-Werror,-Wmacro-redefined]
   91 | #  define INFINITY (__builtin_inff ())
      |           ^
/usr/bin/../lib/clang/19/include/float.h:173:11: note: previous definition is here
  173 | #  define INFINITY (__builtin_inff())
      |           ^
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:98:11: error: 'NAN' macro redefined [-Werror,-Wmacro-redefined]
   98 | #  define NAN (__builtin_nanf (""))
      |           ^
/usr/bin/../lib/clang/19/include/float.h:174:11: note: previous definition is here
  174 | #  define NAN (__builtin_nanf(""))

Don't define INFINITY nor NAN if they are defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoCheck Clang 12 for __builtin_complex
H.J. Lu [Sun, 22 Dec 2024 00:04:27 +0000 (08:04 +0800)] 
Check Clang 12 for __builtin_complex

Since __builtin_complex was added to Clang 12, support __builtin_complex
for Clang 12.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoUse -finput-charset=ascii only if supported
H.J. Lu [Sun, 22 Dec 2024 00:04:25 +0000 (08:04 +0800)] 
Use -finput-charset=ascii only if supported

Check if -finput-charset=ascii is supported before using it in
check-installed-headers.sh.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoconform: Use -dD instead of -dN on compiler invocation
Adhemerval Zanella [Sun, 22 Dec 2024 00:04:24 +0000 (08:04 +0800)] 
conform: Use -dD instead of -dN on compiler invocation

clang does not support -dN.
Reviewed-by: Sam James <sam@gentoo.org>
7 months agomath: Exclude tgmath3-macro-tests for Clang
H.J. Lu [Sun, 15 Dec 2024 23:21:43 +0000 (07:21 +0800)] 
math: Exclude tgmath3-macro-tests for Clang

tgmath3-macro-tests won't compile with <float.h> and <tgmath.h> from
Clang due to missing C23 support:

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

Disable them for now when Clang is used for testing so that "make check"
can finish.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoCheck if -mamx-tile works for testing
H.J. Lu [Wed, 18 Dec 2024 10:56:14 +0000 (18:56 +0800)] 
Check if -mamx-tile works for testing

Since -mamx-tile is used only for testing, use LIBC_TRY_TEST_CC_COMMAND,
instead of LIBC_TRY_CC_AND_TEST_CC_COMMAND to check it and don't check
__builtin_ia32_ldtilecfg for Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoassert: Sort tests in Makefile
H.J. Lu [Sat, 21 Dec 2024 21:55:39 +0000 (05:55 +0800)] 
assert: Sort tests in Makefile

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoassert: ensure posix compliance, add tests for such
DJ Delorie [Thu, 14 Nov 2024 20:12:57 +0000 (15:12 -0500)] 
assert: ensure posix compliance, add tests for such

Fix assert.c so that even the fallback
case conforms to POSIX, although not exactly the same as
the default case so a test can tell the difference.

Add a test that verifies that abort is called, and that the
message printed to stderr has all the info that POSIX requires.
Verify this even when malloc isn't usable.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
7 months agocet: Drop '#pragma GCC target' in tst-cet-legacy-10a[-static].c
Adhemerval Zanella [Fri, 20 Dec 2024 22:16:58 +0000 (06:16 +0800)] 
cet: Drop '#pragma GCC target' in tst-cet-legacy-10a[-static].c

After

commit 215447f5cbcf1a494cded57734f68d7f9c2b0dc0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 17 06:18:55 2024 +0800

    cet: Pass -mshstk to compiler for tst-cet-legacy-10a[-static].c

we can remove '#pragma GCC target' in tst-cet-legacy-10a[-static].c.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
7 months agoposix: fix system when a child cannot be created [BZ #32450]
Aurelien Jarno [Thu, 19 Dec 2024 22:55:15 +0000 (23:55 +0100)] 
posix: fix system when a child cannot be created [BZ #32450]

POSIX states that "if a child process cannot be created, or if the
termination status for the command language interpreter cannot be
obtained, system() shall return -1 and set errno to indicate the error."

In the glibc implementation it could happen when posix_spawn fails,
which happens when the underlying fork, vfork, or clone call fails. They
could fail with EAGAIN and ENOMEM.

Resolves: BZ #32450
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoDon't use glibc <tgmath.h> when testing with Clang
H.J. Lu [Wed, 18 Dec 2024 10:58:34 +0000 (18:58 +0800)] 
Don't use glibc <tgmath.h> when testing with Clang

Clang has its own <tgmath.h> and doesn't use <tgmath.h> from glibc.  Pass
"-I." to compiler only if $($(<F)-no-include-dot) are undefined.  Define
it to yes for tgmath tests when testing with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agostdio-common: Exclude bug28 when clang is used
H.J. Lu [Wed, 18 Dec 2024 18:21:27 +0000 (02:21 +0800)] 
stdio-common: Exclude bug28 when clang is used

Clang 19 takes a very long time, it ran more than 27 minutes on Intel Core
i7-1195G7 before the process was killed, to compile bug28.c:

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

Exclude it when Clang is used for testing.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoFix elf: Introduce is_rtld_link_map [BZ #32488]
H.J. Lu [Fri, 20 Dec 2024 20:21:55 +0000 (04:21 +0800)] 
Fix elf: Introduce is_rtld_link_map [BZ #32488]

Also use is_rtld_link_map in dl-cet.c.  This fixes BZ #32488.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agomath: xfail some tanpi tests for ibm128-libgcc
Adhemerval Zanella [Thu, 19 Dec 2024 14:40:50 +0000 (11:40 -0300)] 
math: xfail some tanpi tests for ibm128-libgcc

On powerpc math/test-ibm128-tanpi shows multiple failures:

testing long double (without inline functions)
Failure: tanpi_downward (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0xfffffffffffffffdp-1)
Result:
 is:          4.68843873182857939141363635204365e+28   0x1.2efbb6629d1d59b032520400df8p+95
 should be:   inf   inf
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0x3fffffffffffffffffffffffffdp-1)
Result:
 is:          1.41444453325831960404472183124793e+16   0x1.9202627cbf98e052d5fdbeee1f8p+53
 should be:   inf   inf
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
Failure: Test: tanpi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          2.91356019227449116879287504834896e-15   0x1.a3e365fee24d4632f95a2235698p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.91356019227449116879287504834896e-15   0x1.a3e365fee24d4632f95a2235698p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          7.94911926685664643005642781870827e-16   0x1.ca3c4b83eb5688e1474146dc338p-51
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  7.94911926685664643005642781870827e-16   0x1.ca3c4b83eb5688e1474146dc338p-51
 ulp       :  160891965142034222272327839154722485473479235229008379884749401713481320342777314570400076204240982703218835644458374555276642
 max.ulp   :  8.0000
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0xfffffffffffffffdp-1)
Result:
 is:          2.14718475310122677917055904836884e+28   0x1.1584624c14882fff76592b4ec10p+94
 should be:   inf   inf
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0xfffffffffffffffdp-1)
Result:
 is:         -2.14718475310122677917055904836884e+28  -0x1.1584624c14882fff76592b4ec10p+94
 should be:  -inf  -inf
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1)
Result:
 is:          6.60739946234609289593176521179840e+15   0x1.7796511d79d6ce55bc8bf083fe0p+52
 should be:   inf   inf
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1)
Result:
 is:         -6.60739946234609289593176521179840e+15  -0x1.7796511d79d6ce55bc8bf083fe0p+52
 should be:  -inf  -inf
Failure: Test: tanpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.17953443892757434921819283936141e-14  -0x1.a8f8d97fb893518cbe5688935c0p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -1.85584803206881692897837494734542e-14  -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: tanpi_upward (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0xfffffffffffffffdp-1)
Result:
 is:         -2.14718475310122677917055904836884e+28  -0x1.1584624c14882fff76592b4ec10p+94
 should be:  -inf  -inf
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1)
Result:
 is:         -6.60739946234609289593176521179829e+15  -0x1.7796511d79d6ce55bc8bf083fdbp+52
 should be:  -inf  -inf
Failure: Test: tanpi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.17953443892757434921819283936138e-14  -0x1.a8f8d97fb893518cbe5688935b0p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936139e-14   0x1.a8f8d97fb893518cbe5688935b0p-47
 ulp       :  inf
 max.ulp   :  8.0000
Failure: Test: tanpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -1.85584803206881692897837494734542e-14  -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734543e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  inf
 max.ulp   :  8.0000
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0

7 months agoelf: Reorder audit events in dlcose to match _dl_fini (bug 32066)
Florian Weimer [Tue, 3 Sep 2024 15:57:46 +0000 (17:57 +0200)] 
elf: Reorder audit events in dlcose to match _dl_fini (bug 32066)

This was discovered after extending elf/tst-audit23 to cover
dlclose of the dlmopen namespace.

Auditors already experience the new order during process
shutdown (_dl_fini), so no LAV_CURRENT bump or backwards
compatibility code seems necessary.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Call la_objclose for proxy link maps in _dl_fini (bug 32065)
Florian Weimer [Fri, 9 Aug 2024 14:06:40 +0000 (16:06 +0200)] 
elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)
Florian Weimer [Fri, 9 Aug 2024 13:31:18 +0000 (15:31 +0200)] 
elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)

Previously, the ld.so link map was silently added to the namespace.
This change produces an auditing event for it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Add the endswith function to <endswith.h>
Florian Weimer [Fri, 29 Nov 2024 14:36:40 +0000 (15:36 +0100)] 
elf: Add the endswith function to <endswith.h>

And include <stdbool.h> for a definition of bool.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Update DSO list, write audit log to elf/tst-audit23.out
Florian Weimer [Tue, 3 Sep 2024 15:52:47 +0000 (17:52 +0200)] 
elf: Update DSO list, write audit log to elf/tst-audit23.out

After commit 1d5024f4f052c12e404d42d3b5bfe9c3e9fd27c4
("support: Build with exceptions and asynchronous unwind tables
[BZ #30587]"), libgcc_s is expected to show up in the DSO
list on 32-bit Arm.  Do not update max_objs because vdso is not
tracked (and which is the reason why the test currently passes
even with libgcc_s present).

Also write the log output from the auditor to standard output,
for easier test debugging.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Move _dl_rtld_map, _dl_rtld_audit_state out of GL
Florian Weimer [Fri, 20 Dec 2024 14:52:57 +0000 (15:52 +0100)] 
elf: Move _dl_rtld_map, _dl_rtld_audit_state out of GL

This avoids immediate GLIBC_PRIVATE ABI issues if the size of
struct link_map or struct auditstate changes.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoelf: Introduce is_rtld_link_map
Florian Weimer [Fri, 20 Dec 2024 14:52:57 +0000 (15:52 +0100)] 
elf: Introduce is_rtld_link_map

Unconditionally define it to false for static builds.

This avoids the awkward use of weak_extern for _dl_rtld_map
in checks that cannot be possibly true on static builds.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>