platform/upstream/glibc.git
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.

7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 months agolocaledata: renamed: aa_ER@saaho -> ssy_ER
Mike FABIAN [Thu, 18 Jan 2024 10:08:48 +0000 (11:08 +0100)]
localedata: renamed:    aa_ER@saaho -> ssy_ER

Resolves: BZ # 19956

7 months agoDefine ISO 639-3 "ssy" (Saho)
Mike FABIAN [Thu, 18 Jan 2024 10:01:10 +0000 (11:01 +0100)]
Define ISO 639-3 "ssy" (Saho)

Related: BZ # 19956

References:
https://iso639-3.sil.org/code/ssy
https://en.wikipedia.org/wiki/Saho_language

7 months agolocaledata: add crh_RU, Crimean Tartar language in the Cyrillic script as used in...
Mike FABIAN [Thu, 18 Jan 2024 08:15:18 +0000 (09:15 +0100)]
localedata: add crh_RU, Crimean Tartar language in the Cyrillic script as used in Russia.

Resolves: BZ # 24386

7 months agolocaledata: tr_TR, ku_TR: Sync with CLDR: “Turkey” -> “Türkiye”
Mike FABIAN [Thu, 18 Jan 2024 07:30:34 +0000 (08:30 +0100)]
localedata: tr_TR, ku_TR: Sync with CLDR: “Turkey” -> “Türkiye”

Resolves: BZ # 31257

7 months agolocaledata: miq_NI: Shorten month names in abmon
Mike FABIAN [Wed, 17 Jan 2024 17:25:13 +0000 (18:25 +0100)]
localedata: miq_NI: Shorten month names in abmon

Resolves: BZ # 23172

7 months agoUpdate kernel version to 6.7 in header constant tests
Joseph Myers [Wed, 17 Jan 2024 21:15:37 +0000 (21:15 +0000)]
Update kernel version to 6.7 in header constant tests

This patch updates the kernel version in the tests tst-mman-consts.py,
tst-mount-consts.py and tst-pidfd-consts.py to 6.7.  (There are no new
constants covered by these tests in 6.7 that need any other header
changes.)

Tested with build-many-glibcs.py.

7 months agolocaledata: add gbm_IN locale
Mike FABIAN [Wed, 17 Jan 2024 16:13:48 +0000 (17:13 +0100)]
localedata: add gbm_IN locale

Resolves: BZ # 19479

7 months agoDefine ISO 639-3 "gbm" (Garhwali)
Mike FABIAN [Wed, 17 Jan 2024 15:46:12 +0000 (16:46 +0100)]
Define ISO 639-3 "gbm" (Garhwali)

Related: BZ # 19479

References:
https://iso639-3.sil.org/code/gbm
https://en.wikipedia.org/wiki/Garhwali_language

7 months agoUpdate syscall lists for Linux 6.7
Joseph Myers [Wed, 17 Jan 2024 15:38:54 +0000 (15:38 +0000)]
Update syscall lists for Linux 6.7

Linux 6.7 adds the futex_requeue, futex_wait and futex_wake syscalls,
and enables map_shadow_stack for architectures previously missing it.
Update syscall-names.list and regenerate the arch-syscall.h headers
with build-many-glibcs.py update-syscalls.

Tested with build-many-glibcs.py.

7 months agoUse Linux 6.7 in build-many-glibcs.py
Joseph Myers [Wed, 17 Jan 2024 11:35:35 +0000 (11:35 +0000)]
Use Linux 6.7 in build-many-glibcs.py

This patch makes build-many-glibcs.py use Linux 6.7.

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

7 months agostdlib: Remove unused is_aligned function from qsort.c
Adhemerval Zanella [Wed, 17 Jan 2024 11:08:01 +0000 (08:08 -0300)]
stdlib: Remove unused is_aligned function from qsort.c

Checked on x86_64-linux-gnu.

7 months agoNEWS: Mention PLT rewrite on x86-64
H.J. Lu [Mon, 15 Jan 2024 17:39:03 +0000 (09:39 -0800)]
NEWS: Mention PLT rewrite on x86-64

Mention PLT rewrite on x86-64 for glibc 2.39.

7 months agostdlib: Verify heapsort for two-element cases
Kuan-Wei Chiu [Tue, 16 Jan 2024 02:16:57 +0000 (10:16 +0800)]
stdlib: Verify heapsort for two-element cases

Adjust the testing approach to start from scenarios with only 2
elements, as insertion sort no longer handles such cases.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agostdlib: Fix heapsort for cases with exactly two elements
Kuan-Wei Chiu [Tue, 16 Jan 2024 02:16:56 +0000 (10:16 +0800)]
stdlib: Fix heapsort for cases with exactly two elements

When malloc fails to allocate a buffer and falls back to heapsort, the
current heapsort implementation does not perform sorting when there are
exactly two elements. Heapsort is now skipped only when there is
exactly one element.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agolocaledata: anp_IN: Fix abbreviated month names
Mike FABIAN [Mon, 15 Jan 2024 22:12:48 +0000 (23:12 +0100)]
localedata: anp_IN: Fix abbreviated month names

Resolves: BZ # 31239

