Commit Graph

39639 Commits

Author SHA1 Message Date
Samuel Thibault
63550530d9 hurd: Fix unwinding over INTR_MSG_TRAP
We used to use .cfi_adjust_cfa_offset around %esp manipulation
asm instructions to fix unwinding, but when building glibc with
-fno-omit-frame-pointer this is bogus since in that case %ebp is the CFA and
does not move.

Instead, let's force -fno-omit-frame-pointer when building intr-msg.c so
that %ebp can always be used and no .cfi_adjust_cfa_offset is needed.
2023-02-09 19:58:43 +01:00
Adhemerval Zanella Netto
16e424a325 powerpc64: Add the clone3 wrapper
It follows the internal signature:

  extern int clone3 (struct clone_args *__cl_args, size_t __size,
 int (*__func) (void *__arg), void *__arg);

The powerpc64 ABI requires an initial stackframe so the child can
store/restore the TOC.  It is create prior calling clone3 by
adjusting the stack size (since kernel will compute the stack as
stack plus size).

Checked on powerpc64-linux-gnu (power8, kernel 6.0) and
powerpc64le-linux-gnu (power9, kernel 4.18).
Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
2023-02-09 07:49:25 -03:00
Adhemerval Zanella
fb95c31638 string: Disable stack protector in early static initialization
For powerpc, strncmp is used on _dl_string_platform issued by
__tcb_parse_hwcap_and_convert_at_platform.

Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2023-02-08 17:14:03 -03:00
Adhemerval Zanella
22999b2f0f string: Add libc_hidden_proto for memrchr
Although static linker can optimize it to local call, it follows the
internal scheme to provide hidden proto and definitions.

Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2023-02-08 17:13:58 -03:00
Adhemerval Zanella
7ea510127e string: Add libc_hidden_proto for strchrnul
Although static linker can optimize it to local call, it follows the
internal scheme to provide hidden proto and definitions.

Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2023-02-08 17:13:56 -03:00
Florian Weimer
9fd63e3537 elf: Smoke-test ldconfig -p against system /etc/ld.so.cache
The test is sufficient to detect the ldconfig bug fixed in
commit 9fe6f63638 ("elf: Fix 64 time_t
support for installed statically binaries").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-02-08 18:11:04 +01:00
Carlos O'Donell
67c37737ed NEWS: Document CVE-2023-25139.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-02-07 15:19:39 -05:00
Andreas Schwab
41349f6f67 Use 64-bit time_t interfaces in strftime and strptime (bug 30053)
Both functions use time_t only internally, so the ABI is not affected.
2023-02-07 10:15:09 +01:00
quxm
ec6d2b83f2 C-SKY: Strip hard float abi from hard float feature.
The hard float abi and hard float are different,
  Hard float abi: Use float register to pass float type arguments.
  Hard float: Enable the hard float ISA feature.
So the with_fp_cond cannot represent these two features. When
-mfloat-abi=softfp, the float abi is soft and hard float is enabled.
So add 'with_hard_float_abi' in preconfigure and define 'CSKY_HARD_FLOAT_ABI'
if float abi is hard, and use 'CSKY_HARD_FLOAT_ABI' to determine
dynamic linker because it is what determines compatibility.
And with_fp_cond is still needed to tell glibc whether to enable
hard floating feature.
In addition, use AC_TRY_COMMAND to test gcc to ensure compatibility
between different versions of gcc. The original way has a problem
that __CSKY_HARD_FLOAT_FPU_SF__ means the target only has single
hard float-points ISA, so it's not defined in CPUs like ck810f.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-07 16:34:24 +08:00
Stefan Liebler
41f67ccbe9 S390: Influence hwcaps/stfle via GLIBC_TUNABLES.
This patch enables the option to influence hwcaps and stfle bits used
by the s390 specific ifunc-resolvers.  The currently x86-specific
tunable glibc.cpu.hwcaps is also used on s390x to achieve the task. In
addition the user can also set a CPU arch-level like z13 instead of
single HWCAP and STFLE features.

Note that the tunable only handles the features which are really used
in the IFUNC-resolvers.  All others are ignored as the values are only
used inside glibc.  Thus we can influence:
- HWCAP_S390_VXRS (z13)
- HWCAP_S390_VXRS_EXT (z14)
- HWCAP_S390_VXRS_EXT2 (z15)
- STFLE_MIE3 (z15)

The influenced hwcap/stfle-bits are stored in the s390-specific
cpu_features struct which also contains reserved fields for future
usage.

The ifunc-resolvers and users of stfle bits are adjusted to use the
information from cpu_features struct.

On 31bit, the ELF_MACHINE_IRELATIVE macro is now also defined.
Otherwise the new ifunc-resolvers segfaults as they depend on
the not yet processed_rtld_global_ro@GLIBC_PRIVATE relocation.
2023-02-07 09:19:27 +01:00
Adhemerval Zanella
0b9d2d4a76 string: Hook up the default implementation on test-strrchr
And remove SIMPLE_STRRCHR, which is not used anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
77a9e5c97e string: Hook up the default implementation on test-memrchr
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
0dfa8617b5 string: Hook up the default implementation on test-memchr
And remove SIMPLE_MEMCHR, which is not used anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
3092c84900 string: Hook up the default implementation on test-strcpy
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
11aabacce8 string: Hook up the default implementation on test-stpcpy
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
c863e33f78 string: Hook up the default implementation on test-strncmp
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
e7a0c81e61 string: Hook up the default implementation on test-strcmp
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
c19e3394a2 string: Hook up the default implementation on test-strchr
Also remove the simple_STRCHR, which can be easily replaced.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
b79cffb391 string: Hook up the default implementation on test-strnlen
Also remove the SIMPLE_STRNLEN, which is not used anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
52d9adc9e3 string: Hook up the default implementation on test-strlen
Also remove the simple_STRLEN and builtin_strlen, which are not used
anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
25788431c0 riscv: Add string-fza.h and string-fzi.h
It uses the bitmanip extension to optimize index_fist and index_last
with clz/ctz (using generic implementation that routes to compiler
builtin) and orc.b to check null bytes.

Checked the string test on riscv64 user mode.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
c505eb828e sh: Add string-fzb.h
Use the SH cmp/str on has_{zero,eq,zero_eq}.

Checked on sh4-linux-gnu.
2023-02-06 16:19:35 -03:00
Richard Henderson
080685c90f powerpc: Add string-fza.h
While ppc has the more important string functions in assembly,
there are still a few generic routines used.

Use the Power 6 CMPB insn for testing of zeros.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:19:35 -03:00
Richard Henderson
885306b2f6 arm: Add string-fza.h
While arm has the more important string functions in assembly,
there are still a few generic routines used.

Use the UQSUB8 insn for testing of zeros.

Checked on armv7-linux-gnueabihf

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:19:35 -03:00
Richard Henderson
120ad6ed1a alpha: Add string-fza, string-fzb.h, string-fzi.h, and string-shift.h
While alpha has the more important string functions in assembly,
there are still a few for find the generic routines are used.

Use the CMPBGE insn, via the builtin, for testing of zeros.  Use a
simplified expansion of __builtin_ctz when the insn isn't available.

Checked on alpha-linux-gnu.

Co-authored-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:19:35 -03:00
Richard Henderson
c62b1c29c2 hppa: Add string-fza.h, string-fzc.h, and string-fzi.h
Use UXOR,SBZ to test for a zero byte within a word.  While we can
get semi-decent code out of asm-goto, we would do slightly better
with a compiler builtin.

For index_zero et al, sequential testing of bytes is less expensive than
any tricks that involve a count-leading-zeros insn that we don't have.

Checked on hppa-linux-gnu.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:19:35 -03:00
Richard Henderson
be836d9153 hppa: Add memcopy.h
GCC's combine pass cannot merge (x >> c | y << (32 - c)) into a
double-word shift unless (1) the subtract is in the same basic block
and (2) the result of the subtract is used exactly once.  Neither
condition is true for any use of MERGE.

By forcing the use of a double-word shift, we not only reduce
contention on SAR, but also allow the setting of SAR to be hoisted
outside of a loop.

Checked on hppa-linux-gnu.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
167f6230af string: Improve generic strrchr with memrchr and strlen
Now that both strlen and memrchr have word vectorized implementation,
it should be faster to implement strrchr based on memrchr over the
string length instead of calling strchr on a loop.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
9d4fa7a1ca string: Improve generic memrchr
New algorithm read the lastaligned address and mask off the unwanted
bytes.  The loop now read word-aligned address and check using the
has_eq macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
0f4254311e string: Improve generic strnlen with memchr
It also cleanups the multiple inclusion by leaving the ifunc
implementation to undef the weak_alias and libc_hidden_def.

Co-authored-by: Richard Henderson  <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
2a8867a17f string: Improve generic memchr
New algorithm read the first aligned address and mask off the
unwanted bytes (this strategy is similar to arch-specific
implementations used on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_eq
macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
3709ed9047 string: Improve generic strcpy
Now that stpcpy is vectorized based on op_t, it should be better to
call it instead of strlen plus memcpy.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
30c1dfde31 string: Improve generic stpcpy
It follows the strategy:

  - Align the destination on word boundary using byte operations.

  - If source is also word aligned, read a word per time, check for
    null (using has_zero from string-fzb.h), and write the remaining
    bytes.

  - If source is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case,
    check for null with has_zero, and write the remaining bytes if
    null is found.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
367c31b5d6 string: Improve generic strncmp
It follows the strategy:

   - Align the first input to word boundary using byte operations.

   - If second input is also word aligned, read a word per time, check
     for  null (using has_zero), and check final words using byte
     operation.

   - If second input is not word aligned, loop by aligning the source,
     and merge the result of two reads.  Similar to aligned case, check
     for null with has_zero, and check final words using byte operation.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
30cf54bf30 string: Improve generic strcmp
It follows the strategy:

  - Align the first input to word boundary using byte operations.

  - If second input is also word aligned, read a word per time, check for
    null (using has_zero), and check final words using byte operation.

  - If second input is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case, check for
    null with has_zero, and check final words using byte operation.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
506f7dbbab string: Improve generic strchr
New algorithm now calls strchrnul.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
685e844a97 string: Improve generic strchrnul
New algorithm read the first aligned address and mask off the unwanted
bytes (this strategy is similar to arch-specific  implementations used
on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_zero_eq
function.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
350d8d1366 string: Improve generic strlen
New algorithm read the first aligned address and mask off the
unwanted bytes (this strategy is similar to arch-specific
implementations used on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_zero
macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powercp64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
00cb84dde7 Add string vectorized find and detection functions
This patch adds generic string find and detection meant to be used in
generic vectorized string implementation.  The idea is to decompose the
basic string operation so each architecture can reimplement if it
provides any specialized hardware instruction.

The 'string-misc.h' provides miscellaneous functions:

  - extractbyte: extracts the byte from an specific index.
  - repeat_bytes: setup an word by replicate the argument on each byte.

The 'string-fza.h' provides zero byte detection functions:

  - find_zero_low, find_zero_all, find_eq_low, find_eq_all,
    find_zero_eq_low, find_zero_eq_all, and find_zero_ne_all

The 'string-fzb.h' provides boolean zero byte detection functions:

  - has_zero: determine if any byte within a word is zero.
  - has_eq: determine byte equality between two words.
  - has_zero_eq: determine if any byte within a word is zero along with
    byte equality between two words.

The 'string-fzi.h' provides positions for string-fza.h results:

  - index_first: return index of first zero byte within a word.
  - index_last: return index of first byte different between two words.

The 'string-fzc.h' provides a combined version of fza and fzi:

  - index_first_zero_eq: return index of first zero byte within a word or
    first byte different between two words.
  - index_first_zero_ne: return index of first zero byte within a word or
    first byte equal between two words.
  - index_last_zero: return index of last zero byte within a word.
  - index_last_eq: return index of last byte different between two words.

The 'string-shift.h' provides a way to mask off parts of a work based on
some alignmnet (to handle unaligned arguments):

  - shift_find, shift_find_last.

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-02-06 16:19:35 -03:00
Richard Henderson
d45890b28c Parameterize OP_T_THRES from memcopy.h
It moves OP_T_THRES out of memcopy.h to its own header and adjust
each architecture that redefines it.

Checked with a build and check with run-built-tests=no for all major
Linux ABIs.

Co-authored-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Adhemerval Zanella
d1a9b6d8e7 Parameterize op_t from memcopy.h
It moves the op_t definition out to an specific header, adds
the attribute 'may-alias', and cleanup its duplicated definitions.

Checked with a build and check with run-built-tests=no for all major
Linux ABIs.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-02-06 16:19:35 -03:00
Wilco Dijkstra
32c7acd464 Replace rawmemchr (s, '\0') with strchr
Almost all uses of rawmemchr find the end of a string.  Since most targets use
a generic implementation, replacing it with strchr is better since that is
optimized by compilers into strlen (s) + s.  Also fix the generic rawmemchr
implementation to use a cast to unsigned char in the if statement.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-02-06 16:16:19 +00:00
Wilco Dijkstra
d2d3f3720c AArch64: Improve SVE memcpy and memmove
Improve SVE memcpy by copying 2 vectors if the size is small enough.
This improves performance of random memcpy by ~9% on Neoverse V1, and
33-64 byte copies are ~16% faster.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2023-02-06 16:15:34 +00:00
Carlos O'Donell
c980549cc6 Account for grouping in printf width (bug 30068)
This is a partial fix for mishandling of grouping when formatting
integers.  It properly computes the width in the presence of grouping
characters when the width is larger than the number of significant
digits. The precision related issue is documented in bug 23432.

Co-authored-by: Andreas Schwab <schwab@suse.de>
2023-02-06 10:20:39 -05:00
Flavio Cruz
a1dcc64c9b Move RETURN_TO to x86/sysdep.h and implement x86_64 version.
Message-Id: <Y99nfeBrTubZL9oi@jupiter.tail36e24.ts.net>
2023-02-05 12:36:38 +01:00
Andreas Schwab
359a0b9dbc Remove pthread-pi-defines.sym
It became unused with the removal of the assembler implementation of the
pthread functions.
2023-02-03 17:59:55 +01:00
Sam James
35bcb08eaa stdlib: tests: don't double-define _FORTIFY_SOURCE
If using -D_FORITFY_SOURCE=3 (in my case, I've patched GCC to add
=3 instead of =2 (we've done =2 for years in Gentoo)), building
glibc tests will fail on testmb like:
```
<command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make[2]: *** [../o-iterator.mk:9: /var/tmp/portage/sys-libs/glibc-2.36/work/build-x86-x86_64-pc-linux-gnu-nptl/stdlib/testmb.o] Error 1
make[2]: *** Waiting for unfinished jobs....
```

It's just because we're always setting -D_FORTIFY_SOURCE=2
rather than unsetting it first. If F_S is already 2, it's harmless,
but if it's another value (say, 1, or 3), the compiler will bawk.

(I'm not aware of a reason this couldn't be tested with =3,
but the toolchain support is limited for that (too new), and we want
to run the tests everywhere possible.)

Signed-off-by: Sam James <sam@gentoo.org>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-02-02 23:00:58 -05:00
caiyinyu
83d49a53aa LoongArch: Add new relocation types. 2023-02-03 09:37:07 +08:00
Flavio Cruz
5130cd77b0 Remove sysdeps/mach/i386/machine-sp.h
This file is not used today since we end up using
sysdeps/i386/htl/machine-sp.h. Getting the stack pointer does not need
to be hurd specific and can go into sysdeps/<arch>.
Message-Id: <Y9tpWs2WOgE/Duiq@jupiter.tail36e24.ts.net>
2023-02-02 19:47:47 +01:00
Siddhesh Poyarekar
2337e04e21 cdefs: Limit definition of fortification macros
Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL >
0.  This has the effect of not defining these macros on older C90
compilers that do not have support for variable length argument lists.

Also trim off the trailing backslashes from the definition of
__glibc_fortify and __glibc_fortify_n macros.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-02-02 07:49:02 -05:00