]> sourceware.org Git - glibc.git/log
glibc.git
6 months agoaarch64/fpu: Sync libmvec routines from 2.39 and before with AOR
Joe Ramsay [Tue, 20 Feb 2024 16:44:13 +0000 (16:44 +0000)]
aarch64/fpu: Sync libmvec routines from 2.39 and before with AOR

This includes a fix for big-endian in AdvSIMD log, some cosmetic
changes, and numerous small optimisations mainly around inlining and
using indexed variants of MLA intrinsics.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agoS390: Do not clobber r7 in clone [BZ #31402]
Stefan Liebler [Thu, 22 Feb 2024 14:03:27 +0000 (15:03 +0100)]
S390: Do not clobber r7 in clone [BZ #31402]

Starting with commit e57d8fc97b90127de4ed3e3a9cdf663667580935
"S390: Always use svc 0"
clone clobbers the call-saved register r7 in error case:
function or stack is NULL.

This patch restores the saved registers also in the error case.
Furthermore the existing test misc/tst-clone is extended to check
all error cases and that clone does not clobber registers in this
error case.

6 months agox86_64: Exclude SSE, AVX and FMA4 variants in libm multiarch
Sunil K Pandey [Tue, 13 Feb 2024 20:23:14 +0000 (12:23 -0800)]
x86_64: Exclude SSE, AVX and FMA4 variants in libm multiarch

When glibc is built with ISA level 3 or higher by default, the resulting
glibc binaries won't run on SSE or FMA4 processors.  Exclude SSE, AVX and
FMA4 variants in libm multiarch when ISA level 3 or higher is enabled by
default.

When glibc is built with ISA level 2 enabled by default, only keep SSE4.1
variant.

Fixes BZ 31335.

NB: elf/tst-valgrind-smoke test fails with ISA level 4, because valgrind
doesn't support AVX512 instructions:

https://bugs.kde.org/show_bug.cgi?id=383010

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
6 months agohurd: Reformat Makefile.
Carlos O'Donell [Fri, 9 Jun 2023 21:46:34 +0000 (17:46 -0400)]
hurd: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

Tested with build-many-glibcs.py for x86_64-gnu.

6 months agohtl/tests: Reformat Makefile.
Carlos O'Donell [Fri, 9 Jun 2023 21:45:23 +0000 (17:45 -0400)]
htl/tests: Reformat Makefile.

Reflow and sort Makefile.

No code generation changes in non-test binary artifacts.

No regressions on x86_64 and i686.

Tested with build-many-glibcs.py for x86_64-gnu.

6 months agohtl: Reformat Makefile.
Carlos O'Donell [Fri, 9 Jun 2023 21:44:50 +0000 (17:44 -0400)]
htl: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

6 months agohesiod: Reformat Makefile.
Carlos O'Donell [Fri, 9 Jun 2023 20:44:19 +0000 (16:44 -0400)]
hesiod: Reformat Makefile.

Reflow and sort Makefile.

No code generation changes in non-test binary artifacts.

No regressions on x86_64 and i686.

6 months agogmon: Reformat Makefile.
Carlos O'Donell [Thu, 8 Jun 2023 11:58:00 +0000 (07:58 -0400)]
gmon: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

6 months agodlfcn: Reformat Makefile.
Carlos O'Donell [Thu, 8 Jun 2023 16:17:00 +0000 (12:17 -0400)]
dlfcn: Reformat Makefile.

Reflow and sort Makefile.

No code generation changes in non-test binary artifacts.

No regressions on x86_64 and i686.

6 months agodirent: Reformat Makefile.
Carlos O'Donell [Thu, 8 Jun 2023 11:30:33 +0000 (07:30 -0400)]
dirent: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

6 months agoctype: Reformat Makefile.
Carlos O'Donell [Thu, 8 Jun 2023 10:43:44 +0000 (06:43 -0400)]
ctype: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

6 months agocsu: Reformat Makefile.
Carlos O'Donell [Tue, 6 Jun 2023 12:27:20 +0000 (08:27 -0400)]
csu: Reformat Makefile.

Reflow and sort Makefile.

Code generation changes present due to link order changes.

No regressions on x86_64 and i686.

6 months agoconform: Reformat Makefile.
Carlos O'Donell [Mon, 5 Jun 2023 11:14:41 +0000 (07:14 -0400)]
conform: Reformat Makefile.

Reflow and sort Makefile.

No code changes in generated binary artifacts.

No regressions on x86_64 and i686.

6 months agoSupport compiling .S files with additional options
H.J. Lu [Sun, 25 Feb 2024 12:22:03 +0000 (04:22 -0800)]
Support compiling .S files with additional options

Add $(sysdep-ASFLAGS) $(ASFLAGS-$(<F)) $(ASFLAGS-$(@F)) to compile.S and
COMPILE.S to support compiling .S files with additional options.

6 months agox86-64: Save APX registers in ld.so trampoline
H.J. Lu [Fri, 16 Feb 2024 15:17:10 +0000 (07:17 -0800)]
x86-64: Save APX registers in ld.so trampoline

Add APX registers to STATE_SAVE_MASK so that APX registers are saved in
ld.so trampoline.  This fixes BZ #31371.

Also update STATE_SAVE_OFFSET and STATE_SAVE_MASK for i386 which will
be used by i386 _dl_tlsdesc_dynamic.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
6 months agobenchtests: Add more benchtests for rounding functions.
Junxian Zhu [Mon, 22 Jan 2024 02:16:19 +0000 (10:16 +0800)]
benchtests: Add more benchtests for rounding functions.

This patch adds more benchtests for rounding functions.
The double inputs are copied from trunc-inputs, the float inputs are copied from truncf-inputs. and the rintf is copied from rint-inputs.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agotests: gracefully handle AppArmor userns containment
Simon Chopin [Fri, 16 Feb 2024 16:38:49 +0000 (17:38 +0100)]
tests: gracefully handle AppArmor userns containment

Recent AppArmor containment allows restricting unprivileged user
namespaces, which is enabled by default on recent Ubuntu systems.
When this happens, as is common with Linux Security Modules, the syscall
will fail with -EACCESS.

When that happens, the affected tests will now be considered unsupported
rather than simply failing.

Further information:

* https://gitlab.com/apparmor/apparmor/-/wikis/unprivileged_userns_restriction
* https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
* https://manpages.ubuntu.com/manpages/jammy/man5/apparmor.d.5.html (for
  the return code)

V2:
* Fix duplicated line in check_unshare_hints
* Also handle similar failure in tst-pidfd_getpid

V3:
* Comment formatting
* Aded some more documentation on syscall return value

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
6 months agotreewide: python-scripts: use `is None` for none-equality
Konstantin Kharlamov [Sun, 18 Feb 2024 20:02:34 +0000 (23:02 +0300)]
treewide: python-scripts: use `is None` for none-equality

Testing for `None`-ness with `==` operator is frowned upon and causes
warnings in at least "LGTM" python linter. Fix that.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agopowerpc: Remove power7 strstr optimization
Adhemerval Zanella [Mon, 19 Feb 2024 20:46:55 +0000 (17:46 -0300)]
powerpc: Remove power7 strstr optimization

The optimization is not faster than the generic algorithm,
using the bench-strstr the geometric mean running on a POWER10 machine
using gcc 13.1.1 is 482.47 while the default __strstr_ppc is 340.97
(which uses the generic implementation).

Also, there is no need to redirect the internal str*/mem* call
to optimized version, internal ifunc is supported and enabled
for internal calls (meaning that the generic implementation
will use any asm optimization if available).

Checked on powerpc64le-linux-gnu.
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
6 months agoarm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)
Adhemerval Zanella [Thu, 22 Feb 2024 13:42:55 +0000 (10:42 -0300)]
arm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)