The correct abbreviated month names were apparently given in the comment above `abmon`.
But the value of `abmon` was apparently just copied from the value of `mon` and this
mistake was hard to see because code point notation <Uxxxx> was used. After converting
to UTF-8 it was obvious that there was apparently a copy and paste mistake.

7 months agostdlib: Reinstate stable mergesort implementation on qsort
Adhemerval Zanella [Mon, 15 Jan 2024 14:07:21 +0000 (11:07 -0300)]
stdlib: Reinstate stable mergesort implementation on qsort

The mergesort removal from qsort implementation (commit 03bf8357e8)
had the side-effect of making sorting nonstable.  Although neither
POSIX nor C standard specify that qsort should be stable, it seems
that it has become an instance of Hyrum's law where multiple programs
expect it.

Also, the resulting introsort implementation is not faster than
the previous mergesort (which makes the change even less appealing).

This patch restores the previous mergesort implementation, with the
exception of machinery that checks the resulting allocation against
the _SC_PHYS_PAGES (it only adds complexity and the heuristic not
always make sense depending on the system configuration and load).
The alloca usage was replaced with a fixed-size buffer.

For the fallback mechanism, the implementation uses heapsort.  It is
simpler than quicksort, and it does not suffer from adversarial
inputs.  With memory overcommit, it should be rarely triggered.

The drawback is mergesort requires O(n) extra space, and since it is
allocated with malloc the function is AS-signal-unsafe.  It should be
feasible to change it to use mmap, although I am not sure how urgent
it is.  The heapsort is also nonstable, so programs that require a
stable sort would still be subject to this latent issue.

The tst-qsort5 is removed since it will not create quicksort adversarial
inputs with the current qsort_r implementation.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agox86-64: Check if mprotect works before rewriting PLT
H.J. Lu [Fri, 12 Jan 2024 18:19:41 +0000 (10:19 -0800)]
x86-64: Check if mprotect works before rewriting PLT

Systemd execution environment configuration may prohibit changing a memory
mapping to become executable:

MemoryDenyWriteExecute=
Takes a boolean argument. If set, attempts to create memory mappings
that are writable and executable at the same time, or to change existing
memory mappings to become executable, or mapping shared memory segments
as executable, are prohibited.

When it is set, systemd service stops working if PLT rewrite is enabled.
Check if mprotect works before rewriting PLT.  This fixes BZ #31230.
This also works with SELinux when deny_execmem is on.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agoaarch64: Add NEWS entry about libmvec for 2.39
Szabolcs Nagy [Wed, 3 Jan 2024 09:06:38 +0000 (09:06 +0000)]
aarch64: Add NEWS entry about libmvec for 2.39

Auto-vectorizing scalar calls is now supported.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agolocaledata/unicode-gen/utf8_gen.py: fix Hangul syllable name
Mike FABIAN [Sun, 14 Jan 2024 10:42:28 +0000 (11:42 +0100)]
localedata/unicode-gen/utf8_gen.py: fix Hangul syllable name

Resolves: BZ # 29506

7 months agox86_64: Optimize ffsll function code size.
Sunil K Pandey [Wed, 26 Jul 2023 15:34:05 +0000 (08:34 -0700)]
x86_64: Optimize ffsll function code size.

Ffsll function randomly regress by ~20%, depending on how code gets
aligned in memory.  Ffsll function code size is 17 bytes.  Since default
function alignment is 16 bytes, it can load on 16, 32, 48 or 64 bytes
aligned memory.  When ffsll function load at 16, 32 or 64 bytes aligned
memory, entire code fits in single 64 bytes cache line.  When ffsll
function load at 48 bytes aligned memory, it splits in two cache line,
hence random regression.

Ffsll function size reduction from 17 bytes to 12 bytes ensures that it
will always fit in single 64 bytes cache line.

This patch fixes ffsll function random performance regression.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agolocaledata: Remove redundant comments
Mike FABIAN [Fri, 12 Jan 2024 16:04:24 +0000 (17:04 +0100)]
localedata: Remove redundant comments

7 months agoRISC-V: Enable static-pie.
Yanzhang Wang [Tue, 2 Jan 2024 10:54:15 +0000 (18:54 +0800)]
RISC-V: Enable static-pie.

This patch referents the commit 374cef3 to add static-pie support. And
because the dummy link map is used when relocating ourselves, so need
not to set __global_pointer$ at this time.

It will also check whether toolchain supports to build static-pie.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agolinux: Fix fstat64 on alpha and sparc64
Adhemerval Zanella [Tue, 2 Jan 2024 14:31:52 +0000 (11:31 -0300)]
linux: Fix fstat64 on alpha and sparc64

The 551101e8240b7514fc646d1722f8b79c90362b8f change is incorrect for
alpha and sparc, since __NR_stat is defined by both kABI.  Use
__NR_newfstat to check whether to fallback to __NR_fstat64 (similar
to what fstatat64 does).

Checked on sparc64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agomath: remove exp10 wrappers
Wilco Dijkstra [Tue, 9 Jan 2024 15:32:08 +0000 (15:32 +0000)]
math: remove exp10 wrappers

