summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2009-10-30 16:11:14 +0100
committerAndreas Schwab <schwab@redhat.com>2009-10-30 16:11:14 +0100
commit017dd87448e913383a8be5773569f218e8c661c5 (patch)
treed9124fdbb290416e60553c87aa9f9f1750d7acb8 /elf
parentf8e81cec78280ef92014305c1e10a808b1260683 (diff)
parent3a83202db6e5591f2b72974c1ad98602c6620770 (diff)
downloadglibc-017dd87448e913383a8be5773569f218e8c661c5.tar.gz
glibc-017dd87448e913383a8be5773569f218e8c661c5.tar.xz
glibc-017dd87448e913383a8be5773569f218e8c661c5.zip
Merge remote branch 'origin/master' into fedora/master
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-sym.c5
-rw-r--r--elf/elf.h23
-rw-r--r--elf/ifuncdep2.c34
-rw-r--r--elf/ifuncmain1.c2
-rw-r--r--elf/ifuncmain1vis.c2
-rw-r--r--elf/ifuncmain2.c2
-rw-r--r--elf/ifuncmain5.c2
-rw-r--r--elf/ifuncmain6pie.c3
-rw-r--r--elf/ifuncmain7.c3
-rw-r--r--elf/ifuncmod1.c41
-rw-r--r--elf/ifuncmod3.c1
-rw-r--r--elf/ifuncmod5.c33
12 files changed, 43 insertions, 108 deletions
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 740bb9a892..459729f0f2 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -191,6 +191,11 @@ RTLD_NEXT used in code not dynamically loaded"));
 #endif
 	value = DL_SYMBOL_ADDRESS (result, ref);
 
+      /* 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)) ();
+
 #ifdef SHARED
       /* Auditing checkpoint: we have a new binding.  Provide the
 	 auditing libraries the possibility to change the value and
diff --git a/elf/elf.h b/elf/elf.h
index ce6de07e91..c772ff41ad 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -2041,9 +2041,6 @@ typedef Elf32_Addr Elf32_Conflict;
 #define R_PPC_GOT_DTPREL16_HI	93 /* half16*	(sym+add)@got@dtprel@h */
 #define R_PPC_GOT_DTPREL16_HA	94 /* half16*	(sym+add)@got@dtprel@ha */
 
-/* Keep this the last entry.  */
-#define R_PPC_NUM		95
-
 /* The remaining relocs are from the Embedded ELF ABI, and are not
    in the SVR4 ELF ABI.  */
 #define R_PPC_EMB_NADDR32	101
@@ -2071,11 +2068,14 @@ typedef Elf32_Addr Elf32_Conflict;
 #define R_PPC_DIAB_RELSDA_HI	184	/* like EMB_RELSDA, but high 16 bit */
 #define R_PPC_DIAB_RELSDA_HA	185	/* like EMB_RELSDA, adjusted high 16 */
 
+/* GNU extension to support local ifunc.  */
+#define R_PPC_IRELATIVE		248
+
 /* GNU relocs used in PIC code sequences.  */
-#define R_PPC_REL16		249	/* word32   (sym-.) */
-#define R_PPC_REL16_LO		250	/* half16   (sym-.)@l */
-#define R_PPC_REL16_HI		251	/* half16   (sym-.)@h */
-#define R_PPC_REL16_HA		252	/* half16   (sym-.)@ha */
+#define R_PPC_REL16		249	/* half16   (sym+add-.) */
+#define R_PPC_REL16_LO		250	/* half16   (sym+add-.)@l */
+#define R_PPC_REL16_HI		251	/* half16   (sym+add-.)@h */
+#define R_PPC_REL16_HA		252	/* half16   (sym+add-.)@ha */
 
 /* This is a phony reloc to handle any old fashioned TOC16 references
    that may still be in object files.  */
@@ -2197,8 +2197,13 @@ typedef Elf32_Addr Elf32_Conflict;
 #define R_PPC64_DTPREL16_HIGHEST 105 /* half16	(sym+add)@dtprel@highest */
 #define R_PPC64_DTPREL16_HIGHESTA 106 /* half16	(sym+add)@dtprel@highesta */
 
