Properly handle STT_GNU_IFUNC symbols in do_sym.
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 6 Nov 2009 17:30:56 +0000 (09:30 -0800)
committerUlrich Drepper <drepper@redhat.com>
Fri, 6 Nov 2009 17:30:56 +0000 (09:30 -0800)
do_sym should use DL_FIXUP_VALUE_XXX macros to call IFUNC function.
Otherwise, it won't compile on ia64. This patch fixes it and adds
a test.

ChangeLog
elf/dl-sym.c
elf/ifuncmain3.c

index 03efd6c..a555225 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf/dl-sym.c (do_sym): Properly handle STT_GNU_IFUNC symbols.
+       * elf/ifuncmain3.c (main): Test dlopen STT_GNU_IFUNC symbol.
+
 2009-11-03  Andreas Schwab  <schwab@redhat.com>
 
        * sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Add
index 459729f..0fa3b3a 100644 (file)
@@ -193,8 +193,13 @@ RTLD_NEXT used in code not dynamically loaded"));
 
       /* Resolve indirect function address.  */
       if (__builtin_expect (ELFW(ST_TYPE) (ref->st_info) == STT_GNU_IFUNC, 0))
-       value
-         = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (value)) ();
+       {
+         DL_FIXUP_VALUE_TYPE fixup
+           = DL_FIXUP_MAKE_VALUE (result, (ElfW(Addr)) value);
+         fixup = 
+           ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (fixup)) ();
+         value = (void *) DL_FIXUP_VALUE_CODE_ADDR (fixup);
+       }
 
 #ifdef SHARED
       /* Auditing checkpoint: we have a new binding.  Provide the
index 5d067cc..1574dd5 100644 (file)
@@ -46,6 +46,15 @@ main (void)
       return 1;
     }
 
+  p = dlsym (h, "foo");
+  if (p == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+  if ((*p) () != -1)
+    abort ();
+
   f = dlsym (h, "get_foo_p");
   if (f == NULL)
     {