Instead of __dl_iterate_phdr. On ARM dlfo_eh_frame/dlfo_eh_count
maps to PT_ARM_EXIDX vaddr start / length.

On a Neoverse N1 machine with 160 cores, the following program:

  $ cat test.c
  #include <stdlib.h>
  #include <pthread.h>
  #include <assert.h>

  enum {
    niter = 1024,
    ntimes = 128,
  };

  static void *
  tf (void *arg)
  {
    int a = (int) arg;

    for (int i = 0; i < niter; i++)
      {
        void *p[ntimes];
        for (int j = 0; j < ntimes; j++)
   p[j] = malloc (a * 128);
        for (int j = 0; j < ntimes; j++)
   free (p[j]);
      }

    return NULL;
  }

  int main (int argc, char *argv[])
  {
    enum { nthreads = 16 };
    pthread_t t[nthreads];

    for (int i = 0; i < nthreads; i ++)
      assert (pthread_create (&t[i], NULL, tf, (void *) i) == 0);

    for (int i = 0; i < nthreads; i++)
      {
        void *r;
        assert (pthread_join (t[i], &r) == 0);
        assert (r == NULL);
      }

    return 0;
  }
  $ arm-linux-gnueabihf-gcc -fsanitize=address test.c -o test

Improves from ~15s to 0.5s.

Checked on arm-linux-gnueabihf.

6 months agomath: Update mips64 ulps
Xi Ruoyao [Thu, 22 Feb 2024 20:26:55 +0000 (21:26 +0100)]
math: Update mips64 ulps

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
6 months agoelf: Add new LoongArch reloc types (110 to 126) into elf.h
Xi Ruoyao [Thu, 22 Feb 2024 10:57:43 +0000 (18:57 +0800)]
elf: Add new LoongArch reloc types (110 to 126) into elf.h

These reloc types have been added in LoongArch psABI v2.30.

Link: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#relocation-types
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
6 months agobuild-many-glibcs.py: Add s390 --disable-multi-arch / multi-arch configurations.
Stefan Liebler [Wed, 31 Jan 2024 12:02:57 +0000 (13:02 +0100)]
build-many-glibcs.py: Add s390 --disable-multi-arch / multi-arch configurations.

This patch adds some --disable-multi-arch variants for s390x.

As the used IFUNC variants and __GI symbols depend on the used
gcc -march=cpu-level, there are multiple new configurations.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agosparc: Treat the version field in the FPU control word as reserved
Daniel Cederman [Mon, 19 Feb 2024 13:55:50 +0000 (10:55 -0300)]
sparc: Treat the version field in the FPU control word as reserved

The FSR version field is read-only and might be non-zero.

This allows math/test-fpucw* to correctly pass when the version is
non-zero.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoImplement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64
Flavio Cruz [Sat, 17 Feb 2024 20:25:35 +0000 (15:25 -0500)]
Implement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64

Tested with the tests provided by glibc plus some other toy examples.
Message-ID: <20240217202535.1860803-1-flaviocruz@gmail.com>

7 months agoUse proc_getchildren_rusage when available in getrusage and times.
Flavio Cruz [Sat, 17 Feb 2024 16:48:46 +0000 (11:48 -0500)]
Use proc_getchildren_rusage when available in getrusage and times.

Message-ID: <20240217164846.1837223-1-flaviocruz@gmail.com>