Remove the error handling wrapper from exp10.  This is very similar to
the changes done to exp and exp2, except that we also need to handle
pow10 and pow10l.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoBenchtests: Increase benchmark iterations
Wilco Dijkstra [Tue, 2 Jan 2024 17:08:02 +0000 (17:08 +0000)]
Benchtests: Increase benchmark iterations

Increase benchmark iterations for math and vector math functions to improve
timing accuracy.  Vector math benchmarks now take 1-3 seconds on a modern CPU.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agodebug/getwd_chk.c: warning should be emitted for the __getwd_chk symbol.
Frederic Cambus [Tue, 5 Dec 2023 11:23:07 +0000 (12:23 +0100)]
debug/getwd_chk.c: warning should be emitted for the __getwd_chk symbol.

Otherwise the warning message for the getwd symbol ends up being duplicated.

Signed-off-by: Frederic Cambus <fred@statdns.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoMake __getrandom_nocancel set errno and add a _nostatus version
Xi Ruoyao [Thu, 4 Jan 2024 13:41:20 +0000 (21:41 +0800)]
Make __getrandom_nocancel set errno and add a _nostatus version

The __getrandom_nocancel function returns errors as negative values
instead of errno.  This is inconsistent with other _nocancel functions
and it breaks "TEMP_FAILURE_RETRY (__getrandom_nocancel (p, n, 0))" in
__arc4random_buf.  Use INLINE_SYSCALL_CALL instead of
INTERNAL_SYSCALL_CALL to fix this issue.

But __getrandom_nocancel has been avoiding from touching errno for a
reason, see BZ 29624.  So add a __getrandom_nocancel_nostatus function
and use it in tcache_key_initialize.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agox86-64/cet: Make CET feature check specific to Linux/x86
H.J. Lu [Wed, 10 Jan 2024 16:48:47 +0000 (08:48 -0800)]
x86-64/cet: Make CET feature check specific to Linux/x86

CET feature bits in TCB, which are Linux specific, are used to check if
CET features are active.  Move CET feature check to Linux/x86 directory.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
7 months agoIncorporate translations (zh_CN)
Andreas K. Hüttel [Thu, 11 Jan 2024 18:46:43 +0000 (19:46 +0100)]
Incorporate translations (zh_CN)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agoDefine ISO 639-3 "glk" (Gilaki)
Mike FABIAN [Thu, 11 Jan 2024 15:34:49 +0000 (16:34 +0100)]
Define ISO 639-3 "glk" (Gilaki)

Resolves: BZ # 27163

References:
https://iso639-3.sil.org/code/glk
https://en.wikipedia.org/wiki/Gilaki_language

7 months agoresolv: Fix endless loop in __res_context_query
Stefan Liebler [Thu, 11 Jan 2024 13:01:18 +0000 (14:01 +0100)]
resolv: Fix endless loop in __res_context_query

Starting with commit 40c0add7d48739f5d89ebba255c1df26629a76e2
"resolve: Remove __res_context_query alloca usage"
there is an endless loop in __res_context_query if
__res_context_mkquery fails e.g. if type is invalid.  Then the
scratch buffer is resized to MAXPACKET size and it is retried again.

Before the mentioned commit, it was retried only once and with the
mentioned commit, there is no check and it retries in an endless loop.

This is observable with xtest resolv/tst-resolv-qtypes which times out
after 300s.

This patch retries mkquery only once as before the mentioned commit.
Furthermore, scratch_buffer_set_array_size is now only called with
nelem=2 if type is T_QUERY_A_AND_AAAA (also see mentioned commit).
The test tst-resolv-qtypes is also adjusted to verify that <func>
is really returning with -1 in case of an invalid type.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agolocaledata: revert all the remaining locale sources to UTF-8
Mike FABIAN [Thu, 11 Jan 2024 13:17:55 +0000 (14:17 +0100)]
localedata: revert all the remaining locale sources to UTF-8

7 months agolocaledata: am_ET ber_DZ en_GB en_PH en_US fil_PH kab_DZ om_ET om_KE ti_ET tl_PH...
Mike FABIAN [Thu, 11 Jan 2024 08:14:45 +0000 (09:14 +0100)]
localedata: am_ET ber_DZ en_GB en_PH en_US fil_PH kab_DZ om_ET om_KE ti_ET tl_PH: convert to UTF-8

7 months agolocaledata: resolve cyclic dependencies
Mike FABIAN [Wed, 10 Jan 2024 17:00:26 +0000 (18:00 +0100)]
localedata: resolve cyclic dependencies

Resolves: BZ # 24006

7 months agolocaledata: kv_RU: convert to UTF-8
Mike FABIAN [Thu, 11 Jan 2024 08:33:08 +0000 (09:33 +0100)]
localedata: kv_RU: convert to UTF-8

7 months agolocaledata: add new locale kv_RU
Mike FABIAN [Tue, 9 Jan 2024 13:29:20 +0000 (14:29 +0100)]
localedata: add new locale kv_RU

Resolves: BZ # 30605

7 months agoelf: Fix tst-nodeps2 test failure.
Carlos O'Donell [Wed, 10 Jan 2024 15:46:03 +0000 (10:46 -0500)]
elf: Fix tst-nodeps2 test failure.

