]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Reduce down to one definition of _ELF_DYNAMIC_DO_RELOC.
authorDavid S. Miller <davem@davemloft.net>
Thu, 5 Apr 2012 22:28:37 +0000 (15:28 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Apr 2012 22:28:37 +0000 (15:28 -0700)
* elf/dynamic-link.h (_ELF_DYNAMIC_DO_RELOC): Reduce down to one
definition.
* sysdeps/powerpc/powerpc32/dl-machine.h
(ELF_MACHINE_PLTREL_OVERLAP): Delete.
* sysdeps/s390/s390-32/dl-machine.h
(ELF_MACHINE_PLTREL_OVERLAP): Likewise.
* sysdeps/sparc/sparc32/dl-machine.h
(ELF_MACHINE_PLTREL_OVERLAP): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h
(ELF_MACHINE_PLTREL_OVERLAP): Likewise.

ChangeLog
elf/dynamic-link.h
sysdeps/powerpc/powerpc32/dl-machine.h
sysdeps/s390/s390-32/dl-machine.h
sysdeps/sparc/sparc32/dl-machine.h
sysdeps/sparc/sparc64/dl-machine.h

index ab6db9edb21ad9b5de352cf1273a1f81718c94bc..6337288222a10b64fdab273fd71193bac6423c79 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2012-04-05  David S. Miller  <davem@davemloft.net>
 
+       * elf/dynamic-link.h (_ELF_DYNAMIC_DO_RELOC): Reduce down to one
+       definition.
+       * sysdeps/powerpc/powerpc32/dl-machine.h
+       (ELF_MACHINE_PLTREL_OVERLAP): Delete.
+       * sysdeps/s390/s390-32/dl-machine.h
+       (ELF_MACHINE_PLTREL_OVERLAP): Likewise.
+       * sysdeps/sparc/sparc32/dl-machine.h
+       (ELF_MACHINE_PLTREL_OVERLAP): Likewise.
+       * sysdeps/sparc/sparc64/dl-machine.h
+       (ELF_MACHINE_PLTREL_OVERLAP): Likewise.
+
        * elf/rtld.c (dl_main): If DL_DEBUG_UNUSED is enabled, turn off
        lazy binding.
        * elf/dl-lookup.c (_dl_lookup_symbol_x): If DL_DEBUG_UNUSED, ignore
index aa7122738b2fdd977f39ff4e4fea5f8f883e3a57..310ad5e66e69f8598a9807fb0d33d9772850f720 100644 (file)
@@ -251,53 +251,12 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
 
 /* On some machines, notably SPARC, DT_REL* includes DT_JMPREL in its
    range.  Note that according to the ELF spec, this is completely legal!
-   But conditionally define things so that on machines we know this will
-   not happen we do something more optimal.  */
 
-# ifdef ELF_MACHINE_PLTREL_OVERLAP
-#  define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, skip_ifunc, test_rel) \
-  do {                                                                       \
-    struct { ElfW(Addr) start, size;                                         \
-            __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative; int lazy; }  \
-    ranges[3];                                                               \
-    int ranges_index;                                                        \
-                                                                             \
-    ranges[0].lazy = ranges[2].lazy = 0;                                     \
-    ranges[1].lazy = 1;                                                              \
-    ranges[0].size = ranges[1].size = ranges[2].size = 0;                    \
-    ranges[0].nrelative = ranges[1].nrelative = ranges[2].nrelative = 0;      \
-                                                                             \
-    if ((map)->l_info[DT_##RELOC])                                           \
-      {                                                                              \
-       ranges[0].start = D_PTR ((map), l_info[DT_##RELOC]);                  \
-       ranges[0].size = (map)->l_info[DT_##RELOC##SZ]->d_un.d_val;           \
-       if (map->l_info[VERSYMIDX (DT_##RELOC##COUNT)] != NULL)               \
-         ranges[0].nrelative                                                 \
-           = MIN (map->l_info[VERSYMIDX (DT_##RELOC##COUNT)]->d_un.d_val,    \
-                  ranges[0].size / sizeof (ElfW(reloc)));                    \
-      }                                                                              \
-                                                                             \
-    if ((do_lazy)                                                            \
-       && (map)->l_info[DT_PLTREL]                                           \
-       && (!test_rel || (map)->l_info[DT_PLTREL]->d_un.d_val == DT_##RELOC)) \
-      {                                                                              \
-       ranges[1].start = D_PTR ((map), l_info[DT_JMPREL]);                   \
-       ranges[1].size = (map)->l_info[DT_PLTRELSZ]->d_un.d_val;              \
-       ranges[2].start = ranges[1].start + ranges[1].size;                   \
-       ranges[2].size = ranges[0].start + ranges[0].size - ranges[2].start;  \
-       ranges[0].size = ranges[1].start - ranges[0].start;                   \
-      }                                                                              \
-                                                                             \
-    for (ranges_index = 0; ranges_index < 3; ++ranges_index)                 \
-      elf_dynamic_do_##reloc ((map),                                         \
-                             ranges[ranges_index].start,                     \
-                             ranges[ranges_index].size,                      \
-                             ranges[ranges_index].nrelative,                 \
-                             ranges[ranges_index].lazy,                      \
-                             skip_ifunc);                                    \
-  } while (0)
-# else
-#  define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, skip_ifunc, test_rel) \
+   We are guarenteed that we have one of two situations.  Either DT_JMPREL
+   comes immediately after DT_REL*, or there is overlap and DT_JMPREL
+   consumes precisely the very end of the DT_REL*.  */
+
+# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, skip_ifunc, test_rel) \
   do {                                                                       \
     struct { ElfW(Addr) start, size;                                         \
             __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative; int lazy; }  \
@@ -317,6 +276,8 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
       {                                                                              \
        ElfW(Addr) start = D_PTR ((map), l_info[DT_JMPREL]);                  \
                                                                              \
+       if (__builtin_expect (ranges[0].size, 1))                             \
+         ranges[0].size = (start - ranges[0].start);                         \
        if (! ELF_DURING_STARTUP                                              \
            && ((do_lazy)                                                     \
                /* This test does not only detect whether the relocation      \
@@ -352,7 +313,6 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
                                  skip_ifunc);                                \
       }                                                                              \
   } while (0)
-# endif
 
 # if ELF_MACHINE_NO_REL || ELF_MACHINE_NO_RELA
 #  define _ELF_CHECK_REL 0
index b3177d1591f7af98817cf5197927555ed7d82f98..45868f5de95009b9a1bb81359c4d268fe06d831f 100644 (file)
@@ -388,8 +388,4 @@ elf_machine_lazy_rel (struct link_map *map,
   /* elf_machine_runtime_setup handles this. */
 }
 
-/* The SVR4 ABI specifies that the JMPREL relocs must be inside the
-   DT_RELA table.  */
-#define ELF_MACHINE_PLTREL_OVERLAP 1
-
 #endif /* RESOLVE_MAP */
index 58bd3aba97d692d2659b88fdaede0efc7c538b9e..3eb7e41159e540089f19f77b83ad179c45ec4746 100644 (file)
@@ -227,9 +227,6 @@ _dl_start_user:\n\
 /* The S390 never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
 
-/* The S390 overlaps DT_RELA and DT_PLTREL.  */
-#define ELF_MACHINE_PLTREL_OVERLAP 1
-
 /* We define an initialization functions.  This is called very early in
    _dl_sysdep_start.  */
 #define DL_PLATFORM_INIT dl_platform_init ()
index f85683d1b029b62508b923b10fcf881200c33332..31b540ac37505a676af58167dc5bccc89db4346c 100644 (file)
@@ -204,9 +204,6 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 /* The SPARC never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
 
-/* The SPARC overlaps DT_RELA and DT_PLTREL.  */
-#define ELF_MACHINE_PLTREL_OVERLAP 1
-
 /* Undo the sub %sp, 6*4, %sp; add %sp, 22*4, %o0 below to get at the
    value we want in __libc_stack_end.  */
 #define DL_STACK_END(cookie) \
index 87655d28ad397cfb294c9baa1b8a7d812ae65f4b..4b14593c9bf8d4cc685b0b19ce2f0273f0f5ec5a 100644 (file)
@@ -125,9 +125,6 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
 /* The SPARC never uses Elf64_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
 
-/* The SPARC overlaps DT_RELA and DT_PLTREL.  */
-#define ELF_MACHINE_PLTREL_OVERLAP 1
-
 /* Set up the loaded object described by L so its unrelocated PLT
    entries will jump to the on-demand fixup code in dl-runtime.c.  */