-/* Keep this the last entry.  */
-#define R_PPC64_NUM		107
+/* GNU extension to support local ifunc.  */
+#define R_PPC64_JMP_IREL	247
+#define R_PPC64_IRELATIVE	248
+#define R_PPC64_REL16		249	/* half16   (sym+add-.) */
+#define R_PPC64_REL16_LO	250	/* half16   (sym+add-.)@l */
+#define R_PPC64_REL16_HI	251	/* half16   (sym+add-.)@h */
+#define R_PPC64_REL16_HA	252	/* half16   (sym+add-.)@ha */
 
 /* PowerPC64 specific values for the Dyn d_tag field.  */
 #define DT_PPC64_GLINK  (DT_LOPROC + 0)
diff --git a/elf/ifuncdep2.c b/elf/ifuncdep2.c
index fb21eef5cb..758bae1932 100644
--- a/elf/ifuncdep2.c
+++ b/elf/ifuncdep2.c
@@ -1,6 +1,8 @@
 /* Test 3 STT_GNU_IFUNC symbols.  */
 
-extern int global;
+#include "ifunc-sel.h"
+
+int global __attribute__ ((visibility ("protected"))) = -1;
 
 static int
 one (void)
@@ -26,15 +28,7 @@ __asm__(".type foo1, %gnu_indirect_function");
 void * 
 foo1_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return minus_one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (one, minus_one, zero);
 }
 
 void * foo2_ifunc (void) __asm__ ("foo2");
@@ -43,15 +37,7 @@ __asm__(".type foo2, %gnu_indirect_function");
 void * 
 foo2_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return minus_one;
-    case -1:
-      return one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (minus_one, one, zero);
 }
 
 void * foo3_ifunc (void) __asm__ ("foo3");
@@ -60,13 +46,5 @@ __asm__(".type foo3, %gnu_indirect_function");
 void * 
 foo3_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return zero;
-    default:
-      return minus_one;
-    }
+  return ifunc_sel (one, zero, minus_one);
 }
diff --git a/elf/ifuncmain1.c b/elf/ifuncmain1.c
index de7ffe8779..cc1e5ec5ba 100644
--- a/elf/ifuncmain1.c
+++ b/elf/ifuncmain1.c
@@ -7,8 +7,6 @@
 
 #include <stdlib.h>
 
-int global = -1;
-
 int ret_foo;
 int ret_foo_hidden;
 int ret_foo_protected;
diff --git a/elf/ifuncmain1vis.c b/elf/ifuncmain1vis.c
index a239d2dd0d..81cd12288e 100644
--- a/elf/ifuncmain1vis.c
+++ b/elf/ifuncmain1vis.c
@@ -7,8 +7,6 @@
 
 #include <stdlib.h>
 
-int global = -1;
-
 int ret_foo;
 int ret_foo_hidden;
 int ret_foo_protected;
diff --git a/elf/ifuncmain2.c b/elf/ifuncmain2.c
index cd9b2c8352..db3ba56a02 100644
--- a/elf/ifuncmain2.c
+++ b/elf/ifuncmain2.c
@@ -3,8 +3,6 @@
 
 #include <stdlib.h>
 
-int global = -1;
-
 extern int foo1 (void);
 
 int
diff --git a/elf/ifuncmain5.c b/elf/ifuncmain5.c
index 7f128d006e..f398085cb4 100644
--- a/elf/ifuncmain5.c
+++ b/elf/ifuncmain5.c
@@ -2,8 +2,6 @@
 
 #include <stdlib.h>
 
-int global = -1;
-
 extern int foo (void);
 extern int foo_protected (void);
 
diff --git a/elf/ifuncmain6pie.c b/elf/ifuncmain6pie.c
index 06f179bf9d..8478d4c408 100644
--- a/elf/ifuncmain6pie.c
+++ b/elf/ifuncmain6pie.c
@@ -6,6 +6,7 @@
  */
 
 #include <stdlib.h>
+#include "ifunc-sel.h"
 
 typedef int (*foo_p) (void);
 extern foo_p foo_ptr;