After 78ca44da0160a0b442f0ca1f253e3360f044b2ec
("elf: Relocate libc.so early during startup and dlmopen (bug 31083)")
we start seeing tst-nodeps2 failures when building the testsuite with
--enable-hard-coded-path-in-tests.

When building the testsuite with --enable-hard-coded-path-in-tests
the tst-nodeps2-mod.so is not built with the required DT_RUNPATH
values and the test escapes the test framework and loads the system
libraries and aborts. The fix is to use the existing
$(link-test-modules-rpath-link) variable to set DT_RUNPATH correctly.

No regressions on x86_64.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agolocaledata: Sort Makefile variables.
Carlos O'Donell [Tue, 9 Jan 2024 13:29:45 +0000 (08:29 -0500)]
localedata: Sort Makefile variables.

Sort Makefile variables using scrips/sort-makefile-lines.py.

No regressions on x86_64.

7 months agolocale: Sort Makefile variables.
Carlos O'Donell [Fri, 1 Dec 2023 13:55:59 +0000 (08:55 -0500)]
locale: Sort Makefile variables.

Sort Makefile variables using scrips/sort-makefile-lines.py.

No regressions on x86_64.

7 months agoi386: Remove CET support bits
H.J. Lu [Tue, 9 Jan 2024 20:23:27 +0000 (12:23 -0800)]
i386: Remove CET support bits

1. Remove _dl_runtime_resolve_shstk and _dl_runtime_profile_shstk.
2. Move CET offsets from x86 cpu-features-offsets.sym to x86-64
features-offsets.sym.
3. Rename x86 cet-control.h to x86-64 feature-control.h since it is only
for x86-64 and also used for PLT rewrite.
4. Add x86-64 ldsodefs.h to include feature-control.h.
5. Change TUNABLE_CALLBACK (set_plt_rewrite) to x86-64 only.
6. Move x86 dl-procruntime.c to x86-64.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agox86-64/cet: Move check-cet.awk to x86_64
H.J. Lu [Tue, 9 Jan 2024 20:23:26 +0000 (12:23 -0800)]
x86-64/cet: Move check-cet.awk to x86_64

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agox86-64/cet: Move dl-cet.[ch] to x86_64 directories
H.J. Lu [Tue, 9 Jan 2024 20:23:25 +0000 (12:23 -0800)]
x86-64/cet: Move dl-cet.[ch] to x86_64 directories

Since CET is only enabled for x86-64, move dl-cet.[ch] to x86_64
directories.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agox86: Move x86-64 shadow stack startup codes
H.J. Lu [Tue, 9 Jan 2024 20:23:24 +0000 (12:23 -0800)]
x86: Move x86-64 shadow stack startup codes

Move sysdeps/x86/libc-start.h to sysdeps/x86_64/libc-start.h and use
sysdeps/generic/libc-start.h for i386.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agoFix deprecated utcnow() usage in build-many-glibcs.py
Joseph Myers [Wed, 10 Jan 2024 13:02:16 +0000 (13:02 +0000)]
Fix deprecated utcnow() usage in build-many-glibcs.py

Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:566: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  build_time = datetime.datetime.utcnow()

Replace with datetime.datetime.now(datetime.timezone.utc) (the
datetime.UTC constant is new in 3.11, so not suitable for use in this
script at present).

7 months agoFix invalid escape sequence in build-many-glibcs.py
Joseph Myers [Wed, 10 Jan 2024 13:01:39 +0000 (13:01 +0000)]
Fix invalid escape sequence in build-many-glibcs.py

Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
  m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)

Use a raw string instead to avoid that warning.  (Note: I haven't
checked whether any other Python scripts included with glibc might
have issues with newer Python versions.)

7 months agomath: Fix test-fenv.c feupdateenv tests
Adhemerval Zanella [Tue, 9 Jan 2024 19:40:33 +0000 (16:40 -0300)]
math: Fix test-fenv.c feupdateenv tests

The feupdateenv tests added by 802aef27b2 do not restore the floating
point mask, which might keep some floating point exception enabled and
thus make the feupdateenv_single_test raise an unexpected signal.

Checked on x86_64-linux-gnu and aarch64-linux-gnu (on Apple M1 trapping
is supported).
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
7 months agoRemove installed header rule on $(..)include/%.h
H.J. Lu [Tue, 9 Jan 2024 18:25:20 +0000 (10:25 -0800)]
Remove installed header rule on $(..)include/%.h

On x86-64 machine with

[hjl@gnu-cfl-3 x86-glibc]$ ls -l /usr/include/asm/prctl.h sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 hjl  hjl   825 Jan  9 09:41 sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 root root 1170 Nov 27 16:00 /usr/include/asm/prctl.h
[hjl@gnu-cfl-3 x86-glibc]$

glibc configured with --enable-cet build failed:

make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
../Makerules:327: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.stmp
:
../Makeconfig:1216: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.stmp
:
../Makerules:1126: update target '/usr/include/asm/prctl.h' due to:
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
force-install
/usr/bin/install -c -m 644
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
/usr/include/asm/prctl.h
/usr/bin/install: cannot remove '/usr/include/asm/prctl.h': Permission denied
make[2]: *** [../Makerules:1126: /usr/include/asm/prctl.h] Error 1
make[2]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2
make[1]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc'
make: *** [Makefile:9: all] Error 2

