* elf/do-rel.h (elf_dynamic_do_rel): Help the compiler recognize
	code which is never used when relocating ld.so itself.

	(_ELF_DYNAMIC_DO_RELOC): Help the compiler optimize a bit.
This commit is contained in:
Ulrich Drepper 2002-02-02 07:26:22 +00:00
parent 56c574425d
commit e0f4188600
3 changed files with 40 additions and 14 deletions

View File

@ -1,8 +1,12 @@
2002-02-01 Ulrich Drepper <drepper@redhat.com> 2002-02-01 Ulrich Drepper <drepper@redhat.com>
* elf/do-rel.h (elf_dynamic_do_rel): Help the compiler recognize
code which is never used when relocating ld.so itself.
* elf/dynamic-link.h (elf_get_dynamic_info): Optimize a bit for * elf/dynamic-link.h (elf_get_dynamic_info): Optimize a bit for
starting ld.so itself. Move l_addr variable initialization closer starting ld.so itself. Move l_addr variable initialization closer
to use. to use.
(_ELF_DYNAMIC_DO_RELOC): Help the compiler optimize a bit.
2002-02-01 Jakub Jelinek <jakub@redhat.com> 2002-02-01 Jakub Jelinek <jakub@redhat.com>

View File

@ -98,7 +98,12 @@ elf_dynamic_do_rel (struct link_map *map,
elf_machine_rel_relative (l_addr, relative, elf_machine_rel_relative (l_addr, relative,
(void *) (l_addr + relative->r_offset)); (void *) (l_addr + relative->r_offset));
#ifdef RTLD_BOOTSTRAP
/* The dynamic linker always uses versioning. */
assert (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL);
#else
if (map->l_info[VERSYMIDX (DT_VERSYM)]) if (map->l_info[VERSYMIDX (DT_VERSYM)])
#endif
{ {
const ElfW(Half) *const version = const ElfW(Half) *const version =
(const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
@ -111,10 +116,12 @@ elf_dynamic_do_rel (struct link_map *map,
(void *) (l_addr + r->r_offset)); (void *) (l_addr + r->r_offset));
} }
} }
#ifndef RTLD_BOOTSTRAP
else else
for (; r < end; ++r) for (; r < end; ++r)
elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL, elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
(void *) (l_addr + r->r_offset)); (void *) (l_addr + r->r_offset));
#endif
} }
} }

View File

@ -141,6 +141,12 @@ elf_get_dynamic_info (struct link_map *l)
#ifdef RESOLVE #ifdef RESOLVE
# ifdef RTLD_BOOTSTRAP
# define ELF_DURING_STARTUP (1)
# else
# define ELF_DURING_STARTUP (0)
# endif
/* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'. /* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.
These functions are almost identical, so we use cpp magic to avoid These functions are almost identical, so we use cpp magic to avoid
duplicating their code. It cannot be done in a more general function duplicating their code. It cannot be done in a more general function
@ -188,7 +194,6 @@ elf_get_dynamic_info (struct link_map *l)
# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel) \ # define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel) \
do { \ do { \
struct { ElfW(Addr) start, size; int lazy; } ranges[2]; \ struct { ElfW(Addr) start, size; int lazy; } ranges[2]; \
int ranges_index; \
ranges[0].lazy = 0; \ ranges[0].lazy = 0; \
ranges[0].size = ranges[1].size = 0; \ ranges[0].size = ranges[1].size = 0; \
ranges[0].start = 0; \ ranges[0].start = 0; \
@ -203,26 +208,36 @@ elf_get_dynamic_info (struct link_map *l)
{ \ { \
ElfW(Addr) start = D_PTR ((map), l_info[DT_JMPREL]); \ ElfW(Addr) start = D_PTR ((map), l_info[DT_JMPREL]); \
\ \
if ((do_lazy) \ if (! ELF_DURING_STARTUP \
&& ((do_lazy) \
/* This test does not only detect whether the relocation \ /* This test does not only detect whether the relocation \
sections are in the right order, it also checks whether \ sections are in the right order, it also checks whether \
there is a DT_REL/DT_RELA section. */ \ there is a DT_REL/DT_RELA section. */ \
|| ranges[0].start + ranges[0].size != start) \ || ranges[0].start + ranges[0].size != start)) \
{ \ { \
ranges[1].start = start; \ ranges[1].start = start; \
ranges[1].size = (map)->l_info[DT_PLTRELSZ]->d_un.d_val; \ ranges[1].size = (map)->l_info[DT_PLTRELSZ]->d_un.d_val; \
ranges[1].lazy = (do_lazy); \ ranges[1].lazy = (do_lazy); \
} \ } \
else \ else \
{ \
/* Combine processing the sections. */ \ /* Combine processing the sections. */ \
assert (ranges[0].start + ranges[0].size == start); \
ranges[0].size += (map)->l_info[DT_PLTRELSZ]->d_un.d_val; \ ranges[0].size += (map)->l_info[DT_PLTRELSZ]->d_un.d_val; \
} \
} \ } \
\ \
if (ELF_DURING_STARTUP) \
elf_dynamic_do_##reloc ((map), ranges[0].start, ranges[0].size, 0); \
else \
{ \
int ranges_index; \
for (ranges_index = 0; ranges_index < 2; ++ranges_index) \ for (ranges_index = 0; ranges_index < 2; ++ranges_index) \
elf_dynamic_do_##reloc ((map), \ elf_dynamic_do_##reloc ((map), \
ranges[ranges_index].start, \ ranges[ranges_index].start, \
ranges[ranges_index].size, \ ranges[ranges_index].size, \
ranges[ranges_index].lazy); \ ranges[ranges_index].lazy); \
} \
} while (0) } while (0)
# endif # endif