mirror of
git://sourceware.org/git/glibc.git
synced 2026-09-08 23:58:31 +08:00
The BZ#33326 testcase triggers an assertion during process startup, which results in a segmentation fault instead of an error message and process termination with a SIGABRT. The assert issues __libc_message_impl, which in turn might call string functions depending on the ABI (strchrnul, strlen, memcpy/mempcpy), system calls (writev and mmap), and finally the abort call. The dl-symbol-redir-ifunc.h is also expanded to cover strchrnul on x86_64, s390, powerpc64 (both endianness) and loongarch, mempcpy on powerpc64be, and memcpy on aarch64. On s390 the redirection is only issued if the ifunc variant is built, since strchrnul-c.c only renames the C implementation to STRCHRNUL_DEFAULT when HAVE_STRCHRNUL_IFUNC is set. The buffer that backs up the assert message is now allocated through _dl_mmap, which issues the syscall directly instead of calling __mmap (setting errno on failure requires the thread pointer). The abort call now issues __raise_direct instead of raise (the Hurd port aliases __raise_direct to raise). On i386, syscalls should not use the vDSO during program startup because the thread pointer is not yet initialized. This requires __raise_direct, _dl_writev, and _dl_mmap to be built with I386_USE_SYSENTER set to 0. Creating a test case is challenging. For static-pie, the assert is only called for ill-formed ELF files on elf_get_dynamic_info and by some targets on ELF_DYNAMIC_RELOCATE (although not all targets use assert in their dl-machine.h). Some targets also issue __libc_fatal on ARCH_SETUP_IREL, but also only for ill-formatted ELF files. The test employs a different strategy and overrides the __tunables_init symbol, which is invoked immediately before self-relocation and TLS setup. The test is built with -Wl,-z,muldefs to avoid linker issues. I checked on aarch64, x86_64, i686, s390x (qemu), sparc (qemu), mips64el (qemu), armhf, riscv, and powerpc. Reviewed-by: Florian Weimer <fweimer@redhat.com>
31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/* Symbol redirection for loader/static initialization code.
|
|
Copyright (C) 2022-2026 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef _DL_IFUNC_GENERIC_H
|
|
#define _DL_IFUNC_GENERIC_H
|
|
|
|
asm ("memcpy = __memcpy_generic");
|
|
asm ("memset = __memset_generic");
|
|
asm ("strlen = __strlen_generic");
|
|
#ifndef SHARED
|
|
asm ("memmove = __memmove_generic");
|
|
asm ("memcmp = __memcmp_generic");
|
|
#endif
|
|
|
|
#endif
|