This is triggered by the rule in Makerules:

$(inst_includedir)/%.h: $(..)include/%.h $(+force)
  $(do-install)

Since no files under include/ should be installed, remove it from
Makerules.

Tested it on x86-64.  There are no differences in the installed header
files.

7 months agoi386: Fail if configured with --enable-cet
Adhemerval Zanella [Fri, 5 Jan 2024 13:41:03 +0000 (10:41 -0300)]
i386: Fail if configured with --enable-cet

Since it is only supported for x86_64.

Checked on i686-linux-gnu.

7 months agoi386: Remove CET support
Adhemerval Zanella [Fri, 5 Jan 2024 13:36:40 +0000 (10:36 -0300)]
i386: Remove CET support

CET is only support for x86_64, this patch reverts:

  - faaee1f07ed x86: Support shadow stack pointer in setjmp/longjmp.
  - be9ccd27c09 i386: Add _CET_ENDBR to indirect jump targets in
    add_n.S/sub_n.S
  - c02695d7764 x86/CET: Update vfork to prevent child return
  - 5d844e1b725 i386: Enable CET support in ucontext functions
  - 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
  - 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
  - f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
  - 825b58f3fb i386-mcount.S: Add _CET_ENDBR to _mcount and __fentry__
  - 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
  - 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
  - 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
  - 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
  - 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
  - 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
  - 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
  - f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
  - 4031d7484a i386/sub_n.S: Add a missing _CET_ENDBR to indirect jump
  - target
  -
Checked on i686-linux-gnu.

7 months agox86: Move CET infrastructure to x86_64
Adhemerval Zanella [Fri, 5 Jan 2024 12:32:37 +0000 (09:32 -0300)]
x86: Move CET infrastructure to x86_64

The CET is only supported for x86_64 and there is no plan to add
kernel support for i386.  Move the Makefile rules and files from the
generic x86 folder to x86_64 one.

Checked on x86_64-linux-gnu and i686-linux-gnu.

7 months agolocaledata: su_ID: make lang_name agree with CLDR
Mike FABIAN [Tue, 9 Jan 2024 13:08:08 +0000 (14:08 +0100)]
localedata: su_ID: make lang_name agree with CLDR

7 months agolocaledata: add new locale su_ID
Mike FABIAN [Tue, 9 Jan 2024 12:57:59 +0000 (13:57 +0100)]
localedata: add new locale su_ID

Resolves: BZ # 27312

7 months agolocaledata: add new locale zgh_MA
Mike FABIAN [Tue, 9 Jan 2024 12:43:38 +0000 (13:43 +0100)]
localedata: add new locale zgh_MA

Resolves: BZ # 12908

https://iso639-3.sil.org/code/zgh

7 months agoINSTALL: regenerate
Mark Wielaard [Tue, 9 Jan 2024 00:15:15 +0000 (01:15 +0100)]
INSTALL: regenerate

7 months agolocaledata: add tok/UTF-8 to SUPPORTED
Mike FABIAN [Tue, 9 Jan 2024 09:54:06 +0000 (10:54 +0100)]
localedata: add tok/UTF-8 to SUPPORTED

7 months agolocaledata: tok: add yY and nN to yesexpr and noexpr
Mike FABIAN [Tue, 9 Jan 2024 09:49:07 +0000 (10:49 +0100)]
localedata: tok: add yY and nN to yesexpr and noexpr

See: https://sourceware.org/bugzilla/show_bug.cgi?id=31221#c2

7 months agolocaledata: tok: convert to UTF-8
Mike FABIAN [Tue, 9 Jan 2024 09:46:56 +0000 (10:46 +0100)]
localedata: tok: convert to UTF-8

7 months agolocaledata: add data for tok (Toki Pona)
Janet Blackquill [Sun, 7 Jan 2024 02:38:49 +0000 (21:38 -0500)]
localedata: add data for tok (Toki Pona)

Resolves: BZ # 31221

glibc can recognise its code, but does not have its data.
This patch remedies that.

Signed-off-by: Janet Blackquill <uhhadd@gmail.com>
7 months agoRemove ia64-linux-gnu
Adhemerval Zanella [Mon, 8 Jan 2024 13:21:17 +0000 (10:21 -0300)]
Remove ia64-linux-gnu

Linux 6.7 removed ia64 from the official tree [1], following the general
principle that a glibc port needs upstream support for the architecture
in all the components it depends on (binutils, GCC, and the Linux
kernel).

Apart from the removal of sysdeps/ia64 and sysdeps/unix/sysv/linux/ia64,
there are updates to various comments referencing ia64 for which removal
of those references seemed appropriate. The configuration is removed
from README and build-many-glibcs.py.

The CONTRIBUTED-BY, elf/elf.h, manual/contrib.texi (the porting
mention), *.po files, config.guess, and longlong.h are not changed.

For Linux it allows cleanup some clone2 support on multiple files.