@@ -22,7 +23,7 @@ __asm__(".type foo, %gnu_indirect_function");
 void *
 foo_ifunc (void)
 {
-  return one;
+  return ifunc_one (one);
 }
 
 extern int foo (void);
diff --git a/elf/ifuncmain7.c b/elf/ifuncmain7.c
index 099e929ffc..617a596d5e 100644
--- a/elf/ifuncmain7.c
+++ b/elf/ifuncmain7.c
@@ -5,6 +5,7 @@
  */
 
 #include <stdlib.h>
+#include "ifunc-sel.h"
 
 extern int foo (void);
 
@@ -21,7 +22,7 @@ static void *
 __attribute__ ((used))
 foo_ifunc (void)
 {
-  return one;
+  return ifunc_one (one);
 }
 
 typedef int (*foo_p) (void);
diff --git a/elf/ifuncmod1.c b/elf/ifuncmod1.c
index a1697b596d..2b8195ce55 100644
--- a/elf/ifuncmod1.c
+++ b/elf/ifuncmod1.c
@@ -4,8 +4,9 @@
    2. Function pointer.
    3. Visibility.
  */
+#include "ifunc-sel.h"
 
-extern int global;
+int global __attribute__ ((visibility ("protected"))) = -1;
 
 static int
 one (void)
@@ -20,7 +21,7 @@ minus_one (void)
 }
 
 static int
-zero (void) 
+zero (void)
 {
   return 0;
 }
@@ -28,52 +29,28 @@ zero (void)
 void * foo_ifunc (void) __asm__ ("foo");
 __asm__(".type foo, %gnu_indirect_function");
 
-void * 
+void *
 foo_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return minus_one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (one, minus_one, zero);
 }
 
 void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
 __asm__(".type foo_hidden, %gnu_indirect_function");
 
-void * 
+void *
 foo_hidden_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return minus_one;
-    case -1:
-      return one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (minus_one, one, zero);
 }
 
 void * foo_protected_ifunc (void) __asm__ ("foo_protected");
 __asm__(".type foo_protected, %gnu_indirect_function");
 
-void * 
+void *
 foo_protected_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return zero;
-    default:
-      return minus_one;
-    }
+  return ifunc_sel (one, zero, minus_one);
 }
 
 /* Test hidden indirect function.  */
diff --git a/elf/ifuncmod3.c b/elf/ifuncmod3.c
index 379d2c8d53..ca2d962600 100644
--- a/elf/ifuncmod3.c
+++ b/elf/ifuncmod3.c
@@ -5,4 +5,3 @@
 int ret_foo;
 int ret_foo_hidden;
 int ret_foo_protected;
-int global = -1;
diff --git a/elf/ifuncmod5.c b/elf/ifuncmod5.c
index 2ca1c71541..9a08e8cf53 100644
--- a/elf/ifuncmod5.c
+++ b/elf/ifuncmod5.c
@@ -1,6 +1,7 @@
 /* Test STT_GNU_IFUNC symbols without direct function call.  */
+#include "ifunc-sel.h"
 
-extern int global;
+int global __attribute__ ((visibility ("protected"))) = -1;
 
 static int
 one (void)
@@ -26,15 +27,7 @@ __asm__(".type foo, %gnu_indirect_function");
 void *
 foo_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return minus_one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (one, minus_one, zero);
 }
 
 void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
@@ -43,15 +36,7 @@ __asm__(".type foo_hidden, %gnu_indirect_function");
 void *
 foo_hidden_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return minus_one;
-    case -1:
-      return one;
-    default:
-      return zero;
-    }
+  return ifunc_sel (minus_one, one, zero);
 }
 
 void * foo_protected_ifunc (void) __asm__ ("foo_protected");
@@ -60,15 +45,7 @@ __asm__(".type foo_protected, %gnu_indirect_function");
 void *
 foo_protected_ifunc (void)
 {
-  switch (global)
-    {
-    case 1:
-      return one;
-    case -1:
-      return zero;
-    default:
-      return minus_one;
-    }
+  return ifunc_sel (one, zero, minus_one);
 }
 
 /* Test hidden indirect function.  */