7 months agoLinux: Switch back to assembly syscall wrapper for prctl (bug 29770)
Florian Weimer [Sat, 17 Feb 2024 08:17:04 +0000 (09:17 +0100)]
Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)

Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for
prctl [BZ #25896]") replaced the assembler wrapper with a C function.
However, on powerpc64le-linux-gnu, the C variadic function
implementation requires extra work in the caller to set up the
parameter save area.  Calling a function that needs a parameter save
area without one (because the prototype used indicates the function is
not variadic) corrupts the caller's stack.   The Linux manual pages
project documents prctl as a non-variadic function.  This has resulted
in various projects over the years using non-variadic prototypes,
including the sanitizer libraries in LLVm and GCC (GCC PR 113728).

This commit switches back to the assembler implementation on most
targets and only keeps the C implementation for x86-64 x32.

Also add the __prctl_time64 alias from commit
b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for
prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet
present in commit ff026950e280bc3e9487b41b460fb31bc5b57721.

This restores the old ABI on powerpc64le-linux-gnu, thus fixing
bug 29770.

Reviewed-By: Simon Chopin <simon.chopin@canonical.com>
7 months agoi386: Use generic memrchr in libc (bug 31316)
Florian Weimer [Fri, 16 Feb 2024 06:40:37 +0000 (07:40 +0100)]
i386: Use generic memrchr in libc (bug 31316)

Before this change, we incorrectly used the SSE2 variant in the
implementation, without checking that the system actually supports
SSE2.

Tested-by: Sam James <sam@gentoo.org>
7 months agoApply the Makefile sorting fix
H.J. Lu [Thu, 15 Feb 2024 19:19:56 +0000 (11:19 -0800)]
Apply the Makefile sorting fix

Apply the Makefile sorting fix generated by sort-makefile-lines.py.

7 months agosysdeps/x86_64/Makefile (tests): Add the end marker
H.J. Lu [Thu, 15 Feb 2024 19:12:13 +0000 (11:12 -0800)]
sysdeps/x86_64/Makefile (tests): Add the end marker

7 months agosort-makefile-lines.py: Allow '_' in name and "^# name"
H.J. Lu [Thu, 15 Feb 2024 11:22:55 +0000 (03:22 -0800)]
sort-makefile-lines.py: Allow '_' in name and "^# name"

'_' is used in Makefile variable names and many variables end with
"^# name".  Relax sort-makefile-lines.py to allow '_' in name and
"^# name" as variable end.  This fixes BZ #31385.

7 months agotrivial doc fix: remove weird phrase "syscall takes zero to five arguments"
Askar Safin [Mon, 12 Feb 2024 16:48:55 +0000 (19:48 +0300)]
trivial doc fix: remove weird phrase "syscall takes zero to five arguments"

"number of arguments, from zero to five" is wrong, because on Linux maximal number
of arguments is 6, not 5. Also, maximal number of arguments is kernel-dependent,
so let's not include it here at all.

Moreover, "Each kind of system call has a definite number of arguments" is questionable.
Think about SYS_open on Linux, which takes 2 or 3 arguments. Or SYS_clone on Linux x86_64, which
takes 2 to 5 arguments. So I propose to fully remove this sentence.

Signed-off-by: Askar Safin <safinaskar@zohomail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agomips: Use builtins for ffs and ffsll
Junxian Zhu [Tue, 6 Feb 2024 08:34:56 +0000 (16:34 +0800)]
mips: Use builtins for ffs and ffsll

__builtin_ffs{,ll} basically on __builtin_ctz{,ll} in MIPS GCC compiler.
The hardware ctz instructions were available after MIPS{32,64} Release1. By using builtin ctz. It can also reduce code size of ffs/ffsll.

Checked on mips o32. mips64.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
7 months agox86: Expand the comment on when REP STOSB is used on memset
Adhemerval Zanella [Thu, 8 Feb 2024 13:08:40 +0000 (10:08 -0300)]
x86: Expand the comment on when REP STOSB is used on memset

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agox86: Do not prefer ERMS for memset on Zen3+
Adhemerval Zanella [Thu, 8 Feb 2024 13:08:39 +0000 (10:08 -0300)]
x86: Do not prefer ERMS for memset on Zen3+

For AMD Zen3+ architecture, the performance of the vectorized loop is
slightly better than ERMS.

Checked on x86_64-linux-gnu on Zen3.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agox86: Fix Zen3/Zen4 ERMS selection (BZ 30994)
Adhemerval Zanella [Thu, 8 Feb 2024 13:08:38 +0000 (10:08 -0300)]
x86: Fix Zen3/Zen4 ERMS selection (BZ 30994)

The REP MOVSB usage on memcpy/memmove does not show much performance
improvement on Zen3/Zen4 cores compared to the vectorized loops.  Also,
as from BZ 30994, if the source is aligned and the destination is not
the performance can be 20x slower.

The performance difference is noticeable with small buffer sizes, closer
to the lower bounds limits when memcpy/memmove starts to use ERMS.  The
performance of REP MOVSB is similar to vectorized instruction on the
size limit (the L2 cache).  Also, there is no drawback to multiple cores
sharing the cache.

Checked on x86_64-linux-gnu on Zen3.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agox86/cet: fix shadow stack test scripts
Michael Jeanson [Mon, 5 Feb 2024 20:22:39 +0000 (15:22 -0500)]
x86/cet: fix shadow stack test scripts

Some shadow stack test scripts use the '==' operator with the 'test'
command to validate exit codes resulting in the following error:

  sysdeps/x86_64/tst-shstk-legacy-1e.sh: 31: test: 139: unexpected operator

The '==' operator is invalid for the 'test' command, use '-eq' like the
previous call to 'test'.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agotest_printers_common.py: Remove invalid escape sequence
H.J. Lu [Mon, 12 Feb 2024 14:06:50 +0000 (06:06 -0800)]
test_printers_common.py: Remove invalid escape sequence

Change "\(" and "\)" to "\\(" and "\\)" in test_printers_common.py.  This
fixes the test warning:

.../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agoelf: Remove attempt at env handling in elf/tst-rtld-list-diagnostics.py
Florian Weimer [Fri, 9 Feb 2024 15:16:08 +0000 (16:16 +0100)]
elf: Remove attempt at env handling in elf/tst-rtld-list-diagnostics.py

Instead, let the system shell parse the whole thing and invoke the env
command.

7 months agoAdd SOL_VSOCK from Linux 6.7 to bits/socket.h
Joseph Myers [Thu, 8 Feb 2024 12:57:24 +0000 (12:57 +0000)]
Add SOL_VSOCK from Linux 6.7 to bits/socket.h

Linux 6.7 adds a constant SOL_VSOCK (recall that various constants in
include/linux/socket.h are in fact part of the kernel-userspace API
despite that not being a uapi header).  Add it to glibc's
bits/socket.h.

Tested for x86_64.

7 months agolocaledata: ssy_ER: Fix syntax error
Mike FABIAN [Wed, 7 Feb 2024 17:41:02 +0000 (18:41 +0100)]
localedata: ssy_ER: Fix syntax error

7 months agolocaledata: hr_HR: change currency to EUR/€
Dragan Stanojević (Nevidljivi) [Wed, 7 Feb 2024 15:31:04 +0000 (16:31 +0100)]
localedata: hr_HR: change currency to EUR/€

Resolves: BZ # 29845

7 months agoChange lv_LV collation to agree with the recent change in CLDR
Mike FABIAN [Wed, 7 Feb 2024 15:04:53 +0000 (16:04 +0100)]
Change lv_LV collation to agree with the recent change in CLDR

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

See this change in CLDR committed on 2024-01-29:
https://github.com/unicode-org/cldr/commit/635e2d3d0566563e12c8ea58c219d35183fcec12

7 months agoAdd new AArch64 HWCAP2 definitions from Linux 6.7 to bits/hwcap.h
Joseph Myers [Thu, 8 Feb 2024 01:39:09 +0000 (01:39 +0000)]
Add new AArch64 HWCAP2 definitions from Linux 6.7 to bits/hwcap.h

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

7 months agostring: Add hidden builtin definition for __strcpy_chk.
Stefan Liebler [Mon, 5 Feb 2024 13:22:06 +0000 (14:22 +0100)]
string: Add hidden builtin definition for __strcpy_chk.

Otherwise on at least x86_64 and s390x there is an unwanted PLT entry
in libc.so when configured with --enable-fortify-source=3 and build
with -Os.

This is observed in elf/check-localplt
Extra PLT reference: libc.so: __strcpy_chk

The call to PLT entry is in inet/ruserpass.c.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoarm: Remove wrong ldr from _dl_start_user (BZ 31339)
Adhemerval Zanella [Mon, 5 Feb 2024 16:10:24 +0000 (16:10 +0000)]
arm: Remove wrong ldr from _dl_start_user (BZ 31339)

The commit 49d877a80b29d3002887b084eec6676d9f5fec18 (arm: Remove
_dl_skip_args usage) removed the _SKIP_ARGS literal, which was
previously loader to r4 on loader _start.  However, the cleanup did not
remove the following 'ldr r4, [sl, r4]' on _dl_start_user, used to check
to skip the arguments after ld self-relocations.

In my testing, the kernel initially set r4 to 0, which makes the
ldr instruction just read the _GLOBAL_OFFSET_TABLE_.  However, since r4
is a callee-saved register; a different runtime might not zero
initialize it and thus trigger an invalid memory access.

Checked on arm-linux-gnu.

Reported-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
7 months agoLoongArch: Use builtins for ffs and ffsll
Xi Ruoyao [Sun, 4 Feb 2024 00:27:50 +0000 (08:27 +0800)]
LoongArch: Use builtins for ffs and ffsll

On LoongArch GCC compiles __builtin_ffs{,ll} to basically
`(x ? __builtin_ctz (x) : -1) + 1`.  Since a hardware ctz instruction is
available, this is much better than the table-driven generic
implementation.

Tested on loongarch64.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoRemove sysdeps/ia64/math-use-builtins-ffs.h
Xi Ruoyao [Sat, 3 Feb 2024 17:02:49 +0000 (01:02 +0800)]
Remove sysdeps/ia64/math-use-builtins-ffs.h

IA64 is gone.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
7 months agoFix stringop-overflow warning in tst-strlcat2.
Stefan Liebler [Tue, 16 Jan 2024 08:44:30 +0000 (09:44 +0100)]
Fix stringop-overflow warning in tst-strlcat2.

On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
In function ‘do_one_test’,
    inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [1844674407370955086618446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
   49 | # define STRNLEN strnlen
      |                  ^
tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
   89 |   size_t dst_length = STRNLEN (dst, n);
      |                       ^~~~~~~

This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
Fix stringop-overflow warning in test-strncat.
https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2

7 months agomips: FIx clone3 implementation (BZ 31325)
Adhemerval Zanella [Thu, 1 Feb 2024 17:29:53 +0000 (14:29 -0300)]
mips: FIx clone3 implementation (BZ 31325)

For o32 we need to setup a minimal stack frame to allow cprestore
on __thread_start_clone3 (which instruct the linker to save the
gp for PIC).  Also, there is no guarantee by kABI that $8 will be
preserved after syscall execution, so we need to save it on the
provided stack.

Checked on mipsel-linux-gnu.

Reported-by: Khem Raj <raj.khem@gmail.com>
Tested-by: Khem Raj <raj.khem@gmail.com>
7 months agostdlib: fix qsort example in manual
Paul Eggert [Thu, 1 Feb 2024 19:52:46 +0000 (11:52 -0800)]
stdlib: fix qsort example in manual

* manual/search.texi (Comparison Functions, Array Sort Function):
Sort an array of long ints, not doubles, to avoid hassles
with NaNs.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
7 months agosoft-fp: Add brain format support
Jakub Jelinek [Thu, 1 Feb 2024 15:58:49 +0000 (16:58 +0100)]
soft-fp: Add brain format support

In https://gcc.gnu.org/r13-3292 I've added brain format support
(std::bfloat16_t) on the GCC side, but as glibc has the master copy
of soft-fp, the following patch adds the files from that commit
and from https://gcc.gnu.org/r13-6598 and https://gcc.gnu.org/r13-6622
The files are not used by glibc right now.

7 months agoRename c2x / gnu2x tests to c23 / gnu23
Joseph Myers [Thu, 1 Feb 2024 17:55:57 +0000 (17:55 +0000)]
Rename c2x / gnu2x tests to c23 / gnu23

Complete the internal renaming from "C2X" and related names in GCC by
renaming *-c2x and *-gnu2x tests to *-c23 and *-gnu23.

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

7 months agomanual: Fix up stdbit.texi
Jakub Jelinek [Thu, 1 Feb 2024 15:36:55 +0000 (16:36 +0100)]
manual: Fix up stdbit.texi

My recent change broke make pdf and in other documentation formats
results in weird rendering and invalid URL, all because of a forgotten
comma to separate @uref arguments.

7 months agostring: Use builtins for ffs and ffsll
Adhemerval Zanella Netto [Fri, 25 Aug 2023 16:30:58 +0000 (13:30 -0300)]
string: Use builtins for ffs and ffsll

It allows to remove a lot of arch-specific implementations.

Checked on x86_64, aarch64, powerpc64.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agomisc: tst-poll: Proper synchronize with child before sending the signal
Adhemerval Zanella [Fri, 26 Jan 2024 11:23:41 +0000 (08:23 -0300)]
misc: tst-poll: Proper synchronize with child before sending the signal

When running the testsuite in parallel, for instance running make -j
$(nproc) check, occasionally tst-epoll fails with a timeout.  It happens
because it sometimes takes a bit more than 10ms for the process to get
cloned and blocked by the syscall.  In that case the signal is
sent to early, and the test fails with a timeout.

Checked on x86_64-linux-gnu.

7 months agomath: Remove bogus math implementations
Adhemerval Zanella [Tue, 30 Jan 2024 16:54:27 +0000 (13:54 -0300)]
math: Remove bogus math implementations

The exp10, exp10l, fma, fmaf, and fmal default implementation do not
implement the appropriate semantics nor with an reasonable accuracy.
They are also not used by any supported port.

7 months agoRefer to C23 in place of C2X in glibc
Joseph Myers [Thu, 1 Feb 2024 11:02:01 +0000 (11:02 +0000)]
Refer to C23 in place of C2X in glibc

WG14 decided to use the name C23 as the informal name of the next
revision of the C standard (notwithstanding the publication date in
2024).  Update references to C2X in glibc to use the C23 name.

This is intended to update everything *except* where it involves
renaming files (the changes involving renaming tests are intended to
be done separately).  In the case of the _ISOC2X_SOURCE feature test
macro - the only user-visible interface involved - support for that
macro is kept for backwards compatibility, while adding
_ISOC23_SOURCE.

Tested for x86_64.

7 months agoelf: Remove _dl_sysdep_open_object hook function
Florian Weimer [Thu, 1 Feb 2024 07:59:02 +0000 (08:59 +0100)]
elf: Remove _dl_sysdep_open_object hook function

It is currently not used by any target.

7 months agobuild-many-glibcs: relax version check to allow non-digit characters
Fangrui Song [Wed, 31 Jan 2024 23:46:23 +0000 (15:46 -0800)]
build-many-glibcs: relax version check to allow non-digit characters

A version string may contain non-digit characters, commonly found in
built-from-VCS tools, e.g.
```
git version 2.39.GIT
git version 2.43.0.493.gbc7ee2e5e1
```

`int()` will raise a ValueError, leading to a spurious 'missing'.

Reviewed-by: DJ Delorie <dj@redhat.com>
7 months agoUse gcc __builtin_stdc_* builtins in stdbit.h if possible
Jakub Jelinek [Wed, 31 Jan 2024 18:17:27 +0000 (19:17 +0100)]
Use gcc __builtin_stdc_* builtins in stdbit.h if possible

The following patch uses the GCC 14 __builtin_stdc_* builtins in stdbit.h
for the type-generic macros, so that when compiled with GCC 14 or later,
it supports not just 8/16/32/64-bit unsigned integers, but also 128-bit
(if target supports them) and unsigned _BitInt (any supported precision).
And so that the macros don't expand arguments multiple times and can be
evaluated in constant expressions.

The new testcase is gcc's gcc/testsuite/gcc.dg/builtin-stdc-bit-1.c
adjusted to test stdbit.h and the type-generic macros in there instead
of the builtins and adjusted to use glibc test framework rather than
gcc style tests with __builtin_abort ().

Signed-off-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Joseph Myers <josmyers@redhat.com>
7 months agoOpen master branch for glibc 2.40 development glibc-2.39.9000
Andreas K. Hüttel [Wed, 31 Jan 2024 01:07:20 +0000 (02:07 +0100)]
Open master branch for glibc 2.40 development

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoCreate ChangeLog.old/ChangeLog.28 glibc-2.39
Andreas K. Hüttel [Wed, 31 Jan 2024 00:34:58 +0000 (01:34 +0100)]
Create ChangeLog.old/ChangeLog.28

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoversion.h, include/features.h: Bump version to 2.39
Andreas K. Hüttel [Wed, 31 Jan 2024 00:29:11 +0000 (01:29 +0100)]
version.h, include/features.h: Bump version to 2.39

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agopo: Update translations
Andreas K. Hüttel [Wed, 31 Jan 2024 00:10:02 +0000 (01:10 +0100)]
po: Update translations

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agolibc.pot: regenerate
Andreas K. Hüttel [Tue, 30 Jan 2024 23:52:00 +0000 (00:52 +0100)]
libc.pot: regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoINSTALL, install.texi: minor updates, regenerate
Andreas K. Hüttel [Tue, 30 Jan 2024 23:13:43 +0000 (00:13 +0100)]
INSTALL, install.texi: minor updates, regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agocontrib.texi: update
Andreas K. Hüttel [Tue, 30 Jan 2024 22:48:12 +0000 (23:48 +0100)]
contrib.texi: update

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoNEWS: insert advisories and fixed bugs for 2.39
Andreas K. Hüttel [Tue, 30 Jan 2024 21:40:34 +0000 (22:40 +0100)]
NEWS: insert advisories and fixed bugs for 2.39

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoS390: Fix building with --disable-mutli-arch [BZ #31196]
Stefan Liebler [Tue, 30 Jan 2024 08:34:32 +0000 (09:34 +0100)]
S390: Fix building with --disable-mutli-arch [BZ #31196]

Starting with commits
7ea510127e2067efa07865158ac92c330c379950
string: Add libc_hidden_proto for strchrnul
22999b2f0fb62eed1af4095d062bd1272d6afeb1
string: Add libc_hidden_proto for memrchr

building glibc on s390x with --disable-multi-arch fails if only
the C-variant of strchrnul / memrchr is used.  This is the case
if gcc uses -march < z13.

The build fails with:
../sysdeps/s390/strchrnul-c.c:28:49: error: ‘__strchrnul_c’ undeclared here (not in a function); did you mean ‘__strchrnul’?
   28 | __hidden_ver1 (__strchrnul_c, __GI___strchrnul, __strchrnul_c);

With --disable-multi-arch, __strchrnul_c is not available as string/strchrnul.c
is just included without defining STRCHRNUL and thus we also don't have to create
the internal hidden symbol.

Tested-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoFix typo
Andreas K. Hüttel [Tue, 30 Jan 2024 21:18:42 +0000 (22:18 +0100)]
Fix typo

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agomanual/io: Fix swapped reading and writing phrase.
Joe Simmons-Talbott [Tue, 30 Jan 2024 18:58:34 +0000 (13:58 -0500)]
manual/io: Fix swapped reading and writing phrase.

Reviewed-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoUpdate advisory format and introduce some automation
Siddhesh Poyarekar [Wed, 24 Jan 2024 18:37:20 +0000 (13:37 -0500)]
Update advisory format and introduce some automation

Simplify the advisory format by dropping the -Backport tags and instead
stick to using just the -Commit tags.  To identify backports, put a
substring of git-describe into the release version in the brackets next
to the commit ref.  This way, it not only identifies that the fix (or
regression) is on the release/2.YY/master branch, it also disambiguates
regressions/fixes in the branch from those in the tarball.

Add a README to make it easier for consumers to understand the format.
Additionally, the Release wiki needs to be updated to inform the release
manager to:

1. Generate a NEWS snipped from the advisories directory

AND

2. on release/2.YY/master, replace the advisories directory with a text
   file pointing to the advisories directory in master so that we don't
   have to update multiple locations.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoDocument CVE-2023-6246, CVE-2023-6779, and CVE-2023-6780
Arjun Shankar [Tue, 30 Jan 2024 18:29:45 +0000 (19:29 +0100)]
Document CVE-2023-6246, CVE-2023-6779, and CVE-2023-6780

This commit adds "advisories" entries for the above three CVEs.

7 months agosyslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780)
Arjun Shankar [Mon, 15 Jan 2024 16:44:45 +0000 (17:44 +0100)]
syslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780)

__vsyslog_internal calculated a buffer size by adding two integers, but
did not first check if the addition would overflow.  This commit fixes
that.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
7 months agosyslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6779)
Arjun Shankar [Mon, 15 Jan 2024 16:44:44 +0000 (17:44 +0100)]
syslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6779)

