public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fwd: segfaults in _dl_fixup since 4af6982
       [not found] <CAOLZvyH+V0TokSzHumaxJF9JA=Kxoxh2NVr+ZZbdBD5qZ-urZg@mail.gmail.com>
@ 2021-10-13  6:42 ` Manuel Lauss
  2021-10-13  9:18   ` Szabolcs Nagy
  0 siblings, 1 reply; 12+ messages in thread
From: Manuel Lauss @ 2021-10-13  6:42 UTC (permalink / raw)
  To: libc-alpha, Adhemerval Zanella

[resend with libc-alpha]
Hi Adhemerval,

Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
elf_get_dynamic_info definition")  causes a lot (but not all) of my
applications
to segfault:

Program received signal SIGSEGV, Segmentation fault.
_dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
rel_addr, value);
(gdb) bt
#0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
#1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
../sysdeps/x86_64/dl-trampoline.h:126
#2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
iconvconfig.c:288

Reverting the commit fixes the problem. Gcc, python, etc seem to be
not affected, while for example iconvconfig and openssh are.

Thanks,
    Manuel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Fwd: segfaults in _dl_fixup since 4af6982
  2021-10-13  6:42 ` Fwd: segfaults in _dl_fixup since 4af6982 Manuel Lauss
@ 2021-10-13  9:18   ` Szabolcs Nagy
  2021-10-13 10:58     ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Szabolcs Nagy @ 2021-10-13  9:18 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: libc-alpha, Adhemerval Zanella

The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
> [resend with libc-alpha]
> Hi Adhemerval,
> 
> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
> elf_get_dynamic_info definition")  causes a lot (but not all) of my
> applications
> to segfault:
> 
> Program received signal SIGSEGV, Segmentation fault.
> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
> rel_addr, value);
> (gdb) bt
> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
> ../sysdeps/x86_64/dl-trampoline.h:126
> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
> iconvconfig.c:288
> 
> Reverting the commit fixes the problem. Gcc, python, etc seem to be
> not affected, while for example iconvconfig and openssh are.

on aarch64 buildbot i see

FAIL: nptl/test-cond-printers
FAIL: nptl/test-condattr-printers
FAIL: nptl/test-mutex-printers
FAIL: nptl/test-mutexattr-printers
FAIL: nptl/test-rwlock-printers
FAIL: nptl/test-rwlockattr-printers

and

$ cat nptl/test-cond-printers.out
Error: Response does not match the expected pattern.
Command: start
Expected pattern: main
Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers

Program received signal SIGSEGV, Segmentation fault.
_dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
(gdb)


it seems to be a bind-now pie where PLT relocs are not yet
processed when __libc_start_main is called but PLTGOT is
already marked readonly so _dl_fixup crashes.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13  9:18   ` Szabolcs Nagy
@ 2021-10-13 10:58     ` Adhemerval Zanella
  2021-10-13 11:44       ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 10:58 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Manuel Lauss, libc-alpha



> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> 
> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>> [resend with libc-alpha]
>> Hi Adhemerval,
>> 
>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>> applications
>> to segfault:
>> 
>> Program received signal SIGSEGV, Segmentation fault.
>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>> rel_addr, value);
>> (gdb) bt
>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>> ../sysdeps/x86_64/dl-trampoline.h:126
>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>> iconvconfig.c:288
>> 
>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>> not affected, while for example iconvconfig and openssh are.
> 
> on aarch64 buildbot i see
> 
> FAIL: nptl/test-cond-printers
> FAIL: nptl/test-condattr-printers
> FAIL: nptl/test-mutex-printers
> FAIL: nptl/test-mutexattr-printers
> FAIL: nptl/test-rwlock-printers
> FAIL: nptl/test-rwlockattr-printers
> 
> and
> 
> $ cat nptl/test-cond-printers.out
> Error: Response does not match the expected pattern.
> Command: start
> Expected pattern: main
> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
> 
> Program received signal SIGSEGV, Segmentation fault.
> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
> (gdb)
> 
> 
> it seems to be a bind-now pie where PLT relocs are not yet
> processed when __libc_start_main is called but PLTGOT is
> already marked readonly so _dl_fixup crashes.

I will check this out.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 10:58     ` Adhemerval Zanella
@ 2021-10-13 11:44       ` Adhemerval Zanella
  2021-10-13 11:56         ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 11:44 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Manuel Lauss, libc-alpha



On 13/10/2021 07:58, Adhemerval Zanella wrote:
> 
> 
>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>
>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>>> [resend with libc-alpha]
>>> Hi Adhemerval,
>>>
>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>>> applications
>>> to segfault:
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>>> rel_addr, value);
>>> (gdb) bt
>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>>> ../sysdeps/x86_64/dl-trampoline.h:126
>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>>> iconvconfig.c:288
>>>
>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>>> not affected, while for example iconvconfig and openssh are.
>>
>> on aarch64 buildbot i see
>>
>> FAIL: nptl/test-cond-printers
>> FAIL: nptl/test-condattr-printers
>> FAIL: nptl/test-mutex-printers
>> FAIL: nptl/test-mutexattr-printers
>> FAIL: nptl/test-rwlock-printers
>> FAIL: nptl/test-rwlockattr-printers
>>
>> and
>>
>> $ cat nptl/test-cond-printers.out
>> Error: Response does not match the expected pattern.
>> Command: start
>> Expected pattern: main
>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
>> (gdb)
>>
>>
>> it seems to be a bind-now pie where PLT relocs are not yet
>> processed when __libc_start_main is called but PLTGOT is
>> already marked readonly so _dl_fixup crashes.
> 
> I will check this out.
> 