The following bug can be closed as WONTFIX: BZ 22634 [2], BZ 14250 [3],
BZ 21634 [4], BZ 10163 [5], BZ 16401 [6], and BZ 11585 [7].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43ff221426d33db909f7159fdf620c3b052e2d1c
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=22634
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=14250
[4] https://sourceware.org/bugzilla/show_bug.cgi?id=21634
[5] https://sourceware.org/bugzilla/show_bug.cgi?id=10163
[6] https://sourceware.org/bugzilla/show_bug.cgi?id=16401
[7] https://sourceware.org/bugzilla/show_bug.cgi?id=11585
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agolocaledata: dz_BT, bo_CN: convert to UTF-8
Mike FABIAN [Mon, 8 Jan 2024 16:02:09 +0000 (17:02 +0100)]
localedata: dz_BT, bo_CN: convert to UTF-8

7 months agolocaledata: dz_BT, bo_CN: Fix spelling of "phur bu" in both Tibetan and Dzongkha
Valery Ushakov [Mon, 8 Jan 2024 15:44:28 +0000 (16:44 +0100)]
localedata: dz_BT, bo_CN: Fix spelling of "phur bu" in both Tibetan and Dzongkha

Resolves: BZ # 31086

7 months agolocaledata: bo_CN: Fix spelling errors in Tibetan data
Valery Ushakov [Mon, 8 Jan 2024 15:39:31 +0000 (16:39 +0100)]
localedata: bo_CN: Fix spelling errors in Tibetan data

Resolves: BZ # 31086

7 months agolocaledata: bo_CN: Fix incomplete edit in Tibetan yesexpr
Valery Ushakov [Mon, 8 Jan 2024 15:08:07 +0000 (16:08 +0100)]
localedata: bo_CN: Fix incomplete edit in Tibetan yesexpr

Resolves: BZ # 31086

7 months agolocaledata: dz_BT: Fix spelling errors in Dzongha data
Valery Ushakov [Mon, 8 Jan 2024 15:04:59 +0000 (16:04 +0100)]
localedata: dz_BT: Fix spelling errors in Dzongha data

Resolves: BZ # 31086

7 months agolocaledata: unicode-gen: Remove redundant \s* from regexp, fix comments
Mike FABIAN [Mon, 8 Jan 2024 09:05:13 +0000 (10:05 +0100)]
localedata: unicode-gen: Remove redundant \s* from regexp, fix comments

7 months agolocaledata: convert the remaining *_RU locales to UTF-8
Mike FABIAN [Fri, 5 Jan 2024 11:15:50 +0000 (12:15 +0100)]
localedata: convert the remaining *_RU locales to UTF-8

7 months agoIncorporate translations
Andreas K. Hüttel [Sun, 7 Jan 2024 10:18:18 +0000 (11:18 +0100)]
Incorporate translations

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agox32: Handle displacement overflow in PLT rewrite [BZ #31218]
H.J. Lu [Sat, 6 Jan 2024 22:03:37 +0000 (14:03 -0800)]
x32: Handle displacement overflow in PLT rewrite [BZ #31218]

PLT rewrite calculated displacement with

ElfW(Addr) disp = value - branch_start - JMP32_INSN_SIZE;

On x32, displacement from 0xf7fbe060 to 0x401030 was calculated as

unsigned int disp = 0x401030 - 0xf7fbe060 - 5;

with disp == 0x8442fcb and caused displacement overflow. The PLT entry
was changed to:

0xf7fbe060 <+0>: e9 cb 2f 44 08      jmp    0x401030
0xf7fbe065 <+5>: cc                  int3
0xf7fbe066 <+6>: cc                  int3
0xf7fbe067 <+7>: cc                  int3
0xf7fbe068 <+8>: cc                  int3
0xf7fbe069 <+9>: cc                  int3
0xf7fbe06a <+10>: cc                  int3
0xf7fbe06b <+11>: cc                  int3
0xf7fbe06c <+12>: cc                  int3
0xf7fbe06d <+13>: cc                  int3
0xf7fbe06e <+14>: cc                  int3
0xf7fbe06f <+15>: cc                  int3

x32 has 32-bit address range, but it doesn't wrap address around at 4GB,
JMP target was changed to 0x100401030 (0xf7fbe060LL + 0x8442fcbLL + 5),
which is above 4GB.

Always use uint64_t to calculate displacement.  This fixes BZ #31218.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
7 months agox86: Fixup some nits in longjmp asm implementation
Noah Goldstein [Fri, 5 Jan 2024 22:00:30 +0000 (14:00 -0800)]
x86: Fixup some nits in longjmp asm implementation

Replace a stray `nop` with a `.p2align` directive.

7 months agostdlib: Fix stdbit.h with -Wconversion for clang
Adhemerval Zanella [Thu, 4 Jan 2024 17:59:28 +0000 (14:59 -0300)]
stdlib: Fix stdbit.h with -Wconversion for clang

With clang 14 and also with main the tst-stdbit-Wconversion
issues the warnings:

  ../stdlib/stdbit.h:701:40: error: implicit conversion loses integer
  precision: 'int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    return __x == 0 ? 0 : ((uint16_t) 1) << (__bw16_inline (__x) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:707:39: error: implicit conversion loses integer
  precision: 'int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    return __x == 0 ? 0 : ((uint8_t) 1) << (__bw8_inline (__x) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:751:40: error: implicit conversion loses integer
  precision: 'int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:757:39: error: implicit conversion loses integer
  precision: 'int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  tst-stdbit-Wconversion.c:45:31: error: implicit conversion loses integer
  precision: 'unsigned short' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (us);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:164:30: note: expanded from macro
  'stdc_trailing_zeros'
     : stdc_trailing_zeros_uc (x))
       ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:191:52: note: expanded from macro
  'stdc_trailing_zeros_uc'
  # define stdc_trailing_zeros_uc(x) (__ctz8_inline (x))
                                      ~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:46:31: error: implicit conversion loses integer
  precision: 'unsigned int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ui);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:163:48: note: expanded from macro
  'stdc_trailing_zeros'
     : sizeof (x) == 2 ? stdc_trailing_zeros_us (x)       \
                         ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:192:53: note: expanded from macro
  'stdc_trailing_zeros_us'
  # define stdc_trailing_zeros_us(x) (__ctz16_inline (x))
                                      ~~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:46:31: error: implicit conversion loses integer
  precision: 'unsigned int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ui);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:164:30: note: expanded from macro
  'stdc_trailing_zeros'
     : stdc_trailing_zeros_uc (x))
       ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:191:52: note: expanded from macro
  'stdc_trailing_zeros_uc'
  # define stdc_trailing_zeros_uc(x) (__ctz8_inline (x))
                                      ~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:47:31: error: implicit conversion loses integer
  precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ul);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:163:48: note: expanded from macro
  'stdc_trailing_zeros'
     : sizeof (x) == 2 ? stdc_trailing_zeros_us (x)       \
                         ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:192:53: note: expanded from macro
  'stdc_trailing_zeros_us'
  # define stdc_trailing_zeros_us(x) (__ctz16_inline (x))
                                      ~~~~~~~~~~~~~~  ^
  [...]