__vsyslog_internal used the return value of snprintf/vsnprintf to
calculate buffer sizes for memory allocation.  If these functions (for
any reason) failed and returned -1, the resulting buffer would be too
small to hold output.  This commit fixes that.

All snprintf/vsnprintf calls are checked for negative return values and
the function silently returns upon encountering them.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agosyslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6246)
Arjun Shankar [Mon, 15 Jan 2024 16:44:43 +0000 (17:44 +0100)]
syslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6246)

__vsyslog_internal did not handle a case where printing a SYSLOG_HEADER
containing a long program name failed to update the required buffer
size, leading to the allocation and overflow of a too-small buffer on
the heap.  This commit fixes that.  It also adds a new regression test
that uses glibc.malloc.check.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
7 months agoUse binutils 2.42 branch in build-many-glibcs.py
Joseph Myers [Tue, 30 Jan 2024 14:20:35 +0000 (14:20 +0000)]
Use binutils 2.42 branch in build-many-glibcs.py

This patch makes build-many-glibcs.py use binutils 2.42 branch.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

7 months agoelf: correct relocation statistics for !ELF_MACHINE_START_ADDRESS
Andreas Schwab [Mon, 29 Jan 2024 16:01:07 +0000 (17:01 +0100)]
elf: correct relocation statistics for !ELF_MACHINE_START_ADDRESS

