Fix LD_PROFILE
authorAnas Nashif <anas.nashif@intel.com>
Mon, 24 Dec 2012 02:26:15 +0000 (18:26 -0800)
committerChanho Park <chanho61.park@samsung.com>
Tue, 10 Feb 2015 08:54:39 +0000 (17:54 +0900)
glibc bug#13818

elf/dl-reloc.c

index 9c2705d..427144e 100644 (file)
@@ -237,32 +237,9 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
     /* String table object symbols.  */
     const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 
-    /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
-#define RESOLVE_MAP(ref, version, r_type) \
-    (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL                            \
-     ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0)               \
-        && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
-       ? (bump_num_cache_relocations (),                                     \
-          (*ref) = l->l_lookup_cache.ret,                                    \
-          l->l_lookup_cache.value)                                           \
-       : ({ lookup_t _lr;                                                    \
-            int _tc = elf_machine_type_class (r_type);                       \
-            l->l_lookup_cache.type_class = _tc;                              \
-            l->l_lookup_cache.sym = (*ref);                                  \
-            const struct r_found_version *v = NULL;                          \
-            if ((version) != NULL && (version)->hash != 0)                   \
-              v = (version);                                                 \
-            _lr = _dl_lookup_symbol_x (strtab + (*ref)->st_name, l, (ref),   \
-                                       scope, v, _tc,                        \
-                                       DL_LOOKUP_ADD_DEPENDENCY, NULL);      \
-            l->l_lookup_cache.ret = (*ref);                                  \
-            l->l_lookup_cache.value = _lr; }))                               \
-     : l)
-
-#include "dynamic-link.h"
-
-    ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
-
+    /* ELF_DYNAMIC_RELOCATE may need to examine l_reloc_result
+       when handling MACHINE_IRELATIVE relocs.  So we must
+       allocate l_reloc_result prior to calling ELF_DYNAMIC_RELOCATE.  */
 #ifndef PROF
     if (__glibc_unlikely (consider_profiling))
       {
@@ -293,6 +270,32 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
          }
       }
 #endif
+
+    /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
+#define RESOLVE_MAP(ref, version, r_type) \
+    (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL                            \
+     ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0)               \
+        && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
+       ? (bump_num_cache_relocations (),                                     \
+          (*ref) = l->l_lookup_cache.ret,                                    \
+          l->l_lookup_cache.value)                                           \
+       : ({ lookup_t _lr;                                                    \
+            int _tc = elf_machine_type_class (r_type);                       \
+            l->l_lookup_cache.type_class = _tc;                              \
+            l->l_lookup_cache.sym = (*ref);                                  \
+            const struct r_found_version *v = NULL;                          \
+            if ((version) != NULL && (version)->hash != 0)                   \
+              v = (version);                                                 \
+            _lr = _dl_lookup_symbol_x (strtab + (*ref)->st_name, l, (ref),   \
+                                       scope, v, _tc,                        \
+                                       DL_LOOKUP_ADD_DEPENDENCY, NULL);      \
+            l->l_lookup_cache.ret = (*ref);                                  \
+            l->l_lookup_cache.value = _lr; }))                               \
+     : l)
+
+#include "dynamic-link.h"
+
+    ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
   }
 
   /* Mark the object so we know this work has been done.  */