It seems to boiler down to __builtin_clz not having a variant for 8 or
16 bits.  Fix it by explicit casting to the expected types.  Although
not strickly required for older gcc, using the same __pacify macro
simpify the required code.

Checked on x86_64-linux-gnu and i686-linux-gnu.

7 months agostdlib: Fix stdbit.h with -Wconversion for older gcc
Adhemerval Zanella [Thu, 4 Jan 2024 17:44:42 +0000 (14:44 -0300)]
stdlib: Fix stdbit.h with -Wconversion for older gcc

With gcc 6.5.0, 7.5.0, 8.5.0, and 9.5.0 the tst-stdbit-Wconversion
issues the warnings:

../stdlib/stdbit.h: In function ‘__clo16_inline’:
../stdlib/stdbit.h:128:26: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __clz16_inline (~__x);
                          ^
../stdlib/stdbit.h: In function ‘__clo8_inline’:
../stdlib/stdbit.h:134:25: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __clz8_inline (~__x);
                         ^
../stdlib/stdbit.h: In function ‘__cto16_inline’:
../stdlib/stdbit.h:232:26: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __ctz16_inline (~__x);
                          ^
../stdlib/stdbit.h: In function ‘__cto8_inline’:
../stdlib/stdbit.h:238:25: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __ctz8_inline (~__x);
                         ^
../stdlib/stdbit.h: In function ‘__bf16_inline’:
../stdlib/stdbit.h:701:23: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x == 0 ? 0 : ((uint16_t) 1) << (__bw16_inline (__x) - 1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bf8_inline’:
../stdlib/stdbit.h:707:23: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x == 0 ? 0 : ((uint8_t) 1) << (__bw8_inline (__x) - 1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bc16_inline’:
../stdlib/stdbit.h:751:59: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) -
1);
                                                           ^~~
../stdlib/stdbit.h:751:23: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) -
1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bc8_inline’:
../stdlib/stdbit.h:757:57: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);
                                                         ^~~
../stdlib/stdbit.h:757:23: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);

It seems to boiler down to __builtin_clz not having a variant for 8 or
16 bits.  Fix it by explicit casting to the expected types.

Checked on x86_64-linux-gnu and i686-linux-gnu with gcc 9.5.0.

7 months agoelf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT
H.J. Lu [Fri, 5 Jan 2024 04:19:39 +0000 (20:19 -0800)]
elf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT

Add ELF_DYNAMIC_AFTER_RELOC to allow target specific processing after
relocation.

For x86-64, add

 #define DT_X86_64_PLT     (DT_LOPROC + 0)
 #define DT_X86_64_PLTSZ   (DT_LOPROC + 1)
 #define DT_X86_64_PLTENT  (DT_LOPROC + 3)

1. DT_X86_64_PLT: The address of the procedure linkage table.
2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage
table.
3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table
entry.

With the r_addend field of the R_X86_64_JUMP_SLOT relocation set to the
memory offset of the indirect branch instruction.

Define ELF_DYNAMIC_AFTER_RELOC for x86-64 to rewrite the PLT section
with direct branch after relocation when the lazy binding is disabled.

PLT rewrite is disabled by default since SELinux may disallow modifying
code pages and ld.so can't detect it in all cases.  Use

