Auto-sync with upstream branch master

Upstream commit: cc74583f23657515b1d09d0765032422af71de52

- Update glibc-nolink-libc.patch following upstream development.
- Update glibc-python3.patch to resolve copyright year conflict.

- elf: Remove the remaining uses of GET_ADDR_OFFSET
- elf: Use TLS_DTV_OFFSET in __tls_get_addr
- s390: Define TLS_DTV_OFFSET instead of GET_ADDR_OFFSET
- elf: Introduce generic <dl-tls.h>
- Update copyright dates not handled by scripts/update-copyrights
- Update copyright in generated files by running "make"
- Update copyright dates with scripts/update-copyrights
- mlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
- elf: Add glibc.rtld.execstack
- elf: Do not change stack permission on dlopen/dlmopen
- x86-64: Reorder dynamic linker list in ldd script (bug 32508)
- libio: asprintf should write NULL upon failure
- nptl: More useful padding in struct pthread
- elf: Remove the GET_ADDR_ARGS and related macros from the TLS code
- build-many-glibcs.py: Add --exclude option
- NEWS: Mention testing glibc build with a different set of compilers
- support: Add support_record_failure_barrier
- io: statx, fstatat: Drop nonnull attribute on the path argument
- configure: Improve configure output for C++ Compiler
- getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]
- include/sys/cdefs.h: Add __attribute_optimization_barrier__
- assert: Use __writev in assert.c [BZ #32492]
- elf: Check PDE load address with non-empty text section
- Add clang specific warning suppression macros
- Add include/libc-misc.h
- Don't redefine INFINITY nor NAN
- assert: ensure posix compliance, add tests for such
- posix: fix system when a child cannot be created [BZ #32450]
- Fix elf: Introduce is_rtld_link_map [BZ #32488]
- elf: Reorder audit events in dlcose to match _dl_fini (bug 32066)
- elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065)
- elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)
- elf: Add the endswith function to <endswith.h>
- elf: Move _dl_rtld_map, _dl_rtld_audit_state out of GL
- elf: Introduce is_rtld_link_map
- Add F_CREATED_QUERY from Linux 6.12 to bits/fcntl-linux.h
- Add HWCAP_LOONGARCH_LSPW from Linux 6.12 to bits/hwcap.h
- Add MSG_SOCK_DEVMEM from Linux 6.12 to bits/socket.h
- Linux: Accept null arguments for utimensat pathname
- x86_64: Remove unused padding from tcbhead_t
- Add NT_X86_XSAVE_LAYOUT and NT_ARM_POE from Linux 6.12 to elf.h
- Add SCHED_EXT from Linux 6.12 to bits/sched.h
- math: Use tanhf from CORE-MATH
- math: Use sinhf from CORE-MATH
- math: Use coshf from CORE-MATH
- math: Use atanhf from CORE-MATH
- math: Use atan2f from CORE-MATH
- math: Use atanf from CORE-MATH
- math: Use asinhf from CORE-MATH
- math: Use asinf from CORE-MATH
- math: Use acoshf from CORE-MATH
- math: Use acosf from CORE-MATH
- math: Fix the expected carg (inf) results
- math: Fix the expected atan2f (inf) results
- math: Fix the expected atanf (inf) results
- math: Add inf support on gen-auto-libm-tests.c
- math: Fix spurious-divbyzero flag name
- benchtests: Add tanhf benchmark
- benchtests: Add sinhf benchmark
- benchtests: Add coshf benchmark
- benchtests: Add atanhf benchmark
- benchtests: Add atan2f benchmark
- benchtests: Add atanf benchmark
- benchtests: Add asinhf benchmark
- benchtests: Add asinf benchmark
- benchtests: Add acoshf benchmark
- benchtests: Add acosf benchmark
- Update syscall lists for Linux 6.12
- ungetc: Guarantee single char pushback
- sys/platform/x86.h: Do not depend on _Bool definition in C++ mode
- ldbl-96: Set -1 to "int sign_exponent:16"
- x86: Avoid integer truncation with large cache sizes (bug 32470)
- AArch64: Improve codegen of AdvSIMD expf family
- AArch64: Improve codegen of AdvSIMD atan(2)(f)
- AArch64: Improve codegen of AdvSIMD logf function family
- manual: Document more sigaction flags
- Remove duplicated BUILD_CC in Makeconfig
- iconv: do not report error exit with transliteration [BZ #32448]
This commit is contained in:
Florian Weimer 2025-01-02 18:47:50 +01:00
parent 3aa08571dd
commit 1db3678aad
4 changed files with 130 additions and 41 deletions

View File

@ -1,4 +1,3 @@
commit 624acf596c5074ffc63ff697850cad4c8ef2e7ff
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Nov 12 20:09:33 2024 +0100
@ -12,30 +11,35 @@ Date: Tue Nov 12 20:09:33 2024 +0100
Still ld.so should not crash with a null-pointer dereference
or undefined symbol reference in these cases.
Perform the final relocation for ld.so right before relocating
libc.so (which seems more correct anyway), but only if libc.so
has been loaded. In the main relocation loop, call
_dl_relocate_object unconditionally because it already checks
if the object has been relocated. Only call __rtld_mutex_init
and __rtld_malloc_init_real if libc.so has been loaded. Otherwise,
the full implementations are not available.
In the main relocation loop, call _dl_relocate_object unconditionally
because it already checks if the object has been relocated.
If libc.so was loaded, self-relocate ld.so against it and call
__rtld_mutex_init and __rtld_malloc_init_real to activate the full
implementations. Those are available only if libc.so is there,
so skip these initialization steps if libc.so is absent. Without
libc.so, the global scope can be completely empty. This can cause
ld.so self-relocation to fail because if it uses symbol-based
relocations, which is why the second ld.so self-relocation is not
performed if libc.so is missing.
The previous concern regarding GOT updates through self-relocation
no longer applies because function pointers are updated
explicitly through __rtld_mutex_init and __rtld_malloc_init_real,
and not through relocation.
and not through relocation. However, the second ld.so self-relocation
is still delayed, in case there are other symbols being used.
Fixes commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf:
rtld_multiple_ref is always true”).
diff --git a/elf/Makefile b/elf/Makefile
index 9172d7306e705bdb..56b49f88f4866230 100644
index e8fc6bd65ffdff57..1af5032ea17c7b31 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -3265,3 +3265,20 @@ tst-tls22-mod1.so-no-z-defs = yes
tst-tls22-mod1-gnu2.so-no-z-defs = yes
tst-tls22-mod2.so-no-z-defs = yes
tst-tls22-mod2-gnu2.so-no-z-defs = yes
@@ -3321,3 +3321,20 @@ endef
$(foreach m,$(modules-semantic-interposition),\
$(eval $(call enable-semantic-interposition,$(m))))
endif
+
+# These rules link and run the special elf/tst-nolink-libc-* tests if
+# a port adds them to the tests variables. Neither test variant is
@ -54,10 +58,10 @@ index 9172d7306e705bdb..56b49f88f4866230 100644
+$(objpfx)tst-nolink-libc-2.out: $(objpfx)tst-nolink-libc-2 $(objpfx)ld.so
+ $< > $@ 2>&1; $(evaluate-test)
diff --git a/elf/rtld.c b/elf/rtld.c
index b8cc3f605f9e053c..f54b1829af20881a 100644
index 0637c53017c8c1dd..2aebd75e420881d9 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2243,15 +2243,7 @@ dl_main (const ElfW(Phdr) *phdr,
@@ -2244,25 +2244,25 @@ dl_main (const ElfW(Phdr) *phdr,
_rtld_main_check (main_map, _dl_argv[0]);
@ -74,34 +78,32 @@ index b8cc3f605f9e053c..f54b1829af20881a 100644
int consider_profiling = GLRO(dl_profile) != NULL;
@@ -2259,9 +2251,19 @@ dl_main (const ElfW(Phdr) *phdr,
/* If we are profiling we also must do lazy reloaction. */
GLRO(dl_lazy) |= consider_profiling;
+ /* If libc.so has been loaded, relocate it early, after the dynamic
+ loader itself. The initial self-relocation of ld.so should be
+ sufficient for IFUNC resolvers in libc.so. */
if (GL(dl_ns)[LM_ID_BASE].libc_map != NULL)
- _dl_relocate_object (GL(dl_ns)[LM_ID_BASE].libc_map,
- GL(dl_ns)[LM_ID_BASE].libc_map->l_scope,
- GLRO(dl_lazy) ? RTLD_LAZY : 0, consider_profiling);
+ {
+ /* If libc.so has been loaded, relocate it early, after the
+ dynamic loader itself. */
+ RTLD_TIMING_VAR (start);
+ rtld_timer_start (&start);
+
+ _dl_relocate_object_no_relro (&GL(dl_rtld_map), main_map->l_scope, 0, 0);
+ _dl_relocate_object (GL(dl_ns)[LM_ID_BASE].libc_map,
+ GL(dl_ns)[LM_ID_BASE].libc_map->l_scope,
+ GLRO(dl_lazy) ? RTLD_LAZY : 0, consider_profiling);
+
+ rtld_timer_accum (&relocate_time, start);
+ }
RTLD_TIMING_VAR (start);
rtld_timer_start (&start);
@@ -2284,9 +2286,8 @@ dl_main (const ElfW(Phdr) *phdr,
@@ -2285,9 +2285,8 @@ dl_main (const ElfW(Phdr) *phdr,
/* Also allocated with the fake malloc(). */
l->l_free_initfini = 0;
- if (l != &GL(dl_rtld_map))
- if (l != &_dl_rtld_map)
- _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
- consider_profiling);
+ _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
@ -109,7 +111,7 @@ index b8cc3f605f9e053c..f54b1829af20881a 100644
/* Add object to slot information data if necessasy. */
if (l->l_tls_blocksize != 0 && __rtld_tls_init_tp_called)
@@ -2324,27 +2325,18 @@ dl_main (const ElfW(Phdr) *phdr,
@@ -2325,27 +2324,22 @@ dl_main (const ElfW(Phdr) *phdr,
/* Set up the object lookup structures. */
_dl_find_object_init ();
@ -122,20 +124,24 @@ index b8cc3f605f9e053c..f54b1829af20881a 100644
- RTLD_TIMING_VAR (start);
- rtld_timer_start (&start);
-
- _dl_relocate_object_no_relro (&GL(dl_rtld_map), main_map->l_scope, 0, 0);
- _dl_relocate_object_no_relro (&_dl_rtld_map, main_map->l_scope, 0, 0);
-
- /* The malloc implementation has been relocated, so resolving
- its symbols (and potentially calling IFUNC resolvers) is safe
- at this point. */
- __rtld_malloc_init_real (main_map);
-
- if (GL(dl_rtld_map).l_relro_size != 0)
- _dl_protect_relro (&GL(dl_rtld_map));
+ /* If libc.so was loaded, ld.so has been fully relocated along with
+ it. Complete ld.so initialization with mutex symbols from
+ libc.so and malloc symbols from the global scope. */
+ /* If libc.so was loaded, relocate ld.so against it. Complete ld.so
+ initialization with mutex symbols from libc.so and malloc symbols
+ from the global scope. */
+ if (GL(dl_ns)[LM_ID_BASE].libc_map != NULL)
+ {
+ RTLD_TIMING_VAR (start);
+ rtld_timer_start (&start);
+ _dl_relocate_object_no_relro (&_dl_rtld_map, main_map->l_scope, 0, 0);
+ rtld_timer_accum (&relocate_time, start);
- if (_dl_rtld_map.l_relro_size != 0)
- _dl_protect_relro (&_dl_rtld_map);
+ __rtld_mutex_init ();
+ __rtld_malloc_init_real (main_map);
+ }
@ -143,8 +149,7 @@ index b8cc3f605f9e053c..f54b1829af20881a 100644
- rtld_timer_accum (&relocate_time, start);
- }
+ /* All ld.so initialization is complete. Apply RELRO. */
+ if (GL(dl_rtld_map).l_relro_size != 0)
+ _dl_protect_relro (&GL(dl_rtld_map));
+ _dl_protect_relro (&_dl_rtld_map);
/* Relocation is complete. Perform early libc initialization. This
is the initial libc, even if audit modules have been loaded with

View File

@ -9,22 +9,22 @@ python3 during a transitional phase.
Author: Carlos O'Donell <carlos@redhat.com>
diff --git a/benchtests/scripts/compare_bench.py b/benchtests/scripts/compare_bench.py
index d4370d723f313a0e..2bbb91d6ea9f6c18 100755
index 7b05d87a38160538..6ac31b6ea807da50 100755
--- a/benchtests/scripts/compare_bench.py
+++ b/benchtests/scripts/compare_bench.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (C) 2015-2024 Free Software Foundation, Inc.
# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
#
diff --git a/benchtests/scripts/import_bench.py b/benchtests/scripts/import_bench.py
index fac2945f6d36db13..ac40878934490380 100644
index 06f1259b6a5a1843..cab1b9129cc9fa68 100644
--- a/benchtests/scripts/import_bench.py
+++ b/benchtests/scripts/import_bench.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (C) 2015-2024 Free Software Foundation, Inc.
# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
#

View File

@ -1,4 +1,4 @@
%global glibcsrcdir glibc-2.40.9000-481-gdd413a4d2f
%global glibcsrcdir glibc-2.40.9000-665-gcc74583f23
%global glibcversion 2.40.9000
# Pre-release tarballs are pulled in from git using a command that is
# effectively:
@ -152,7 +152,7 @@ Version: %{glibcversion}
# - It allows using the Release number without the %%dist tag in the dependency
# generator to make the generated requires interchangeable between Rawhide
# and ELN (.elnYY < .fcXX).
%global baserelease 24
%global baserelease 25
Release: %{baserelease}%{?dist}
# Licenses:
@ -2367,6 +2367,90 @@ update_gconv_modules_cache ()
%endif
%changelog
* Thu Jan 02 2025 Florian Weimer <fweimer@redhat.com> - 2.40.9000-25
- Update glibc-nolink-libc.patch following upstream development.
- Update glibc-python3.patch to resolve copyright year conflict.
- Auto-sync with upstream branch master,
commit cc74583f23657515b1d09d0765032422af71de52:
- elf: Remove the remaining uses of GET_ADDR_OFFSET
- elf: Use TLS_DTV_OFFSET in __tls_get_addr
- s390: Define TLS_DTV_OFFSET instead of GET_ADDR_OFFSET
- elf: Introduce generic <dl-tls.h>
- Update copyright dates not handled by scripts/update-copyrights
- Update copyright in generated files by running "make"
- Update copyright dates with scripts/update-copyrights
- mlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
- elf: Add glibc.rtld.execstack
- elf: Do not change stack permission on dlopen/dlmopen
- x86-64: Reorder dynamic linker list in ldd script (bug 32508)
- libio: asprintf should write NULL upon failure
- nptl: More useful padding in struct pthread
- elf: Remove the GET_ADDR_ARGS and related macros from the TLS code
- build-many-glibcs.py: Add --exclude option
- NEWS: Mention testing glibc build with a different set of compilers
- support: Add support_record_failure_barrier
- io: statx, fstatat: Drop nonnull attribute on the path argument
- configure: Improve configure output for C++ Compiler
- getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]
- include/sys/cdefs.h: Add __attribute_optimization_barrier__
- assert: Use __writev in assert.c [BZ #32492]
- elf: Check PDE load address with non-empty text section
- Add clang specific warning suppression macros
- Add include/libc-misc.h
- Don't redefine INFINITY nor NAN
- assert: ensure posix compliance, add tests for such
- posix: fix system when a child cannot be created [BZ #32450]
- Fix elf: Introduce is_rtld_link_map [BZ #32488]
- elf: Reorder audit events in dlcose to match _dl_fini (bug 32066)
- elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065)
- elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)
- elf: Add the endswith function to <endswith.h>
- elf: Move _dl_rtld_map, _dl_rtld_audit_state out of GL
- elf: Introduce is_rtld_link_map
- Add F_CREATED_QUERY from Linux 6.12 to bits/fcntl-linux.h
- Add HWCAP_LOONGARCH_LSPW from Linux 6.12 to bits/hwcap.h
- Add MSG_SOCK_DEVMEM from Linux 6.12 to bits/socket.h
- Linux: Accept null arguments for utimensat pathname
- x86_64: Remove unused padding from tcbhead_t
- Add NT_X86_XSAVE_LAYOUT and NT_ARM_POE from Linux 6.12 to elf.h
- Add SCHED_EXT from Linux 6.12 to bits/sched.h
- math: Use tanhf from CORE-MATH
- math: Use sinhf from CORE-MATH
- math: Use coshf from CORE-MATH
- math: Use atanhf from CORE-MATH
- math: Use atan2f from CORE-MATH
- math: Use atanf from CORE-MATH
- math: Use asinhf from CORE-MATH
- math: Use asinf from CORE-MATH
- math: Use acoshf from CORE-MATH
- math: Use acosf from CORE-MATH
- math: Fix the expected carg (inf) results
- math: Fix the expected atan2f (inf) results
- math: Fix the expected atanf (inf) results
- math: Add inf support on gen-auto-libm-tests.c
- math: Fix spurious-divbyzero flag name
- benchtests: Add tanhf benchmark
- benchtests: Add sinhf benchmark
- benchtests: Add coshf benchmark
- benchtests: Add atanhf benchmark
- benchtests: Add atan2f benchmark
- benchtests: Add atanf benchmark
- benchtests: Add asinhf benchmark
- benchtests: Add asinf benchmark
- benchtests: Add acoshf benchmark
- benchtests: Add acosf benchmark
- Update syscall lists for Linux 6.12
- ungetc: Guarantee single char pushback
- sys/platform/x86.h: Do not depend on _Bool definition in C++ mode
- ldbl-96: Set -1 to "int sign_exponent:16"
- x86: Avoid integer truncation with large cache sizes (bug 32470)
- AArch64: Improve codegen of AdvSIMD expf family
- AArch64: Improve codegen of AdvSIMD atan(2)(f)
- AArch64: Improve codegen of AdvSIMD logf function family
- manual: Document more sigaction flags
- Remove duplicated BUILD_CC in Makeconfig
- iconv: do not report error exit with transliteration [BZ #32448]
* Mon Dec 16 2024 DJ Delorie <dj@redhat.com> - 2.40.9000-24
- Auto-sync with upstream branch master,
commit dd413a4d2f320d5c3bc43e0788919724c89b3dab.

View File

@ -1 +1 @@
SHA512 (glibc-2.40.9000-481-gdd413a4d2f.tar.xz) = 06b88379df7652fbc9b590f61f1aa428d2bbfca8e9c7984a1e4488ecba1d951097d14f1be9e6e81e78ed3dc93405c8f837b58d0484e980113de6aacbf8239759
SHA512 (glibc-2.40.9000-665-gcc74583f23.tar.xz) = c65c10b6cae986919b2025341355aaafb51569e8b7115972d368286fc8ca0af399b341410f20653554fa98c9a3eb8fc76d5432d96f2f1ea8dd281f071ef96916