I am trying to reproduce it on aarch64-linux-gnu without much success (using
gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
when running through the built glibc (using ubuntu 21.04 one).

Any idea on how to reproduce it?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 11:44       ` Adhemerval Zanella
@ 2021-10-13 11:56         ` Adhemerval Zanella
  2021-10-13 13:46           ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 11:56 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Manuel Lauss, libc-alpha, Fangrui Song



On 13/10/2021 08:44, Adhemerval Zanella wrote:
> 
> 
> On 13/10/2021 07:58, Adhemerval Zanella wrote:
>>
>>
>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>
>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>>>> [resend with libc-alpha]
>>>> Hi Adhemerval,
>>>>
>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>>>> applications
>>>> to segfault:
>>>>
>>>> Program received signal SIGSEGV, Segmentation fault.
>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>>>> rel_addr, value);
>>>> (gdb) bt
>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>>>> ../sysdeps/x86_64/dl-trampoline.h:126
>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>>>> iconvconfig.c:288
>>>>
>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>>>> not affected, while for example iconvconfig and openssh are.
>>>
>>> on aarch64 buildbot i see
>>>
>>> FAIL: nptl/test-cond-printers
>>> FAIL: nptl/test-condattr-printers
>>> FAIL: nptl/test-mutex-printers
>>> FAIL: nptl/test-mutexattr-printers
>>> FAIL: nptl/test-rwlock-printers
>>> FAIL: nptl/test-rwlockattr-printers
>>>
>>> and
>>>
>>> $ cat nptl/test-cond-printers.out
>>> Error: Response does not match the expected pattern.
>>> Command: start
>>> Expected pattern: main
>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
>>> (gdb)
>>>
>>>
>>> it seems to be a bind-now pie where PLT relocs are not yet
>>> processed when __libc_start_main is called but PLTGOT is
>>> already marked readonly so _dl_fixup crashes.
>>
>> I will check this out.
>>
> 
> I am trying to reproduce it on aarch64-linux-gnu without much success (using
> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
> when running through the built glibc (using ubuntu 21.04 one).
> 
> Any idea on how to reproduce it?
> 

Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
elf_get_dynamic_info(), but there are lot of more usage that changes
the semantic of the nested functions (specifically on elf/do-rel.h
and dl-machine.h).

I will try to fix, I think we should define RTLD_BOOTSTRAP before the
fist dynamic-link.h in rtld.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 11:56         ` Adhemerval Zanella
@ 2021-10-13 13:46           ` Adhemerval Zanella
  2021-10-13 13:55             ` Manuel Lauss
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 13:46 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Manuel Lauss, libc-alpha, Fangrui Song

[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]



On 13/10/2021 08:56, Adhemerval Zanella wrote:
> 
> 
> On 13/10/2021 08:44, Adhemerval Zanella wrote:
>>
>>
>> On 13/10/2021 07:58, Adhemerval Zanella wrote:
>>>
>>>
>>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>>
>>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>>>>> [resend with libc-alpha]
>>>>> Hi Adhemerval,
>>>>>
>>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>>>>> applications
>>>>> to segfault:
>>>>>
>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>>>>> rel_addr, value);
>>>>> (gdb) bt
>>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>>>>> ../sysdeps/x86_64/dl-trampoline.h:126
>>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>>>>> iconvconfig.c:288
>>>>>
>>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>>>>> not affected, while for example iconvconfig and openssh are.
>>>>
>>>> on aarch64 buildbot i see
>>>>
>>>> FAIL: nptl/test-cond-printers
>>>> FAIL: nptl/test-condattr-printers
>>>> FAIL: nptl/test-mutex-printers
>>>> FAIL: nptl/test-mutexattr-printers
>>>> FAIL: nptl/test-rwlock-printers
>>>> FAIL: nptl/test-rwlockattr-printers
>>>>
>>>> and
>>>>
>>>> $ cat nptl/test-cond-printers.out
>>>> Error: Response does not match the expected pattern.
>>>> Command: start
>>>> Expected pattern: main
>>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
>>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
>>>>
>>>> Program received signal SIGSEGV, Segmentation fault.
>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
>>>> (gdb)
>>>>
>>>>
>>>> it seems to be a bind-now pie where PLT relocs are not yet
>>>> processed when __libc_start_main is called but PLTGOT is
>>>> already marked readonly so _dl_fixup crashes.
>>>
>>> I will check this out.
>>>
>>
>> I am trying to reproduce it on aarch64-linux-gnu without much success (using
>> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
>> when running through the built glibc (using ubuntu 21.04 one).
>>
>> Any idea on how to reproduce it?
>>
> 
> Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
> elf_get_dynamic_info(), but there are lot of more usage that changes
> the semantic of the nested functions (specifically on elf/do-rel.h
> and dl-machine.h).
> 
> I will try to fix, I think we should define RTLD_BOOTSTRAP before the
> fist dynamic-link.h in rtld.
> 

Could you check if the attached patch fixes it?  The rtld.c now should get
all the required function with the expected semantic (RTLD_BOOTSTRAP defined).

[-- Attachment #2: 0001-elf-Fix-dynamic-link.h-usage-on-rtld.c.patch --]
[-- Type: text/x-patch, Size: 20781 bytes --]

From 0d65225a02967d02ec2aae02600f8578affc4ec1 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 13 Oct 2021 09:49:34 -0300
Subject: [PATCH] elf: Fix dynamic-link.h usage on rtld.c

The 4af6982e4c fix does not fully handle RTLD_BOOTSTRAP usage on
rtld.c, since RTLD_BOOTSTRAP is also used on dl-machine.h on various
architectures to have diferent semantics for relocation functions.

This patch now includes dynamic-link.h and get-dynamic-info.h once
and with RTLD_BOOTSTRAP defined.  The ELF_DYNAMIC_RELOCATE calls
will now call all relocation functions with expected semantic.

To reorganize the include some static TLS definition is moved to
its own header since it is defined on dynamic-link.h and dl-machine.h
requires it (and it creates a circular dependendy that required to
include dynamic-link.h twice in rtld.c).

The powerpc Elf64_FuncDesc is also moved to its own header, since
csu code required its definition (which would require either include
elf/ folder or add a full path).

Checked on x86_64, i686, aarch64, armhf, powerpc64, powerpc32,
and powerpc64le.
---
 elf/dl-static-tls.h                         | 51 +++++++++++++++++++++
 elf/dynamic-link.h                          | 33 +------------
 elf/rtld.c                                  | 19 ++++----
 sysdeps/aarch64/dl-machine.h                |  3 +-
 sysdeps/alpha/dl-machine.h                  |  2 +-
 sysdeps/arc/dl-machine.h                    |  5 +-
 sysdeps/arm/dl-machine.h                    |  1 +
 sysdeps/csky/dl-machine.h                   |  1 +
 sysdeps/generic/dl-machine.h                |  1 +
 sysdeps/hppa/dl-machine.h                   |  1 +
 sysdeps/i386/dl-machine.h                   |  1 +
 sysdeps/ia64/dl-machine.h                   |  1 +
 sysdeps/m68k/dl-machine.h                   |  1 +
 sysdeps/microblaze/dl-machine.h             |  1 +
 sysdeps/mips/dl-machine.h                   |  1 +
 sysdeps/nios2/dl-machine.h                  |  1 +
 sysdeps/powerpc/powerpc32/dl-machine.h      |  1 +
 sysdeps/powerpc/powerpc64/dl-funcdesc.h     | 34 ++++++++++++++
 sysdeps/powerpc/powerpc64/dl-irel.h         |  2 +-
 sysdeps/powerpc/powerpc64/dl-machine.h      | 14 +-----
 sysdeps/riscv/dl-machine.h                  |  1 +
 sysdeps/s390/s390-32/dl-machine.h           |  1 +
 sysdeps/s390/s390-64/dl-machine.h           |  1 +
 sysdeps/sh/dl-machine.h                     |  1 +
 sysdeps/sparc/sparc32/dl-machine.h          |  1 +
 sysdeps/sparc/sparc64/dl-machine.h          |  1 +
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h |  2 +-
 sysdeps/x86_64/dl-machine.h                 |  1 +
 28 files changed, 123 insertions(+), 60 deletions(-)
 create mode 100644 elf/dl-static-tls.h
 create mode 100644 sysdeps/powerpc/powerpc64/dl-funcdesc.h

diff --git a/elf/dl-static-tls.h b/elf/dl-static-tls.h
new file mode 100644
index 0000000000..730924fc01
--- /dev/null
+++ b/elf/dl-static-tls.h
@@ -0,0 +1,51 @@
+/* Inline functions for dynamic linking.
+   Copyright (C) 1995-2021 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_STATIC_TLS_H
+#define _DL_STATIC_TLS_H
+
+/* This macro is used as a callback from elf_machine_rel{a,} when a
+   static TLS reloc is about to be performed.  Since (in dl-load.c) we
+   permit dynamic loading of objects that might use such relocs, we
+   have to check whether each use is actually doable.  If the object
+   whose TLS segment the reference resolves to was allocated space in
+   the static TLS block at startup, then it's ok.  Otherwise, we make
+   an attempt to allocate it in surplus space on the fly.  If that
+   can't be done, we fall back to the error that DF_STATIC_TLS is
+   intended to produce.  */
+#define HAVE_STATIC_TLS(map, sym_map)					\
+    (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET		\
+		       && ((sym_map)->l_tls_offset			\
+			   != FORCED_DYNAMIC_TLS_OFFSET), 1))
+
+#define CHECK_STATIC_TLS(map, sym_map)					\
+    do {								\
+      if (!HAVE_STATIC_TLS (map, sym_map))				\
+	_dl_allocate_static_tls (sym_map);				\
+    } while (0)
+
+#define TRY_STATIC_TLS(map, sym_map)					\
+    (__builtin_expect ((sym_map)->l_tls_offset				\
+		       != FORCED_DYNAMIC_TLS_OFFSET, 1)			\
+     && (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1)	\
+	 || _dl_try_allocate_static_tls (sym_map, true) == 0))
+
+int _dl_try_allocate_static_tls (struct link_map *map, bool optional)
+  attribute_hidden;
+
+#endif
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index 21cdfc88bb..ac4cc70dea 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -16,35 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* This macro is used as a callback from elf_machine_rel{a,} when a
-   static TLS reloc is about to be performed.  Since (in dl-load.c) we
-   permit dynamic loading of objects that might use such relocs, we
-   have to check whether each use is actually doable.  If the object
-   whose TLS segment the reference resolves to was allocated space in
-   the static TLS block at startup, then it's ok.  Otherwise, we make
-   an attempt to allocate it in surplus space on the fly.  If that
-   can't be done, we fall back to the error that DF_STATIC_TLS is
-   intended to produce.  */
-#define HAVE_STATIC_TLS(map, sym_map)					\
-    (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET		\
-		       && ((sym_map)->l_tls_offset			\
-			   != FORCED_DYNAMIC_TLS_OFFSET), 1))
-
-#define CHECK_STATIC_TLS(map, sym_map)					\
-    do {								\
-      if (!HAVE_STATIC_TLS (map, sym_map))				\
-	_dl_allocate_static_tls (sym_map);				\
-    } while (0)
-
-#define TRY_STATIC_TLS(map, sym_map)					\
-    (__builtin_expect ((sym_map)->l_tls_offset				\
-		       != FORCED_DYNAMIC_TLS_OFFSET, 1)			\
-     && (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1)	\
-	 || _dl_try_allocate_static_tls (sym_map, true) == 0))
-
-int _dl_try_allocate_static_tls (struct link_map *map, bool optional)
-  attribute_hidden;
-
+#include <dl-machine.h>
 #include <elf.h>
 
 #ifdef RESOLVE_MAP
@@ -91,9 +63,6 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
 # endif
 #endif
 
-#include <dl-machine.h>
-
-
 #ifdef RESOLVE_MAP
 
 # if defined RTLD_BOOTSTRAP || defined STATIC_PIE_BOOTSTRAP
diff --git a/elf/rtld.c b/elf/rtld.c
index fe5ee9ec4d..b77aaaa733 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -32,7 +32,6 @@
 #include <fpu_control.h>
 #include <hp-timing.h>
 #include <libc-lock.h>
-#include "dynamic-link.h"
 #include <dl-librecon.h>
 #include <unsecvars.h>
 #include <dl-cache.h>
@@ -53,6 +52,15 @@
 
 #include <assert.h>
 
+/* This #define produces dynamic linking inline functions for
+   bootstrap relocation instead of general-purpose relocation.
+   Since ld.so must not have any undefined symbols the result
+   is trivial: always the map of ld.so itself.  */
+#define RTLD_BOOTSTRAP
+#define RESOLVE_MAP(map, scope, sym, version, flags) map
+#include "dynamic-link.h"
+#include "get-dynamic-info.h"
+
 /* Only enables rtld profiling for architectures which provides non generic
    hp-timing support.  The generic support requires either syscall
    (clock_gettime), which will incur in extra overhead on loading time.
@@ -507,15 +515,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
 # define bootstrap_map info.l
 #endif
 
-  /* This #define produces dynamic linking inline functions for
-     bootstrap relocation instead of general-purpose relocation.
-     Since ld.so must not have any undefined symbols the result
-     is trivial: always the map of ld.so itself.  */
-#define RTLD_BOOTSTRAP
-#define RESOLVE_MAP(map, scope, sym, version, flags) map
-#include "get-dynamic-info.h"
-#include "dynamic-link.h"
-
 static ElfW(Addr) __attribute_used__
 _dl_start (void *arg)
 {
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index e30e81c902..e7b91d6530 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 #include <dl-irel.h>
 #include <cpu-features.c>
 
@@ -370,7 +371,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
     }
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr,
 			   const ElfW(Rela) *reloc,
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index 491541326f..b9afa4546f 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -25,7 +25,7 @@
 #define ELF_MACHINE_NAME "alpha"
 
 #include <string.h>
-
+#include <dl-static-tls.h>
 
 /* Mask identifying addresses reserved for the user program,
    where the dynamic linker should not map anything.  */
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
index 4b64ffec25..20496ce1d1 100644
--- a/sysdeps/arc/dl-machine.h
+++ b/sysdeps/arc/dl-machine.h
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <link.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Dynamic Linking ABI for ARCv2 ISA.
 
@@ -318,7 +319,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
     }
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
                            void *const reloc_addr_arg)
@@ -327,7 +328,7 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
   *reloc_addr += l_addr;
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
 		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index dfa05eee44..20c0653e82 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -26,6 +26,7 @@
 #include <tls.h>
 #include <dl-tlsdesc.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #ifndef CLEAR_CACHE
 # error CLEAR_CACHE definition required to handle TEXTREL
diff --git a/sysdeps/csky/dl-machine.h b/sysdeps/csky/dl-machine.h
index ec22f87577..47e8e592d2 100644
--- a/sysdeps/csky/dl-machine.h
+++ b/sysdeps/csky/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero if ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/generic/dl-machine.h b/sysdeps/generic/dl-machine.h
index 4a4ab4fc70..6fc61a2591 100644
--- a/sysdeps/generic/dl-machine.h
+++ b/sysdeps/generic/dl-machine.h
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <link.h>
+#include <dl-static-tls.h>
 
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index e6a4575fce..3a7e20a4a7 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -29,6 +29,7 @@
 #include <dl-fptr.h>
 #include <abort-instr.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* These two definitions must match the definition of the stub in
    bfd/elf32-hppa.c (see plt_stub[]).
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 78bed03eee..94056142e4 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
index 2217d0b556..a53101a02f 100644
--- a/sysdeps/ia64/dl-machine.h
+++ b/sysdeps/ia64/dl-machine.h
@@ -27,6 +27,7 @@
 #include <errno.h>
 #include <dl-fptr.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 5e34c4784e..8e20139c42 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h
index 3fd4988e60..188d3340ee 100644
--- a/sysdeps/microblaze/dl-machine.h
+++ b/sysdeps/microblaze/dl-machine.h
@@ -23,6 +23,7 @@
 
 #include <sys/param.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index f8d1298b60..15e8de551b 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -32,6 +32,7 @@
 #include <sysdep.h>
 #include <sys/asm.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* The offset of gp from GOT might be system-dependent.  It's set by
    ld.  The same value is also */
diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h
index 4de602b13d..efc0bcece9 100644
--- a/sysdeps/nios2/dl-machine.h
+++ b/sysdeps/nios2/dl-machine.h
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <link.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index cda012dc1b..01b18ca536 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -25,6 +25,7 @@
 #include <dl-tls.h>
 #include <dl-irel.h>
 #include <hwcapinfo.h>
+#include <dl-static-tls.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
diff --git a/sysdeps/powerpc/powerpc64/dl-funcdesc.h b/sysdeps/powerpc/powerpc64/dl-funcdesc.h
new file mode 100644
index 0000000000..b2d1f76ce0
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/dl-funcdesc.h
@@ -0,0 +1,34 @@
+/* PowerPC ELFv1 function descriptor definition.
+   Copyright (C) 2009-2021 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_FUNCDESC_H
+#define _DL_FUNCDESC_H
+
+#if _CALL_ELF != 2
+/* A PowerPC64 function descriptor.  The .plt (procedure linkage
+   table) and .opd (official procedure descriptor) sections are
+   arrays of these.  */
+typedef struct
+{
+  Elf64_Addr fd_func;
+  Elf64_Addr fd_toc;
+  Elf64_Addr fd_aux;
+} Elf64_FuncDesc;
+#endif
+
+#endif
diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h
index 0e11b7ff64..aa9a2dca71 100644
--- a/sysdeps/powerpc/powerpc64/dl-irel.h
+++ b/sysdeps/powerpc/powerpc64/dl-irel.h
@@ -23,7 +23,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <ldsodefs.h>
-#include <dl-machine.h>
+#include <dl-funcdesc.h>
 
 #define ELF_MACHINE_IRELA	1
 
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index 3f92fbb369..635cb45dcc 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -28,23 +28,13 @@
 #include <sysdep.h>
 #include <hwcapinfo.h>
 #include <cpu-features.c>
+#include <dl-static-tls.h>
+#include <dl-funcdesc.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
 #define DT_PPC64(x) (DT_PPC64_##x - DT_LOPROC + DT_NUM)
 
-#if _CALL_ELF != 2
-/* A PowerPC64 function descriptor.  The .plt (procedure linkage
-   table) and .opd (official procedure descriptor) sections are
-   arrays of these.  */
-typedef struct
-{
-  Elf64_Addr fd_func;
-  Elf64_Addr fd_toc;
-  Elf64_Addr fd_aux;
-} Elf64_FuncDesc;
-#endif
-
 #define ELF_MULT_MACHINES_SUPPORTED
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index e7289d7ddc..b8fdfde8c0 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sys/asm.h>
 #include <dl-tls.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #ifndef _RTLD_PROLOGUE
 # define _RTLD_PROLOGUE(entry)						\
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
index cd16cc7e00..3c8054ae84 100644
--- a/sysdeps/s390/s390-32/dl-machine.h
+++ b/sysdeps/s390/s390-32/dl-machine.h
@@ -26,6 +26,7 @@
 #include <link.h>
 #include <sysdeps/s390/dl-procinfo.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 /* This is an older, now obsolete value.  */
 #define EM_S390_OLD	0xA390
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
index 0330a8d7de..9d9d0ea0d6 100644
--- a/sysdeps/s390/s390-64/dl-machine.h
+++ b/sysdeps/s390/s390-64/dl-machine.h
@@ -27,6 +27,7 @@
 #include <link.h>
 #include <sysdeps/s390/dl-procinfo.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #define ELF_MACHINE_IRELATIVE       R_390_IRELATIVE
 
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
index 0c22dfd848..96fd894d40 100644
--- a/sysdeps/sh/dl-machine.h
+++ b/sysdeps/sh/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <assert.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 6361cfae9e..a59c110460 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -28,6 +28,7 @@
 #include <tls.h>
 #include <dl-plt.h>
 #include <elf/dl-hwcaps.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index 3fd18c6e5e..2289691689 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -26,6 +26,7 @@
 #include <ldsodefs.h>
 #include <sysdep.h>
 #include <dl-plt.h>
+#include <dl-static-tls.h>
 
 #define ELF64_R_TYPE_ID(info)	((info) & 0xff)
 #define ELF64_R_TYPE_DATA(info) ((info) >> 8)
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index db388a022d..72b75d3beb 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -24,7 +24,7 @@
 #include <sysdep-vdso.h>
 
 #if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
-# include <dl-machine.h>
+# include <dl-funcdesc.h>
 /* The correct solution is for _dl_vdso_vsym to return the address of the OPD
    for the kernel VDSO function.  That address would then be stored in the
    __vdso_* variables and returned as the result of the IFUNC resolver function.
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 20afb0b4bc..33df0dd5fc 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 13:46           ` Adhemerval Zanella
@ 2021-10-13 13:55             ` Manuel Lauss
  2021-10-13 14:41               ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Manuel Lauss @ 2021-10-13 13:55 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Szabolcs Nagy, libc-alpha, Fangrui Song

Applied this patch on top of git head, still same error.

Manuel

On Wed, Oct 13, 2021 at 3:47 PM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 13/10/2021 08:56, Adhemerval Zanella wrote:
> >
> >
> > On 13/10/2021 08:44, Adhemerval Zanella wrote:
> >>
> >>
> >> On 13/10/2021 07:58, Adhemerval Zanella wrote:
> >>>
> >>>
> >>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> >>>>
> >>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
> >>>>> [resend with libc-alpha]
> >>>>> Hi Adhemerval,
> >>>>>
> >>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
> >>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
> >>>>> applications
> >>>>> to segfault:
> >>>>>
> >>>>> Program received signal SIGSEGV, Segmentation fault.
> >>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
> >>>>> rel_addr, value);
> >>>>> (gdb) bt
> >>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
> >>>>> ../sysdeps/x86_64/dl-trampoline.h:126
> >>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
> >>>>> iconvconfig.c:288
> >>>>>
> >>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
> >>>>> not affected, while for example iconvconfig and openssh are.
> >>>>
> >>>> on aarch64 buildbot i see
> >>>>
> >>>> FAIL: nptl/test-cond-printers
> >>>> FAIL: nptl/test-condattr-printers
> >>>> FAIL: nptl/test-mutex-printers
> >>>> FAIL: nptl/test-mutexattr-printers
> >>>> FAIL: nptl/test-rwlock-printers
> >>>> FAIL: nptl/test-rwlockattr-printers
> >>>>
> >>>> and
> >>>>
> >>>> $ cat nptl/test-cond-printers.out
> >>>> Error: Response does not match the expected pattern.
> >>>> Command: start
> >>>> Expected pattern: main
> >>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
> >>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
> >>>>
> >>>> Program received signal SIGSEGV, Segmentation fault.
> >>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
> >>>> (gdb)
> >>>>
> >>>>
> >>>> it seems to be a bind-now pie where PLT relocs are not yet
> >>>> processed when __libc_start_main is called but PLTGOT is
> >>>> already marked readonly so _dl_fixup crashes.
> >>>
> >>> I will check this out.
> >>>
> >>
> >> I am trying to reproduce it on aarch64-linux-gnu without much success (using
> >> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
> >> when running through the built glibc (using ubuntu 21.04 one).
> >>
> >> Any idea on how to reproduce it?
> >>
> >
> > Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
> > elf_get_dynamic_info(), but there are lot of more usage that changes
> > the semantic of the nested functions (specifically on elf/do-rel.h
> > and dl-machine.h).
> >
> > I will try to fix, I think we should define RTLD_BOOTSTRAP before the
> > fist dynamic-link.h in rtld.
> >
>
> Could you check if the attached patch fixes it?  The rtld.c now should get
> all the required function with the expected semantic (RTLD_BOOTSTRAP defined).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 13:55             ` Manuel Lauss
@ 2021-10-13 14:41               ` Adhemerval Zanella
  2021-10-13 14:51                 ` Manuel Lauss
  2021-10-13 17:28                 ` Szabolcs Nagy
  0 siblings, 2 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 14:41 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: Szabolcs Nagy, libc-alpha, Fangrui Song

[-- Attachment #1: Type: text/plain, Size: 3712 bytes --]



On 13/10/2021 10:55, Manuel Lauss wrote:
> Applied this patch on top of git head, still same error.
> 
> Manuel

Sigh, it seems I got the elf_get_dynamic_info() sideways.  Could you check
this slight modified patch? It is x86_64 only for now.

And I am puzzled why I am not seeing any issues in the environments I am
checking...

> 
> On Wed, Oct 13, 2021 at 3:47 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 13/10/2021 08:56, Adhemerval Zanella wrote:
>>>
>>>
>>> On 13/10/2021 08:44, Adhemerval Zanella wrote:
>>>>
>>>>
>>>> On 13/10/2021 07:58, Adhemerval Zanella wrote:
>>>>>
>>>>>
>>>>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>>>>
>>>>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>>>>>>> [resend with libc-alpha]
>>>>>>> Hi Adhemerval,
>>>>>>>
>>>>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>>>>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>>>>>>> applications
>>>>>>> to segfault:
>>>>>>>
>>>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>>>>>>> rel_addr, value);
>>>>>>> (gdb) bt
>>>>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>>>>>>> ../sysdeps/x86_64/dl-trampoline.h:126
>>>>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>>>>>>> iconvconfig.c:288
>>>>>>>
>>>>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>>>>>>> not affected, while for example iconvconfig and openssh are.
>>>>>>
>>>>>> on aarch64 buildbot i see
>>>>>>
>>>>>> FAIL: nptl/test-cond-printers
>>>>>> FAIL: nptl/test-condattr-printers
>>>>>> FAIL: nptl/test-mutex-printers
>>>>>> FAIL: nptl/test-mutexattr-printers
>>>>>> FAIL: nptl/test-rwlock-printers
>>>>>> FAIL: nptl/test-rwlockattr-printers
>>>>>>
>>>>>> and
>>>>>>
>>>>>> $ cat nptl/test-cond-printers.out
>>>>>> Error: Response does not match the expected pattern.
>>>>>> Command: start
>>>>>> Expected pattern: main
>>>>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
>>>>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
>>>>>>
>>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
>>>>>> (gdb)
>>>>>>
>>>>>>
>>>>>> it seems to be a bind-now pie where PLT relocs are not yet
>>>>>> processed when __libc_start_main is called but PLTGOT is
>>>>>> already marked readonly so _dl_fixup crashes.
>>>>>
>>>>> I will check this out.
>>>>>
>>>>
>>>> I am trying to reproduce it on aarch64-linux-gnu without much success (using
>>>> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
>>>> when running through the built glibc (using ubuntu 21.04 one).
>>>>
>>>> Any idea on how to reproduce it?
>>>>
>>>
>>> Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
>>> elf_get_dynamic_info(), but there are lot of more usage that changes
>>> the semantic of the nested functions (specifically on elf/do-rel.h
>>> and dl-machine.h).
>>>
>>> I will try to fix, I think we should define RTLD_BOOTSTRAP before the
>>> fist dynamic-link.h in rtld.
>>>
>>
>> Could you check if the attached patch fixes it?  The rtld.c now should get
>> all the required function with the expected semantic (RTLD_BOOTSTRAP defined).

[-- Attachment #2: 0001-elf-Fix-dynamic-link.h-usage-on-rtld.c.patch --]
[-- Type: text/x-patch, Size: 22503 bytes --]

From 5729408663d0ba5e4b3a6602abe1901b0a669b58 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 13 Oct 2021 09:49:34 -0300
Subject: [PATCH] elf: Fix dynamic-link.h usage on rtld.c

The 4af6982e4c fix does not fully handle RTLD_BOOTSTRAP usage on
rtld.c, since RTLD_BOOTSTRAP is also used on dl-machine.h on various
architectures to have diferent semantics for relocation functions.

This patch now includes dynamic-link.h and get-dynamic-info.h once
and with RTLD_BOOTSTRAP defined.  The ELF_DYNAMIC_RELOCATE calls
will now call all relocation functions with expected semantic.

To reorganize the include some static TLS definition is moved to
its own header since it is defined on dynamic-link.h and dl-machine.h
requires it (and it creates a circular dependendy that required to
include dynamic-link.h twice in rtld.c).

The powerpc Elf64_FuncDesc is also moved to its own header, since
csu code required its definition (which would require either include
elf/ folder or add a full path).

Checked on x86_64, i686, aarch64, armhf, powerpc64, powerpc32,
and powerpc64le.
---
 elf/dl-static-tls.h                         | 51 +++++++++++++++++++++
 elf/dynamic-link.h                          | 33 +------------
 elf/get-dynamic-info.h                      |  1 +
 elf/rtld.c                                  | 19 ++++----
 sysdeps/aarch64/dl-machine.h                |  3 +-
 sysdeps/alpha/dl-machine.h                  |  2 +-
 sysdeps/arc/dl-machine.h                    |  5 +-
 sysdeps/arm/dl-machine.h                    |  1 +
 sysdeps/csky/dl-machine.h                   |  1 +
 sysdeps/generic/dl-machine.h                |  1 +
 sysdeps/hppa/dl-machine.h                   |  1 +
 sysdeps/i386/dl-machine.h                   |  1 +
 sysdeps/ia64/dl-machine.h                   |  1 +
 sysdeps/m68k/dl-machine.h                   |  1 +
 sysdeps/microblaze/dl-machine.h             |  1 +
 sysdeps/mips/dl-machine.h                   |  1 +
 sysdeps/nios2/dl-machine.h                  |  1 +
 sysdeps/powerpc/powerpc32/dl-machine.h      |  1 +
 sysdeps/powerpc/powerpc64/dl-funcdesc.h     | 34 ++++++++++++++
 sysdeps/powerpc/powerpc64/dl-irel.h         |  2 +-
 sysdeps/powerpc/powerpc64/dl-machine.h      | 14 +-----
 sysdeps/riscv/dl-machine.h                  |  1 +
 sysdeps/s390/s390-32/dl-machine.h           |  1 +
 sysdeps/s390/s390-64/dl-machine.h           |  1 +
 sysdeps/sh/dl-machine.h                     |  1 +
 sysdeps/sparc/sparc32/dl-machine.h          |  1 +
 sysdeps/sparc/sparc64/dl-machine.h          |  1 +
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h |  2 +-
 sysdeps/x86_64/dl-machine-rel.h             | 26 +++++++++++
 sysdeps/x86_64/dl-machine.h                 |  1 +
 30 files changed, 150 insertions(+), 60 deletions(-)
 create mode 100644 elf/dl-static-tls.h
 create mode 100644 sysdeps/powerpc/powerpc64/dl-funcdesc.h
 create mode 100644 sysdeps/x86_64/dl-machine-rel.h

diff --git a/elf/dl-static-tls.h b/elf/dl-static-tls.h
new file mode 100644
index 0000000000..730924fc01
--- /dev/null
+++ b/elf/dl-static-tls.h
@@ -0,0 +1,51 @@
+/* Inline functions for dynamic linking.
+   Copyright (C) 1995-2021 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_STATIC_TLS_H
+#define _DL_STATIC_TLS_H
+
+/* This macro is used as a callback from elf_machine_rel{a,} when a
+   static TLS reloc is about to be performed.  Since (in dl-load.c) we
+   permit dynamic loading of objects that might use such relocs, we
+   have to check whether each use is actually doable.  If the object
+   whose TLS segment the reference resolves to was allocated space in
+   the static TLS block at startup, then it's ok.  Otherwise, we make
+   an attempt to allocate it in surplus space on the fly.  If that
+   can't be done, we fall back to the error that DF_STATIC_TLS is
+   intended to produce.  */
+#define HAVE_STATIC_TLS(map, sym_map)					\
+    (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET		\
+		       && ((sym_map)->l_tls_offset			\
+			   != FORCED_DYNAMIC_TLS_OFFSET), 1))
+
+#define CHECK_STATIC_TLS(map, sym_map)					\
+    do {								\
+      if (!HAVE_STATIC_TLS (map, sym_map))				\
+	_dl_allocate_static_tls (sym_map);				\
+    } while (0)
+
+#define TRY_STATIC_TLS(map, sym_map)					\
+    (__builtin_expect ((sym_map)->l_tls_offset				\
+		       != FORCED_DYNAMIC_TLS_OFFSET, 1)			\
+     && (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1)	\
+	 || _dl_try_allocate_static_tls (sym_map, true) == 0))
+
+int _dl_try_allocate_static_tls (struct link_map *map, bool optional)
+  attribute_hidden;
+
+#endif
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index 21cdfc88bb..ac4cc70dea 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -16,35 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* This macro is used as a callback from elf_machine_rel{a,} when a
-   static TLS reloc is about to be performed.  Since (in dl-load.c) we
-   permit dynamic loading of objects that might use such relocs, we
-   have to check whether each use is actually doable.  If the object
-   whose TLS segment the reference resolves to was allocated space in
-   the static TLS block at startup, then it's ok.  Otherwise, we make
-   an attempt to allocate it in surplus space on the fly.  If that
-   can't be done, we fall back to the error that DF_STATIC_TLS is
-   intended to produce.  */
-#define HAVE_STATIC_TLS(map, sym_map)					\
-    (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET		\
-		       && ((sym_map)->l_tls_offset			\
-			   != FORCED_DYNAMIC_TLS_OFFSET), 1))
-
-#define CHECK_STATIC_TLS(map, sym_map)					\
-    do {								\
-      if (!HAVE_STATIC_TLS (map, sym_map))				\
-	_dl_allocate_static_tls (sym_map);				\
-    } while (0)
-
-#define TRY_STATIC_TLS(map, sym_map)					\
-    (__builtin_expect ((sym_map)->l_tls_offset				\
-		       != FORCED_DYNAMIC_TLS_OFFSET, 1)			\
-     && (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1)	\
-	 || _dl_try_allocate_static_tls (sym_map, true) == 0))
-
-int _dl_try_allocate_static_tls (struct link_map *map, bool optional)
-  attribute_hidden;
-
+#include <dl-machine.h>
 #include <elf.h>
 
 #ifdef RESOLVE_MAP
@@ -91,9 +63,6 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
 # endif
 #endif
 
-#include <dl-machine.h>
-
-
 #ifdef RESOLVE_MAP
 
 # if defined RTLD_BOOTSTRAP || defined STATIC_PIE_BOOTSTRAP
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
index d169099fbc..4a23c32bdb 100644
--- a/elf/get-dynamic-info.h
+++ b/elf/get-dynamic-info.h
@@ -22,6 +22,7 @@
 #define _GET_DYNAMIC_INFO_H
 
 #include <assert.h>
+#include <dl-machine-rel.h>
 #include <libc-diag.h>
 
 static inline void __attribute__ ((unused, always_inline))
diff --git a/elf/rtld.c b/elf/rtld.c
index fe5ee9ec4d..87d94c1a7a 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -32,7 +32,6 @@
 #include <fpu_control.h>
 #include <hp-timing.h>
 #include <libc-lock.h>
-#include "dynamic-link.h"
 #include <dl-librecon.h>
 #include <unsecvars.h>
 #include <dl-cache.h>
@@ -52,6 +51,15 @@
 #include <dl-tunables.h>
 
 #include <assert.h>
+#include "get-dynamic-info.h"
+
+/* This #define produces dynamic linking inline functions for
+   bootstrap relocation instead of general-purpose relocation.
+   Since ld.so must not have any undefined symbols the result
+   is trivial: always the map of ld.so itself.  */
+#define RTLD_BOOTSTRAP
+#define RESOLVE_MAP(map, scope, sym, version, flags) map
+#include "dynamic-link.h"
 
 /* Only enables rtld profiling for architectures which provides non generic
    hp-timing support.  The generic support requires either syscall
@@ -507,15 +515,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
 # define bootstrap_map info.l
 #endif
 
-  /* This #define produces dynamic linking inline functions for
-     bootstrap relocation instead of general-purpose relocation.
-     Since ld.so must not have any undefined symbols the result
-     is trivial: always the map of ld.so itself.  */
-#define RTLD_BOOTSTRAP
-#define RESOLVE_MAP(map, scope, sym, version, flags) map
-#include "get-dynamic-info.h"
-#include "dynamic-link.h"
-
 static ElfW(Addr) __attribute_used__
 _dl_start (void *arg)
 {
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index e30e81c902..e7b91d6530 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 #include <dl-irel.h>
 #include <cpu-features.c>
 
@@ -370,7 +371,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
     }
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr,
 			   const ElfW(Rela) *reloc,
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index 491541326f..b9afa4546f 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -25,7 +25,7 @@
 #define ELF_MACHINE_NAME "alpha"
 
 #include <string.h>
-
+#include <dl-static-tls.h>
 
 /* Mask identifying addresses reserved for the user program,
    where the dynamic linker should not map anything.  */
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
index 4b64ffec25..20496ce1d1 100644
--- a/sysdeps/arc/dl-machine.h
+++ b/sysdeps/arc/dl-machine.h
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <link.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Dynamic Linking ABI for ARCv2 ISA.
 
@@ -318,7 +319,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
     }
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
                            void *const reloc_addr_arg)
@@ -327,7 +328,7 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
   *reloc_addr += l_addr;
 }
 
-inline void
+static inline void
 __attribute__ ((always_inline))
 elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
 		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index dfa05eee44..20c0653e82 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -26,6 +26,7 @@
 #include <tls.h>
 #include <dl-tlsdesc.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #ifndef CLEAR_CACHE
 # error CLEAR_CACHE definition required to handle TEXTREL
diff --git a/sysdeps/csky/dl-machine.h b/sysdeps/csky/dl-machine.h
index ec22f87577..47e8e592d2 100644
--- a/sysdeps/csky/dl-machine.h
+++ b/sysdeps/csky/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero if ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/generic/dl-machine.h b/sysdeps/generic/dl-machine.h
index 4a4ab4fc70..6fc61a2591 100644
--- a/sysdeps/generic/dl-machine.h
+++ b/sysdeps/generic/dl-machine.h
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <link.h>
+#include <dl-static-tls.h>
 
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index e6a4575fce..3a7e20a4a7 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -29,6 +29,7 @@
 #include <dl-fptr.h>
 #include <abort-instr.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* These two definitions must match the definition of the stub in
    bfd/elf32-hppa.c (see plt_stub[]).
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 78bed03eee..94056142e4 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
index 2217d0b556..a53101a02f 100644
--- a/sysdeps/ia64/dl-machine.h
+++ b/sysdeps/ia64/dl-machine.h
@@ -27,6 +27,7 @@
 #include <errno.h>
 #include <dl-fptr.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 5e34c4784e..8e20139c42 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h
index 3fd4988e60..188d3340ee 100644
--- a/sysdeps/microblaze/dl-machine.h
+++ b/sysdeps/microblaze/dl-machine.h
@@ -23,6 +23,7 @@
 
 #include <sys/param.h>
 #include <tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index f8d1298b60..15e8de551b 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -32,6 +32,7 @@
 #include <sysdep.h>
 #include <sys/asm.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* The offset of gp from GOT might be system-dependent.  It's set by
    ld.  The same value is also */
diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h
index 4de602b13d..efc0bcece9 100644
--- a/sysdeps/nios2/dl-machine.h
+++ b/sysdeps/nios2/dl-machine.h
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <link.h>
 #include <dl-tls.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index cda012dc1b..01b18ca536 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -25,6 +25,7 @@
 #include <dl-tls.h>
 #include <dl-irel.h>
 #include <hwcapinfo.h>
+#include <dl-static-tls.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
diff --git a/sysdeps/powerpc/powerpc64/dl-funcdesc.h b/sysdeps/powerpc/powerpc64/dl-funcdesc.h
new file mode 100644
index 0000000000..b2d1f76ce0
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/dl-funcdesc.h
@@ -0,0 +1,34 @@
+/* PowerPC ELFv1 function descriptor definition.
+   Copyright (C) 2009-2021 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_FUNCDESC_H
+#define _DL_FUNCDESC_H
+
+#if _CALL_ELF != 2
+/* A PowerPC64 function descriptor.  The .plt (procedure linkage
+   table) and .opd (official procedure descriptor) sections are
+   arrays of these.  */
+typedef struct
+{
+  Elf64_Addr fd_func;
+  Elf64_Addr fd_toc;
+  Elf64_Addr fd_aux;
+} Elf64_FuncDesc;
+#endif
+
+#endif
diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h
index 0e11b7ff64..aa9a2dca71 100644
--- a/sysdeps/powerpc/powerpc64/dl-irel.h
+++ b/sysdeps/powerpc/powerpc64/dl-irel.h
@@ -23,7 +23,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <ldsodefs.h>
-#include <dl-machine.h>
+#include <dl-funcdesc.h>
 
 #define ELF_MACHINE_IRELA	1
 
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index 3f92fbb369..635cb45dcc 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -28,23 +28,13 @@
 #include <sysdep.h>
 #include <hwcapinfo.h>
 #include <cpu-features.c>
+#include <dl-static-tls.h>
+#include <dl-funcdesc.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
 #define DT_PPC64(x) (DT_PPC64_##x - DT_LOPROC + DT_NUM)
 
-#if _CALL_ELF != 2
-/* A PowerPC64 function descriptor.  The .plt (procedure linkage
-   table) and .opd (official procedure descriptor) sections are
-   arrays of these.  */
-typedef struct
-{
-  Elf64_Addr fd_func;
-  Elf64_Addr fd_toc;
-  Elf64_Addr fd_aux;
-} Elf64_FuncDesc;
-#endif
-
 #define ELF_MULT_MACHINES_SUPPORTED
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index e7289d7ddc..b8fdfde8c0 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sys/asm.h>
 #include <dl-tls.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #ifndef _RTLD_PROLOGUE
 # define _RTLD_PROLOGUE(entry)						\
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
index cd16cc7e00..3c8054ae84 100644
--- a/sysdeps/s390/s390-32/dl-machine.h
+++ b/sysdeps/s390/s390-32/dl-machine.h
@@ -26,6 +26,7 @@
 #include <link.h>
 #include <sysdeps/s390/dl-procinfo.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 /* This is an older, now obsolete value.  */
 #define EM_S390_OLD	0xA390
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
index 0330a8d7de..9d9d0ea0d6 100644
--- a/sysdeps/s390/s390-64/dl-machine.h
+++ b/sysdeps/s390/s390-64/dl-machine.h
@@ -27,6 +27,7 @@
 #include <link.h>
 #include <sysdeps/s390/dl-procinfo.h>
 #include <dl-irel.h>
+#include <dl-static-tls.h>
 
 #define ELF_MACHINE_IRELATIVE       R_390_IRELATIVE
 
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
index 0c22dfd848..96fd894d40 100644
--- a/sysdeps/sh/dl-machine.h
+++ b/sysdeps/sh/dl-machine.h
@@ -24,6 +24,7 @@
 #include <sys/param.h>
 #include <sysdep.h>
 #include <assert.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 6361cfae9e..a59c110460 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -28,6 +28,7 @@
 #include <tls.h>
 #include <dl-plt.h>
 #include <elf/dl-hwcaps.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index 3fd18c6e5e..2289691689 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -26,6 +26,7 @@
 #include <ldsodefs.h>
 #include <sysdep.h>
 #include <dl-plt.h>
+#include <dl-static-tls.h>
 
 #define ELF64_R_TYPE_ID(info)	((info) & 0xff)
 #define ELF64_R_TYPE_DATA(info) ((info) >> 8)
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index db388a022d..72b75d3beb 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -24,7 +24,7 @@
 #include <sysdep-vdso.h>
 
 #if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
-# include <dl-machine.h>
+# include <dl-funcdesc.h>
 /* The correct solution is for _dl_vdso_vsym to return the address of the OPD
    for the kernel VDSO function.  That address would then be stored in the
    __vdso_* variables and returned as the result of the IFUNC resolver function.
diff --git a/sysdeps/x86_64/dl-machine-rel.h b/sysdeps/x86_64/dl-machine-rel.h
new file mode 100644
index 0000000000..3401859f19
--- /dev/null
+++ b/sysdeps/x86_64/dl-machine-rel.h
@@ -0,0 +1,26 @@
+/* Machine-dependent ELF dynamic relocation type.  x86-64 version.
+   Copyright (C) 2001-2021 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_MACHINE_REL_H
+#define _DL_MACHINE_REL_H
+
+/* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations.  */
+#define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
+
+#endif
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 20afb0b4bc..33df0dd5fc 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -26,6 +26,7 @@
 #include <sysdep.h>
 #include <tls.h>
 #include <dl-tlsdesc.h>
+#include <dl-static-tls.h>
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 14:41               ` Adhemerval Zanella
@ 2021-10-13 14:51                 ` Manuel Lauss
  2021-10-13 15:12                   ` Adhemerval Zanella
  2021-10-13 17:28                 ` Szabolcs Nagy
  1 sibling, 1 reply; 12+ messages in thread
From: Manuel Lauss @ 2021-10-13 14:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Szabolcs Nagy, libc-alpha, Fangrui Song

This patch works on x64_64 now, the 32bit x86 build breaks.

Manuel

On Wed, Oct 13, 2021 at 4:41 PM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 13/10/2021 10:55, Manuel Lauss wrote:
> > Applied this patch on top of git head, still same error.
> >
> > Manuel
>
> Sigh, it seems I got the elf_get_dynamic_info() sideways.  Could you check
> this slight modified patch? It is x86_64 only for now.
>
> And I am puzzled why I am not seeing any issues in the environments I am
> checking...
>
> >
> > On Wed, Oct 13, 2021 at 3:47 PM Adhemerval Zanella
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >>
> >> On 13/10/2021 08:56, Adhemerval Zanella wrote:
> >>>
> >>>
> >>> On 13/10/2021 08:44, Adhemerval Zanella wrote:
> >>>>
> >>>>
> >>>> On 13/10/2021 07:58, Adhemerval Zanella wrote:
> >>>>>
> >>>>>
> >>>>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> >>>>>>
> >>>>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
> >>>>>>> [resend with libc-alpha]
> >>>>>>> Hi Adhemerval,
> >>>>>>>
> >>>>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
> >>>>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
> >>>>>>> applications
> >>>>>>> to segfault:
> >>>>>>>
> >>>>>>> Program received signal SIGSEGV, Segmentation fault.
> >>>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
> >>>>>>> rel_addr, value);
> >>>>>>> (gdb) bt
> >>>>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
> >>>>>>> ../sysdeps/x86_64/dl-trampoline.h:126
> >>>>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
> >>>>>>> iconvconfig.c:288
> >>>>>>>
> >>>>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
> >>>>>>> not affected, while for example iconvconfig and openssh are.
> >>>>>>
> >>>>>> on aarch64 buildbot i see
> >>>>>>
> >>>>>> FAIL: nptl/test-cond-printers
> >>>>>> FAIL: nptl/test-condattr-printers
> >>>>>> FAIL: nptl/test-mutex-printers
> >>>>>> FAIL: nptl/test-mutexattr-printers
> >>>>>> FAIL: nptl/test-rwlock-printers
> >>>>>> FAIL: nptl/test-rwlockattr-printers
> >>>>>>
> >>>>>> and
> >>>>>>
> >>>>>> $ cat nptl/test-cond-printers.out
> >>>>>> Error: Response does not match the expected pattern.
> >>>>>> Command: start
> >>>>>> Expected pattern: main
> >>>>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
> >>>>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
> >>>>>>
> >>>>>> Program received signal SIGSEGV, Segmentation fault.
> >>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
> >>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
> >>>>>> (gdb)
> >>>>>>
> >>>>>>
> >>>>>> it seems to be a bind-now pie where PLT relocs are not yet
> >>>>>> processed when __libc_start_main is called but PLTGOT is
> >>>>>> already marked readonly so _dl_fixup crashes.
> >>>>>
> >>>>> I will check this out.
> >>>>>
> >>>>
> >>>> I am trying to reproduce it on aarch64-linux-gnu without much success (using
> >>>> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
> >>>> when running through the built glibc (using ubuntu 21.04 one).
> >>>>
> >>>> Any idea on how to reproduce it?
> >>>>
> >>>
> >>> Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
> >>> elf_get_dynamic_info(), but there are lot of more usage that changes
> >>> the semantic of the nested functions (specifically on elf/do-rel.h
> >>> and dl-machine.h).
> >>>
> >>> I will try to fix, I think we should define RTLD_BOOTSTRAP before the
> >>> fist dynamic-link.h in rtld.
> >>>
> >>
> >> Could you check if the attached patch fixes it?  The rtld.c now should get
> >> all the required function with the expected semantic (RTLD_BOOTSTRAP defined).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 14:51                 ` Manuel Lauss
@ 2021-10-13 15:12                   ` Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 15:12 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: Szabolcs Nagy, libc-alpha, Fangrui Song



On 13/10/2021 11:51, Manuel Lauss wrote:
> This patch works on x64_64 now, the 32bit x86 build breaks.

Thanks for checking it, I know what I got wrong in first place.
The 32-bit break is expected, I added only x86_64 support.  I will
prepare a patch to work on all architectures and run make check
on the architecture I have available.

> 
> Manuel
> 
> On Wed, Oct 13, 2021 at 4:41 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 13/10/2021 10:55, Manuel Lauss wrote:
>>> Applied this patch on top of git head, still same error.
>>>
>>> Manuel
>>
>> Sigh, it seems I got the elf_get_dynamic_info() sideways.  Could you check
>> this slight modified patch? It is x86_64 only for now.
>>
>> And I am puzzled why I am not seeing any issues in the environments I am
>> checking...
>>
>>>
>>> On Wed, Oct 13, 2021 at 3:47 PM Adhemerval Zanella
>>> <adhemerval.zanella@linaro.org> wrote:
>>>>
>>>>
>>>>
>>>> On 13/10/2021 08:56, Adhemerval Zanella wrote:
>>>>>
>>>>>
>>>>> On 13/10/2021 08:44, Adhemerval Zanella wrote:
>>>>>>
>>>>>>
>>>>>> On 13/10/2021 07:58, Adhemerval Zanella wrote:
>>>>>>>
>>>>>>>
>>>>>>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>>>>>>
>>>>>>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote:
>>>>>>>>> [resend with libc-alpha]
>>>>>>>>> Hi Adhemerval,
>>>>>>>>>
>>>>>>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix
>>>>>>>>> elf_get_dynamic_info definition")  causes a lot (but not all) of my
>>>>>>>>> applications
>>>>>>>>> to segfault:
>>>>>>>>>
>>>>>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc,
>>>>>>>>> rel_addr, value);
>>>>>>>>> (gdb) bt
>>>>>>>>> #0  _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>>>>> #1  0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at
>>>>>>>>> ../sysdeps/x86_64/dl-trampoline.h:126
>>>>>>>>> #2  0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at
>>>>>>>>> iconvconfig.c:288
>>>>>>>>>
>>>>>>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be
>>>>>>>>> not affected, while for example iconvconfig and openssh are.
>>>>>>>>
>>>>>>>> on aarch64 buildbot i see
>>>>>>>>
>>>>>>>> FAIL: nptl/test-cond-printers
>>>>>>>> FAIL: nptl/test-condattr-printers
>>>>>>>> FAIL: nptl/test-mutex-printers
>>>>>>>> FAIL: nptl/test-mutexattr-printers
>>>>>>>> FAIL: nptl/test-rwlock-printers
>>>>>>>> FAIL: nptl/test-rwlockattr-printers
>>>>>>>>
>>>>>>>> and
>>>>>>>>
>>>>>>>> $ cat nptl/test-cond-printers.out
>>>>>>>> Error: Response does not match the expected pattern.
>>>>>>>> Command: start
>>>>>>>> Expected pattern: main
>>>>>>>> Response:  Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36.
>>>>>>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers
>>>>>>>>
>>>>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>>>>> _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at dl-runtime.c:146
>>>>>>>> 146       return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
>>>>>>>> (gdb)
>>>>>>>>
>>>>>>>>
>>>>>>>> it seems to be a bind-now pie where PLT relocs are not yet
>>>>>>>> processed when __libc_start_main is called but PLTGOT is
>>>>>>>> already marked readonly so _dl_fixup crashes.
>>>>>>>
>>>>>>> I will check this out.
>>>>>>>
>>>>>>
>>>>>> I am trying to reproduce it on aarch64-linux-gnu without much success (using
>>>>>> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails
>>>>>> when running through the built glibc (using ubuntu 21.04 one).
>>>>>>
>>>>>> Any idea on how to reproduce it?
>>>>>>
>>>>>
>>>>> Sigh... I think this is another fallback of RTLD_BOOTSTRAP.  I fixed the
>>>>> elf_get_dynamic_info(), but there are lot of more usage that changes
>>>>> the semantic of the nested functions (specifically on elf/do-rel.h
>>>>> and dl-machine.h).
>>>>>
>>>>> I will try to fix, I think we should define RTLD_BOOTSTRAP before the
>>>>> fist dynamic-link.h in rtld.
>>>>>
>>>>
>>>> Could you check if the attached patch fixes it?  The rtld.c now should get
>>>> all the required function with the expected semantic (RTLD_BOOTSTRAP defined).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 14:41               ` Adhemerval Zanella
  2021-10-13 14:51                 ` Manuel Lauss
@ 2021-10-13 17:28                 ` Szabolcs Nagy
  2021-10-13 18:15                   ` Adhemerval Zanella
  1 sibling, 1 reply; 12+ messages in thread
From: Szabolcs Nagy @ 2021-10-13 17:28 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Manuel Lauss, libc-alpha, Fangrui Song

The 10/13/2021 11:41, Adhemerval Zanella wrote:
> 
> 
> On 13/10/2021 10:55, Manuel Lauss wrote:
> > Applied this patch on top of git head, still same error.
> > 
> > Manuel
> 
> Sigh, it seems I got the elf_get_dynamic_info() sideways.  Could you check
> this slight modified patch? It is x86_64 only for now.

on aarch64 i get

get-dynamic-info.h:25:10: fatal error: dl-machine-rel.h: No such file or directory
 #include <dl-machine-rel.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

> 
> And I am puzzled why I am not seeing any issues in the environments I am
> checking...

i use a stock ubuntu toolchain: that's pie by default
and i think bind-now too.

the previous patch still has the same failures

FAIL: nptl/test-cond-printers
FAIL: nptl/test-condattr-printers
FAIL: nptl/test-mutex-printers
FAIL: nptl/test-mutexattr-printers
FAIL: nptl/test-rwlock-printers
FAIL: nptl/test-rwlockattr-printers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: segfaults in _dl_fixup since 4af6982
  2021-10-13 17:28                 ` Szabolcs Nagy
@ 2021-10-13 18:15                   ` Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2021-10-13 18:15 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Manuel Lauss, libc-alpha, Fangrui Song



On 13/10/2021 14:28, Szabolcs Nagy wrote:
> The 10/13/2021 11:41, Adhemerval Zanella wrote:
>>
>>
>> On 13/10/2021 10:55, Manuel Lauss wrote:
>>> Applied this patch on top of git head, still same error.
>>>
>>> Manuel
>>
>> Sigh, it seems I got the elf_get_dynamic_info() sideways.  Could you check
>> this slight modified patch? It is x86_64 only for now.
> 
> on aarch64 i get
> 
> get-dynamic-info.h:25:10: fatal error: dl-machine-rel.h: No such file or directory
>  #include <dl-machine-rel.h>
>           ^~~~~~~~~~~~~~~~~~
> compilation terminated.

Yeah, it was x86_64 only as I put originaly.  I am wrapping up the patch that
should cover all architectures. 

> 
>>
>> And I am puzzled why I am not seeing any issues in the environments I am
>> checking...
> 
> i use a stock ubuntu toolchain: that's pie by default
> and i think bind-now too.
> 
> the previous patch still has the same failures
> 
> FAIL: nptl/test-cond-printers
> FAIL: nptl/test-condattr-printers
> FAIL: nptl/test-mutex-printers
> FAIL: nptl/test-mutexattr-printers
> FAIL: nptl/test-rwlock-printers
> FAIL: nptl/test-rwlockattr-printers
> 

I would expect it since it did not addressed the issue :/.  But thanks
for checking it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-10-13 18:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAOLZvyH+V0TokSzHumaxJF9JA=Kxoxh2NVr+ZZbdBD5qZ-urZg@mail.gmail.com>
2021-10-13  6:42 ` Fwd: segfaults in _dl_fixup since 4af6982 Manuel Lauss
2021-10-13  9:18   ` Szabolcs Nagy
2021-10-13 10:58     ` Adhemerval Zanella
2021-10-13 11:44       ` Adhemerval Zanella
2021-10-13 11:56         ` Adhemerval Zanella
2021-10-13 13:46           ` Adhemerval Zanella
2021-10-13 13:55             ` Manuel Lauss
2021-10-13 14:41               ` Adhemerval Zanella
2021-10-13 14:51                 ` Manuel Lauss
2021-10-13 15:12                   ` Adhemerval Zanella
2021-10-13 17:28                 ` Szabolcs Nagy
2021-10-13 18:15                   ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).