Fixes: 6628c742b2 ("elf: Remove prelink support")
7 months agoRelicense IBM portions of resolv/base64.c resolv/res_debug.c.
Carlos O'Donell [Thu, 18 Jan 2024 17:28:20 +0000 (12:28 -0500)]
Relicense IBM portions of resolv/base64.c resolv/res_debug.c.

This change relicenses the IBM portions of resolv/base64.c and
resolv/res_debug.c to a new license that does not have use-limited
patent language.  The top-level LICENSE file is updated with the
license.

The relicensing was approved by IBM.

Signed-off-by: Brad Topol, IBM Director of Open Technologies <btopol@us.ibm.com>
Signed-off-by: Richard Fontana <rfontana@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
7 months agolocaledata: Use consistent values for grouping and mon_grouping
Mike FABIAN [Thu, 18 Jan 2024 15:52:03 +0000 (16:52 +0100)]
localedata: Use consistent values for grouping and mon_grouping

Resolves: BZ # 31205

Adapt test cases in test-grouping_iterator.c

7 months agomanual: fix order of arguments of memalign and aligned_alloc (Bug 27547)
Dennis Brendel [Mon, 15 Jan 2024 08:55:37 +0000 (09:55 +0100)]
manual: fix order of arguments of memalign and aligned_alloc (Bug 27547)

