···
1
+
From f06f3f05b48c72e2c9b0fa78671f94fd22d67da8 Mon Sep 17 00:00:00 2001
2
+
From: Florian Weimer <fweimer@redhat.com>
3
+
Date: Wed, 1 Jun 2016 07:14:42 +0200
4
+
Subject: [PATCH] fork in libpthread cannot use IFUNC resolver [BZ #19861]
6
+
This commit only addresses the fork case, the vfork case has to be a
7
+
tail call, which is why the generic code needs an IFUNC resolver
10
+
diff --git a/nptl/pt-fork.c b/nptl/pt-fork.c
11
+
index b65d6b4..db9b61d 100644
12
+
--- a/nptl/pt-fork.c
13
+
+++ b/nptl/pt-fork.c
15
+
the historical ABI requires it. For static linking, there is no need to
16
+
provide anything here--the libc version will be linked in. For shared
17
+
library ABI compatibility, there must be __fork and fork symbols in
18
+
- libpthread.so; so we define them using IFUNC to redirect to the libc
22
+
-#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
26
+
-static __typeof (fork) *
27
+
-__attribute__ ((used))
28
+
-fork_resolve (void)
30
+
- return &__libc_fork;
32
+
+ With an IFUNC resolver, it would be possible to avoid the
33
+
+ indirection, but the IFUNC resolver might run before the
34
+
+ __libc_fork symbol has been relocated, in which case the IFUNC
35
+
+ resolver would not be able to provide the correct address. */
37
+
-# ifdef HAVE_ASM_SET_DIRECTIVE
38
+
-# define DEFINE_FORK(name) \
39
+
- asm (".set " #name ", fork_resolve\n" \
40
+
- ".globl " #name "\n" \
41
+
- ".type " #name ", %gnu_indirect_function");
43
+
-# define DEFINE_FORK(name) \
44
+
- asm (#name " = fork_resolve\n" \
45
+
- ".globl " #name "\n" \
46
+
- ".type " #name ", %gnu_indirect_function");
49
+
-# else /* !HAVE_IFUNC */
50
+
+#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
52
+
static pid_t __attribute__ ((used))
54
+
@@ -59,14 +40,10 @@ fork_compat (void)
55
+
return __libc_fork ();
58
+
-# define DEFINE_FORK(name) strong_alias (fork_compat, name)
60
+
-# endif /* HAVE_IFUNC */
62
+
-DEFINE_FORK (fork_ifunc)
63
+
-compat_symbol (libpthread, fork_ifunc, fork, GLIBC_2_0);
64
+
+strong_alias (fork_compat, fork_alias)
65
+
+compat_symbol (libpthread, fork_alias, fork, GLIBC_2_0);
67
+
-DEFINE_FORK (__fork_ifunc)
68
+
-compat_symbol (libpthread, __fork_ifunc, __fork, GLIBC_2_0);
69
+
+strong_alias (fork_compat, __fork_alias)
70
+
+compat_symbol (libpthread, __fork_alias, __fork, GLIBC_2_0);