b8fef8
b8fef8
2012-03-07  Jeff Law  <law@redhat.com>
b8fef8
b8fef8
	* elf/dl-reloc.c (_dl_relocate_object): Move code to allocate
b8fef8
	l_reloc_result prior to calling ELF_DYNAMIC_RELOCATE.
b8fef8
b8fef8
diff -rup a/elf/dl-reloc.c b/elf/dl-reloc.c
b8fef8
--- a/elf/dl-reloc.c	2012-01-01 05:16:32.000000000 -0700
b8fef8
+++ b/elf/dl-reloc.c	2012-03-06 15:41:56.486242640 -0700
b8fef8
@@ -238,32 +238,9 @@ _dl_relocate_object (struct link_map *l,
b8fef8
     /* String table object symbols.  */
b8fef8
     const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
b8fef8
 
b8fef8
-    /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
b8fef8
-#define RESOLVE_MAP(ref, version, r_type) \
b8fef8
-    (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL			      \
b8fef8
-     ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0)		      \
b8fef8
-	 && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
b8fef8
-	? (bump_num_cache_relocations (),				      \
b8fef8
-	   (*ref) = l->l_lookup_cache.ret,				      \
b8fef8
-	   l->l_lookup_cache.value)					      \
b8fef8
-	: ({ lookup_t _lr;						      \
b8fef8
-	     int _tc = elf_machine_type_class (r_type);			      \
b8fef8
-	     l->l_lookup_cache.type_class = _tc;			      \
b8fef8
-	     l->l_lookup_cache.sym = (*ref);				      \
b8fef8
-	     const struct r_found_version *v = NULL;			      \
b8fef8
-	     if ((version) != NULL && (version)->hash != 0)		      \
b8fef8
-	       v = (version);						      \
b8fef8
-	     _lr = _dl_lookup_symbol_x (strtab + (*ref)->st_name, l, (ref),   \
b8fef8
-					scope, v, _tc,			      \
b8fef8
-					DL_LOOKUP_ADD_DEPENDENCY, NULL);      \
b8fef8
-	     l->l_lookup_cache.ret = (*ref);				      \
b8fef8
-	     l->l_lookup_cache.value = _lr; }))				      \
b8fef8
-     : l)
b8fef8
-
b8fef8
-#include "dynamic-link.h"
b8fef8
-
b8fef8
-    ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
b8fef8
-
b8fef8
+    /* ELF_DYNAMIC_RELOCATE may need to examine l_reloc_result
b8fef8
+       when handling MACHINE_IRELATIVE relocs.  So we must
b8fef8
+       allocate l_reloc_result prior to calling ELF_DYNAMIC_RELOCATE.  */
b8fef8
 #ifndef PROF
b8fef8
     if (__builtin_expect (consider_profiling, 0))
b8fef8
       {
b8fef8
@@ -290,6 +267,32 @@ _dl_relocate_object (struct link_map *l,
b8fef8
 	  }
b8fef8
       }
b8fef8
 #endif
b8fef8
+
b8fef8
+    /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
b8fef8
+#define RESOLVE_MAP(ref, version, r_type) \
b8fef8
+    (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL			      \
b8fef8
+     ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0)		      \
b8fef8
+	 && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
b8fef8
+	? (bump_num_cache_relocations (),				      \
b8fef8
+	   (*ref) = l->l_lookup_cache.ret,				      \
b8fef8
+	   l->l_lookup_cache.value)					      \
b8fef8
+	: ({ lookup_t _lr;						      \
b8fef8
+	     int _tc = elf_machine_type_class (r_type);			      \
b8fef8
+	     l->l_lookup_cache.type_class = _tc;			      \
b8fef8
+	     l->l_lookup_cache.sym = (*ref);				      \
b8fef8
+	     const struct r_found_version *v = NULL;			      \
b8fef8
+	     if ((version) != NULL && (version)->hash != 0)		      \
b8fef8
+	       v = (version);						      \
b8fef8
+	     _lr = _dl_lookup_symbol_x (strtab + (*ref)->st_name, l, (ref),   \
b8fef8
+					scope, v, _tc,			      \
b8fef8
+					DL_LOOKUP_ADD_DEPENDENCY, NULL);      \
b8fef8
+	     l->l_lookup_cache.ret = (*ref);				      \
b8fef8
+	     l->l_lookup_cache.value = _lr; }))				      \
b8fef8
+     : l)
b8fef8
+
b8fef8
+#include "dynamic-link.h"
b8fef8
+
b8fef8
+    ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
b8fef8
   }
b8fef8
 
b8fef8
   /* Mark the object so we know this work has been done.  */