$ export GLIBC_TUNABLES=glibc.cpu.plt_rewrite=1

to enable PLT rewrite with 32-bit direct jump at run-time or

$ export GLIBC_TUNABLES=glibc.cpu.plt_rewrite=2

to enable PLT rewrite with 32-bit direct jump and on APX processors with
64-bit absolute jump at run-time.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
7 months agoaarch64: Make cpu-features definitions not Linux-specific
Sergey Bugaev [Wed, 3 Jan 2024 17:14:45 +0000 (20:14 +0300)]
aarch64: Make cpu-features definitions not Linux-specific

These describe generic AArch64 CPU features, and are not tied to a
kernel-specific way of determining them. We can share them between
the Linux and Hurd AArch64 ports.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-13-bugaevc@gmail.com>

7 months agohurd: Initializy _dl_pagesize early in static builds
Sergey Bugaev [Wed, 3 Jan 2024 17:14:44 +0000 (20:14 +0300)]
hurd: Initializy _dl_pagesize early in static builds

We fetch __vm_page_size as the very first RPC that we do, inside
__mach_init (). Propagate that to _dl_pagesize ASAP after that,
before any other initialization.

In dynamic builds, this is already done immediately after
__mach_init (), inside _dl_sysdep_start ().

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-12-bugaevc@gmail.com>

7 months agohurd: Only init early static TLS if it's used to store stack or pointer guards
Sergey Bugaev [Wed, 3 Jan 2024 17:14:43 +0000 (20:14 +0300)]
hurd: Only init early static TLS if it's used to store stack or pointer guards

This is the case on both x86 architectures, but not on AArch64.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-11-bugaevc@gmail.com>

7 months agohurd: Make init-first.c no longer x86-specific
Sergey Bugaev [Wed, 3 Jan 2024 17:14:42 +0000 (20:14 +0300)]
hurd: Make init-first.c no longer x86-specific

This will make it usable in other ports.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-10-bugaevc@gmail.com>

7 months agohurd: Drop x86-specific assembly from init-first.c
Sergey Bugaev [Wed, 3 Jan 2024 17:14:41 +0000 (20:14 +0300)]
hurd: Drop x86-specific assembly from init-first.c

We already have the RETURN_TO macro for this exact use case, and it's already
used in the non-static code path. Use it here too.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-9-bugaevc@gmail.com>

7 months agohurd: Pass the data pointer to _hurd_stack_setup explicitly
Sergey Bugaev [Wed, 3 Jan 2024 17:14:40 +0000 (20:14 +0300)]
hurd: Pass the data pointer to _hurd_stack_setup explicitly

Instead of relying on the stack frame layout to figure out where the stack
pointer was prior to the _hurd_stack_setup () call, just pass the pointer
as an argument explicitly. This is less brittle and much more portable.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-8-bugaevc@gmail.com>

7 months agox86-64/cet: Check the restore token in longjmp
H.J. Lu [Tue, 2 Jan 2024 15:03:29 +0000 (07:03 -0800)]
x86-64/cet: Check the restore token in longjmp

setcontext and swapcontext put a restore token on the old shadow stack
which is used to restore the target shadow stack when switching user
contexts.  When longjmp from a user context, the target shadow stack
can be different from the current shadow stack and INCSSP can't be
used to restore the shadow stack pointer to the target shadow stack.

Update longjmp to search for a restore token.  If found, use the token
to restore the shadow stack pointer before using INCSSP to pop the
shadow stack.  Stop the token search and use INCSSP if the shadow stack
entry value is the same as the current shadow stack pointer.

It is a user error if there is a shadow stack switch without leaving a
restore token on the old shadow stack.

The only difference between __longjmp.S and __longjmp_chk.S is that
__longjmp_chk.S has a check for invalid longjmp usages.  Merge
__longjmp.S and __longjmp_chk.S by adding the CHECK_INVALID_LONGJMP
macro.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
7 months agolocaledata: ru_RU, ru_UA: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:32:44 +0000 (16:32 +0100)]
localedata: ru_RU, ru_UA: convert to UTF-8

7 months agolocaledata: es_??: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:02:24 +0000 (16:02 +0100)]
localedata: es_??: convert to UTF-8

7 months agolocaledata: miq_NI: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:00:33 +0000 (16:00 +0100)]
localedata: miq_NI: convert to UTF-8

7 months agoi386: Ignore --enable-cet
H.J. Lu [Wed, 3 Jan 2024 20:09:23 +0000 (12:09 -0800)]
i386: Ignore --enable-cet

Since shadow stack is only supported for x86-64, ignore --enable-cet for
i386.  Always setting $(enable-cet) for i386 to "no" to support

ifneq ($(enable-cet),no)

in x86 Makefiles.  We can't use

ifeq ($(enable-cet),yes)

since $(enable-cet) can be "yes", "no" or "permissive".
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 months agomach: Drop SNARF_ARGS macro
Sergey Bugaev [Wed, 3 Jan 2024 17:14:39 +0000 (20:14 +0300)]
mach: Drop SNARF_ARGS macro

We're obtaining arguments from the stack differently, see init-first.c.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>