Commit Graph

42725 Commits

Author SHA1 Message Date
Maciej W. Rozycki aa4dbb2eeb stdio-common: Convert macros across scanf input specifier tests
Convert 'compare_real', 'read_real', and 'verify_input' macros to
functions so as to improve readability and avoid pitfalls.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki a1e5ee13ab stdio-common: Adjust header inclusion in scanf input specifier tests
Move the inclusion of the data class header from the individual tests to
the data-type-specific skeleton, providing for the use of the data type
under test in the data class header and reducing duplication.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki 2419637eb0 stdio-common: Include correct skeleton in scanf input specifier tests
Follow 'scanf' itself and use the system header inclusion variant for
the data-type-specific skeleton consistently across the remaining scanf
family functions so that any sysdeps/ variant takes precedence even in
the presence of a corresponding skeleton in stdio-common/ (though we
have no such arrangement at the moment).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki ca0f999a93 stdio-common: Fix NaN input data for scanf input specifier tests [BZ #32857]
Update NaN input data with 'n-char-sequence' in reference data matching
data under test, removing test failures with the M68K host.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki 27aa1fb735 stdio-common: Fix bad NaN crash in scanf input specifier tests [BZ #32857]
Fix a null pointer dereference causing a crash in 'read_real' when the
terminating null character is written for use with the subsequent call
to 'nan' for invalid NaN reference input, such as:

%a:nan:1:3:nanny:

by moving all the 'n-char-sequence' handling under the check for the
opening parenthesis.

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki 67d2c9e3b7 stdio-common: Fix a crash in scanf input specifier tests [BZ #32857]
Fix a null pointer dereference causing a crash in 'read_real' when the
terminating null character is written for use with the subsequent call
to 'nan' for NaN reference input using null 'n-char-sequence', such as:

%a:nan():1:5:nan():

by moving the memory allocation call ahead of the check for the closing
parenthesis.

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki da2a2581c4 stdio-common: Fix error reporting in scanf input specifier tests
Remove buffer contents reporting from the real variant of 'verify_input'
where there has been an input data format error making the contents of
data buffers irrelevant.

For example given invalid float input data:

%a:nan:1:3:nan(:

these messages are produced:

error: ./tst-scanf-format-skeleton.c:240: input buffer: `0000c07f'
error: ./tst-scanf-format-skeleton.c:240: value buffer: `0000c07f'
error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error

with the two former lines irrelevant.  Remove them from output then,
only leaving:

error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
Maciej W. Rozycki 2b16c76609 stdio-common: Reject insufficient character data in scanf [BZ #12701]
Reject invalid formatted scanf character data with the 'c' conversion
where there is not enough input available to satisfy the field width
requested.  It is required by ISO C that this conversion matches a
sequence of characters of exactly the number specified by the field
width and it is also already documented as such in our own manual:

"It reads precisely the next N characters, and fails if it cannot get
that many."

Currently a matching success is instead incorrectly produced where the
EOF condition is encountered before the required number of characters
has been retrieved, and the characters actually obtained are stored in
the buffer provided.

Add test cases accordingly and remove placeholders from 'c' conversion
input data for the existing scanf tests.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-23 01:02:46 +01:00
H.J. Lu e377a7a8ec Disable -Wimplicit-fallthrough when clang is in use
Clang's -Wimplicit-fallthrough warning, which flags unannotated
fall-through in switch statements, does not recognize specific comments
like /* FALLTHROUGH */ for suppressing the warning, unlike GCC.  Since
fall through comments are used extensively in glibc, disable
-Wimplicit-fallthrough when clang is in use.

This fixes BZ #33312.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-08-22 16:32:02 -07:00
H.J. Lu b4ab549ae5 libio: Properly link in libio functions in static binaries
commit 3020f72618
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date:   Tue Dec 27 18:11:43 2022 -0300

    libio: Remove the usage of __libc_IO_vtables

added

 #define libio_static_fn_required(name) __asm (".globl " #name);

to link in libio functions in static binaries.  But there is no relocation
in
	.globl	_IO_file_open

and "strip --strip-unneeded" will remove such unreferenced symbols which
breaks static binaries.  Redefine libio_static_fn_required to create a
reference to the required function with

static __typeof (name) *const name##_p __attribute__((used)) = name;

This fixes BZ #33300.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Tested-by: Xi Ruoyao <xry111@xry111.site>
2025-08-22 12:03:00 -07:00
Uros Bizjak 3997c50f0b x86_64: Use __seg_fs qualifiers in NPTL accessors
Use __seg_fs named address space qualifiers to cast NPTL accessors
to %fs: prefixed addresses.  Use volatile access only where
strictly necessary.

Use existing assembly RSEQ_* accessors for x32 to
work around the GCC bug:

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

because negative value in __rseq_offset is used
as an offset from %fs.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
2025-08-22 06:36:14 -07:00
H.J. Lu bb7fb0f1a7 x86: Remove an extra space before THREAD_SELF
After

f6dd43d5f7 i386: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
b0f0c41a5f x86_64: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()

removed the unnecessary __GNUC_PREREQ (6, 0) test, remove the extra space
before THREAD_SELF macro name.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-21 19:32:30 -07:00
Uros Bizjak b0f0c41a5f x86_64: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
Currenty GCC-12 is required as the minimum supported compiler
version.  Remove stalled __GNUC_PREREQ (6, 0) test for
GCC compiler version in THREAD_SELF() macro definition.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20 11:48:27 -07:00
Uros Bizjak 0e49fc68aa i386: Use __seg_gs qualifiers in NPTL accessors
Use __seg_gs named address space qualifiers to cast NPTL accessors
to %gs: prefixed addresses.  Use volatile access only where
strictly necessary.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20 11:48:23 -07:00
Uros Bizjak f6dd43d5f7 i386: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
Currenty GCC-12 is required as the minimum supported compiler
version.  Remove stalled __GNUC_PREREQ (6, 0) test for
GCC compiler version in THREAD_SELF() macro definition.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20 11:48:20 -07:00
Uros Bizjak f80dddbe29 i386: Use TESTB instead of TESTL in ____longjmp_chk()
There is no need to use TESTL when checking the least-significant bit
with a TEST instruction. Use TESTB, which is three bytes shorter:

   f6 44 24 04 01          testb  $0x1,0x4(%esp)

vs:

   f7 44 24 04 01 00 00    testl  $0x1,0x4(%esp)
   00

for the same effect.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20 11:48:17 -07:00
Uros Bizjak dd38f49cdc x86_64: Use TESTB instead of TESTL in CHECK_INVALID_LONGJMP
There is no need to use TESTL when checking the least-significant bit
with a TEST instruction. Use TESTB, which is three bytes shorter:

   f6 44 24 f0 01      	   testb  $0x1,-0x10(%rsp)

vs:

   f7 44 24 f0 01 00 00    testl  $0x1,-0x10(%rsp)
   00

for the same effect.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20 11:47:53 -07:00
Pierre Blanchard aac077645a AArch64: Fix SVE powf routine [BZ #33299]
Fix a bug in predicate logic introduced in last change.
A slight performance improvement from relying on all true
predicates during conversion from single to double.
This fixes BZ #33299.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2025-08-20 17:45:21 +00:00
Arjun Shankar 6f999af332 support: Handle FUSE_GETXATTR during FUSE FS mount
When testing with some kernel versions, support FUSE infrastructure
encounters a FUSE_GETXATTR request, leading to FUSE tests hanging until
timed out.  Therefore, pass FUSE_GETXATTR requests from
support_fuse_handle_mountpoint to support_fuse_handle_directory, and
adjust support_fuse_handle_directory to return ENOSYS so that tests can
proceed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-08-19 09:54:38 +02:00
caiyinyu d4ccda8e69 malloc: Fix tst bug in malloc/tst-free-errno-malloc-hugetlb1.
When transparent hugepages (THP) are configured to 32MB on x86/loongarch
systems, the current big_size value may not be sufficiently large to
guarantee that free(ptr) [1] will call munmap(ptr_aligned, big_size).

Tested on x86_64 and loongarch64.

PS: Without this patch and using 32M THP, there is a about 50% chance
that malloc/tst-free-errno-malloc-hugetlb1 will fail on both x86_64 and
loongarch64.

[1] malloc/tst-free-errno.c:
...
       errno = 1789;
       /* This call to free() is supposed to call
            munmap (ptr_aligned, big_size);
          which increases the number of VMAs by 1, which is supposed
          to fail.  */
->     free (ptr);
       TEST_VERIFY (get_errno () == 1789);
     }
...

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2025-08-19 09:05:32 +08:00
H.J. Lu bd4628f3f1 i386: Also add GLIBC_ABI_GNU2_TLS version [BZ #33129]
Since the GNU2 TLS run-time bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=31372

affects both i386 and x86-64, also add GLIBC_ABI_GNU2_TLS version to i386
to indicate the working GNU2 TLS run-time.  For x86-64, the additional
GNU2 TLS run-time bug fix is needed for

https://sourceware.org/bugzilla/show_bug.cgi?id=31501

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-08-18 11:58:01 -07:00
gfleury 098e449df0 htl: move sem_unlink into libc.
Message-ID: <20250817104023.91919-8-gfleury@disroot.org>
2025-08-18 01:06:41 +02:00
gfleury f5a43420e2 htl: move sem_{clockwait, timedwait, wait, trywait} into libc.
Message-ID: <20250817104023.91919-7-gfleury@disroot.org>
2025-08-18 01:06:38 +02:00
gfleury 795f5f2a8b htl: move sem_post into libc.
Message-ID: <20250817104023.91919-6-gfleury@disroot.org>
2025-08-18 00:55:33 +02:00
gfleury 50f5ddc20a htl: move sem_open, sem_close into libc.
Message-ID: <20250817104023.91919-5-gfleury@disroot.org>
2025-08-18 00:55:18 +02:00
gfleury b2b6d32f11 htl: move sem_init into libc.
Message-ID: <20250817104023.91919-4-gfleury@disroot.org>
2025-08-18 00:23:11 +02:00
gfleury 11c07af422 htl: move sem_getvalue into libc.
Message-ID: <20250817104023.91919-3-gfleury@disroot.org>
2025-08-18 00:22:53 +02:00
gfleury c2560a0c56 htl: move sem_destroy into libc.
Message-ID: <20250817104023.91919-2-gfleury@disroot.org>
2025-08-18 00:22:43 +02:00
gfleury 35296a6e73 htl: move __pthread_startup into libc.
Message-ID: <20250815181500.107433-20-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury 80412aee3e htl: move __pthread_setup into libc.
Message-ID: <20250815181500.107433-19-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury b6616efe8c htl: move pthread_{join, clockjoin_np, timedjoin_np, tryjoin_np} into libc.
Message-ID: <20250815181500.107433-18-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury 36982b0fdb htl: move pthread_exit into libc.
Message-ID: <20250815181500.107433-17-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury a901f2599e htl: move pthread_detach into libc.
Message-ID: <20250815181500.107433-16-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury d0667a77de htl: move __pthread_sigstate_init into libc.
Message-ID: <20250815181500.107433-15-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury f6a47e2d61 htl: move pthread_mutex_transfer_np into libc.
Message-ID: <20250815181500.107433-14-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury 1e6588e777 htl: move pthread_getattr_np into libc.
Message-ID: <20250815181500.107433-13-gfleury@disroot.org>
2025-08-16 01:44:51 +02:00
gfleury 6541288cb5 htl: move pthread_testcancel into libc.
Message-ID: <20250815181500.107433-12-gfleury@disroot.org>
2025-08-16 01:44:50 +02:00
gfleury edcc9ca48c htl: move pthread_kill into libc.
Message-ID: <20250815181500.107433-11-gfleury@disroot.org>
2025-08-16 01:44:27 +02:00
gfleury de8351f4de htl: move pthread_cancel, __pthread_do_cancel into libc.
Message-ID: <20250815181500.107433-10-gfleury@disroot.org>
2025-08-16 01:44:27 +02:00
gfleury e0b765d9ba htl: move __thread_set_pcsptp into libc.
Message-ID: <20250815181500.107433-9-gfleury@disroot.org>
2025-08-16 01:44:27 +02:00
gfleury 2dcb8fb8e7 htl: move pthread_yield into libc.
Message-ID: <20250815181500.107433-8-gfleury@disroot.org>
2025-08-16 01:44:27 +02:00
gfleury fa35ccbba8 htl: move pthread_getcpuclockid into libc.
Message-ID: <20250815181500.107433-7-gfleury@disroot.org>
2025-08-16 01:44:27 +02:00
gfleury c3abc99cb0 htl: move __pthread_thread_{alloc, start, terminate} into libc.
Message-ID: <20250815181500.107433-6-gfleury@disroot.org>
2025-08-16 01:44:26 +02:00
gfleury 450912d5db htl: move __pthread_stack_alloc into libc.
Message-ID: <20250815181500.107433-5-gfleury@disroot.org>
2025-08-16 01:15:37 +02:00
gfleury 2522a3f3ae htl: move __pthread_init_{specific, static_tls}, __pthread_{alloc}, dealloc} into libc.
Message-ID: <20250815181500.107433-4-gfleury@disroot.org>
2025-08-16 01:13:22 +02:00
gfleury b586357e2a htl: move pthread_get/setconcurrency into libc.
Message-ID: <20250815181500.107433-3-gfleury@disroot.org>
2025-08-16 01:12:21 +02:00
gfleury d479e71498 htl: move pthread_setschedprio into libc.
Message-ID: <20250815181500.107433-2-gfleury@disroot.org>
2025-08-16 01:11:21 +02:00
H.J. Lu 399384e0c8 x86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212]
When the linker -z mark-plt option is used to add DT_X86_64_PLT,
DT_X86_64_PLTSZ and DT_X86_64_PLTENT, the r_addend field of the
R_X86_64_JUMP_SLOT relocation stores the offset of the indirect
branch instruction.  However, glibc versions without the commit:

commit f8587a6189
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 20 19:21:48 2022 -0700

    x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT

    According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_DAT
    and R_X86_64_JUMP_SLOT.  Since linkers always set their r_addends to 0, we
    can ignore their r_addends.

    Reviewed-by: Fangrui Song <maskray@google.com>

won't ignore the r_addend value in the R_X86_64_JUMP_SLOT relocation.
Such programs and shared libraries will fail at run-time randomly.

Add GLIBC_ABI_DT_X86_64_PLT version to indicate that glibc is compatible
with DT_X86_64_PLT.

The linker can add the glibc GLIBC_ABI_DT_X86_64_PLT version dependency
whenever -z mark-plt is passed to the linker.  The resulting programs and
shared libraries will fail to load at run-time against libc.so without the
GLIBC_ABI_DT_X86_64_PLT version, instead of fail randomly.

This fixes BZ #33212.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-08-14 07:05:37 -07:00
H.J. Lu ed1b7a5a48 i386: Add GLIBC_ABI_GNU_TLS version [BZ #33221]
On i386, programs and shared libraries with __thread usage may fail
silently at run-time against glibc without the TLS run-time fix for:

https://sourceware.org/bugzilla/show_bug.cgi?id=32996

Add GLIBC_ABI_GNU_TLS version to indicate that glibc has the working
GNU TLS run-time.  Linker can add the GLIBC_ABI_GNU_TLS version to
binaries which depend on the working TLS run-time so that such programs
and shared libraries will fail to load and run at run-time against
libc.so without the GLIBC_ABI_GNU_TLS version, instead of fail silently
at random.

This fixes BZ #33221.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-08-14 05:43:32 -07:00
H.J. Lu 9df8fa397d x86-64: Add GLIBC_ABI_GNU2_TLS version [BZ #33129]
Programs and shared libraries compiled with -mtls-dialect=gnu2 may fail
silently at run-time against glibc without the GNU2 TLS run-time fix
for:

https://sourceware.org/bugzilla/show_bug.cgi?id=31372

Add GLIBC_ABI_GNU2_TLS version to indicate that glibc has the working
GNU2 TLS run-time.  Linker can add the GLIBC_ABI_GNU2_TLS version to
binaries which depend on the working GNU2 TLS run-time:

https://sourceware.org/bugzilla/show_bug.cgi?id=33130

so that such programs and shared libraries will fail to load and run at
run-time against libc.so without the GLIBC_ABI_GNU2_TLS version, instead
of fail silently at random.

This fixes BZ #33129.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-08-14 05:42:54 -07:00