On the summary page the order of the function arguments was reversed, but it is
in correct order in the other places of the manual.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agomanual, NEWS: Document malloc side effect of dynamic TLS changes
Florian Weimer [Wed, 24 Jan 2024 08:34:15 +0000 (09:34 +0100)]
manual, NEWS: Document malloc side effect of dynamic TLS changes

The increased malloc subsystem usage is a side effect of
commit d2123d68275acc0f061e73d5f86ca504e0d5a344 ("elf: Fix slow tls
access after dlopen [BZ #19924]").

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
7 months agoNEWS: Update temporary files ignored by ldconfig
Florian Weimer [Wed, 24 Jan 2024 08:34:15 +0000 (09:34 +0100)]
NEWS: Update temporary files ignored by ldconfig

Fixes commit 2aa0974d2573441bffd596b07bff8698b1f2f18c ("elf: ldconfig
should skip temporary files created by package managers") and
commit cfb5a97a93ea656e3b2263e42142a4032986d9ba ("ldconfig: Fixes for
skipping temporary files.").

Reported-by: Guillem Jover <guillem@debian.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agopo: Incorporate translations (sr)
Andreas K. Hüttel [Tue, 23 Jan 2024 21:28:23 +0000 (22:28 +0100)]
po: Incorporate translations (sr)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agostring: Disable stack protector for memset in early static initialization
Adhemerval Zanella [Mon, 22 Jan 2024 13:42:19 +0000 (10:42 -0300)]
string: Disable stack protector for memset in early static initialization

For ports that use the default memset, the compiler might generate early
calls before the stack protector is initialized (for instance, riscv
with -fstack-protector-all on _dl_aux_init).

Checked on riscv64-linux-gnu-rv64imafdc-lp64d.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agoqsort: Fix a typo causing unnecessary malloc/free (BZ 31276)
Xi Ruoyao [Mon, 22 Jan 2024 20:29:18 +0000 (04:29 +0800)]
qsort: Fix a typo causing unnecessary malloc/free (BZ 31276)

In qsort_r we allocate a buffer sized QSORT_STACK_SIZE (1024) on stack
and we intend to use it if all elements can fit into it.  But there is a
typo:

    if (total_size < sizeof buf)
      buf = tmp;
    else
      /* allocate a buffer on heap and use it ... */

Here "buf" is a pointer, thus sizeof buf is just 4 or 8, instead of
1024.  There is also a minor issue that we should use "<=" instead of
"<".

This bug is detected debugging some strange heap corruption running the
Ruby-3.3.0 test suite (on an experimental Linux From Scratch build using
Binutils-2.41.90 and Glibc trunk, and also Fedora Rawhide [1]).  It
seems Ruby is doing some wild "optimization" by jumping into somewhere
in qsort_r instead of calling it normally, resulting in a double free of
buf if we allocate it on heap.  The issue can be reproduced
deterministically with:

    LD_PRELOAD=/usr/lib/libc_malloc_debug.so MALLOC_CHECK_=3 \
    LD_LIBRARY_PATH=. ./ruby test/runner.rb test/ruby/test_enum.rb

in Ruby-3.3.0 tree after building it.  This change would hide the issue
for Ruby, but Ruby is likely still buggy (if using this "optimization"
sorting larger arrays).

[1]:https://kojipkgs.fedoraproject.org/work/tasks/9729/111889729/build.log

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
7 months agoriscv: add support for static PIE
Andreas Schwab [Wed, 17 Jan 2024 14:35:57 +0000 (15:35 +0100)]
riscv: add support for static PIE

In order to support static PIE the startup code must avoid relocations
before __libc_start_main is called.

7 months agosh: Fix static build with --enable-fortify
Adhemerval Zanella [Tue, 16 Jan 2024 16:07:47 +0000 (13:07 -0300)]
sh: Fix static build with --enable-fortify

For static the internal symbols should not be prepended with the
internal __GI_.

Checked with a make check for sh4-linux-gnu.

7 months agosparc: Fix sparc64 memmove length comparison (BZ 31266)
Adhemerval Zanella [Thu, 18 Jan 2024 13:52:18 +0000 (10:52 -0300)]
sparc: Fix sparc64 memmove length comparison (BZ 31266)

The small counts copy bytes comparsion should be unsigned (as the
memmove size argument).  It fixes string/tst-memmove-overflow on
sparcv9, where the input size triggers an invalid code path.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

7 months agosparc64: Remove unwind information from signal return stubs [BZ#31244]
Adhemerval Zanella [Wed, 17 Jan 2024 13:38:09 +0000 (10:38 -0300)]
sparc64: Remove unwind information from signal return stubs [BZ#31244]

Similar to sparc32 fix, remove the unwind information on the signal
return stubs.  This fixes the regressions:

FAIL: nptl/tst-cancel24-static
FAIL: nptl/tst-cond8-static
FAIL: nptl/tst-mutex8-static
FAIL: nptl/tst-mutexpi8-static
FAIL: nptl/tst-mutexpi9

On sparc64-linux-gnu.

7 months agosparc: Remove 64 bit check on sparc32 wordsize (BZ 27574)
Adhemerval Zanella [Wed, 17 Jan 2024 13:13:06 +0000 (10:13 -0300)]
sparc: Remove 64 bit check on sparc32 wordsize (BZ 27574)

The sparc32 is always 32 bits.

Checked on sparcv9-linux-gnu.

7 months agoUse --disable-default-pie for sparc in build-many-glibcs.py
Adhemerval Zanella [Wed, 17 Jan 2024 12:24:55 +0000 (09:24 -0300)]
Use --disable-default-pie for sparc in build-many-glibcs.py

The staticcally built binaries fails without this option [1].

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29575

7 months agoFurther build-many-glibcs.py fixes for utcnow() deprecation
Joseph Myers [Fri, 19 Jan 2024 13:30:34 +0000 (13:30 +0000)]
Further build-many-glibcs.py fixes for utcnow() deprecation

It turns out that the replacement of datetime.datetime.utcnow(), for a
warning produced early in running build-many-glibcs.py with Python
3.12, (a) wasn't complete (there were other uses elsewhere in the
script also needing updating) and (b) broke reading of build-time from
build-state.json, because an aware datetime was written out including
+00:00 for the timezone, which was not expected by the strptime call.

Fix the first by making the change to
datetime.datetime.now(datetime.timezone.utc) for all the remaining
utcnow() calls.  Fix the second by using strftime with an explicit
format instead of just str() when formatting build times for
build-state.json and and email subjects, and then setting the timezone
explicitly when reading from build-state.json.  (Other uses, in
particular messages output by the bot, continue to use str() as the
precise format should not matter in those cases; it shouldn't actually
matter for email subjects either but it seems a good idea to keep
those short.)

Tested with a bot-cycle run and checking the format of times in
build-state.json afterwards.

8 months agosparc: Do not test preservation of NaN payloads for LEON
Daniel Cederman [Fri, 12 Jan 2024 09:26:23 +0000 (10:26 +0100)]
sparc: Do not test preservation of NaN payloads for LEON

The FPU used by LEON does not preserve NaN payload. This change allows
the math/test-*-canonicalize tests to pass on LEON.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agosparc: Force calculation that raises exception
Daniel Cederman [Tue, 16 Jan 2024 15:16:41 +0000 (16:16 +0100)]
sparc: Force calculation that raises exception

Use the math_force_eval() macro to force the calculation to complete and
raise the exception.

With this change the math/test-fenv test pass.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agosparc: Fix llrint and llround missing exceptions on SPARC V8
Daniel Cederman [Tue, 16 Jan 2024 08:31:40 +0000 (09:31 +0100)]
sparc: Fix llrint and llround missing exceptions on SPARC V8

Conversions from a float to a long long on SPARC v8 uses a libgcc function
that may not raise the correct exceptions on overflow. It also may raise
spurious "inexact" exceptions on non overflow cases. This patch fixes the
problem in the same way as for RV32.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agosparc: Remove unwind information from signal return stubs [BZ #31244]
Daniel Cederman [Tue, 16 Jan 2024 08:31:41 +0000 (09:31 +0100)]
sparc: Remove unwind information from signal return stubs [BZ #31244]

The functions were previously written in C, but were not compiled
with unwind information. The ENTRY/END macros includes .cfi_startproc
and .cfi_endproc which adds unwind information. This caused the
tests cleanup-8 and cleanup-10 in the GCC testsuite to fail.
This patch adds a version of the ENTRY/END macros without the
CFI instructions that can be used instead.

sigaction registers a restorer address that is located two instructions
before the stub function. This patch adds a two instruction padding to
avoid that the unwinder accesses the unwind information from the function
that the linker has placed right before it in memory. This fixes an issue
with pthread_cancel that caused tst-mutex8-static (and other tests) to fail.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agosparc: Prevent stfsr from directly following floating-point instruction
Daniel Cederman [Mon, 15 Jan 2024 14:53:45 +0000 (15:53 +0100)]
sparc: Prevent stfsr from directly following floating-point instruction

On LEON, if the stfsr instruction is immediately following a floating-point
operation instruction in a running program, with no other instruction in
between the two, the stfsr might behave as if the order was reversed
between the two instructions and the stfsr occurred before the
floating-point operation.

Add a nop instruction before the stfsr to prevent this from happening.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agosparc: Use existing macros to avoid code duplication
Daniel Cederman [Mon, 15 Jan 2024 14:53:44 +0000 (15:53 +0100)]
sparc: Use existing macros to avoid code duplication

Macros for using inline assembly to access the fp state register exists
in both fenv_private.h and in fpu_control.h. Let fenv_private.h use the
macros from fpu_control.h

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This page took 0.084097 seconds and 5 git commands to generate.