[2/2] Only provide non-default symbols in libpthread for vfork
diff mbox

Message ID 1400886936-16338-3-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson May 23, 2014, 11:15 p.m. UTC
* nptl/pt-vfork.c (vfork_resolve): Rename from vfork_ifunc.
	(vfork_ifunc): Define via attribute ifunc.
	(DEFINE_VFORK): Remove.
	(vfork, __vfork): Define via compat_symbol.
---
 nptl/pt-vfork.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

Comments

Roland McGrath May 24, 2014, 2:30 a.m. UTC | #1
We need to separately decide about if/how we want to rely on the attribute
support as I mentioned a moment ago in the other thread.  But to proceed as
if we'll decide to rely on the attribute in all our IFUNC-defining C code:

> +void *vfork_ifunc(void *, const void *, size_t)
> +     __attribute__ ((ifunc ("vfork_resolve")));

What in carnation is that signature?  (And it needs a space.)
A pasto from a memcpy implementation, I guess?

Does it not work to do:
	__typeof (vfork) vfork_ifunc __attribute__ ((ifunc ("vfork_resolve")));
?

Obviously this case has the most trivial of signatures.  But I'm thinking
about if we can maybe define a macro or two for this stuff and clean up
all our IFUNC stuff to look actually somewhat pretty.

>  #if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
> -DEFINE_VFORK (__vfork)
> +strong_alias (vfork_ifunc, vfork_ifunc2)
> +compat_symbol (libpthread, vfork_ifunc2, __vfork, GLIBC_2_1_2);
>  #endif

For some reason "ifunc2" just really irks me.  I'd rather see
__vfork_ifunc, as if we had a straightforward convention that the
STV_HIDDEN name of foo's IFUNC symbol is foo_ifunc.


Thanks,
Roland

Patch
diff mbox

diff --git a/nptl/pt-vfork.c b/nptl/pt-vfork.c
index 8beb121..78c0781 100644
--- a/nptl/pt-vfork.c
+++ b/nptl/pt-vfork.c
@@ -42,30 +42,21 @@ 
 
 extern __typeof (vfork) __libc_vfork;   /* Defined in libc.  */
 
-attribute_hidden __attribute__ ((used))
-__typeof (vfork) *
-vfork_ifunc (void)
+static __typeof (vfork) *
+vfork_resolve (void)
 {
   return &__libc_vfork;
 }
 
-# ifdef HAVE_ASM_SET_DIRECTIVE
-#  define DEFINE_VFORK(name) \
-  asm (".set " #name ", vfork_ifunc\n" \
-       ".globl " #name "\n" \
-       ".type " #name ", %gnu_indirect_function");
-# else
-#  define DEFINE_VFORK(name) \
-  asm (#name " = vfork_ifunc\n" \
-       ".globl " #name "\n" \
-       ".type " #name ", %gnu_indirect_function");
-# endif
+void *vfork_ifunc(void *, const void *, size_t)
+     __attribute__ ((ifunc ("vfork_resolve")));
 #endif
 
 #if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
-DEFINE_VFORK (vfork)
+compat_symbol (libpthread, vfork_ifunc, vfork, GLIBC_2_0);
 #endif
 
 #if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
-DEFINE_VFORK (__vfork)
+strong_alias (vfork_ifunc, vfork_ifunc2)
+compat_symbol (libpthread, vfork_ifunc2, __vfork, GLIBC_2_1_2);
 #endif