aboutsummaryrefslogtreecommitdiff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-01-27 21:30:46 +0000
committerUlrich Drepper <drepper@redhat.com>2004-01-27 21:30:46 +0000
commite8ed861df7f58c9663e9b63cc2f2ee5346a18f3b (patch)
treeadfe079858f8bd8ffcb8c96a5adc9c5136b8f5be /elf/rtld.c
parentbed12f78fab86b2349cab6e7f4c0e46bde5e9711 (diff)
downloadglibc-e8ed861df7f58c9663e9b63cc2f2ee5346a18f3b.tar
glibc-e8ed861df7f58c9663e9b63cc2f2ee5346a18f3b.tar.gz
glibc-e8ed861df7f58c9663e9b63cc2f2ee5346a18f3b.tar.bz2
glibc-e8ed861df7f58c9663e9b63cc2f2ee5346a18f3b.zip
Update.
2004-01-26 David Mosberger <davidm@hpl.hp.com> * elf/link.h (struct dl_phdr_info): Fix typo in comment. * elf/rtld.c (dl_main): After incrementing dl_nloaded, also increment dl_load_adds. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Replace GL(dl_load_subs) with equivalent GL(dl_load_adds - GL(dl_nloaded). (dl_iterate_phdr): Likewise. * elf/dl-close.c (_dl_close): Delete increment of GL(dl_load_subs). * elf/dl-support.c: Remove global variable _dl_load_subs. * sysdeps/generic/ldsodefs.h (struct rtld_global): Remove _dl_load_subs member. 2004-01-27 Jakub Jelinek <jakub@redhat.com> * elf/rtld.c (_dl_start_final): Don't set l_relro_* here. (_dl_start): And neither here. (dl_main): Set GL(dl_loaded)->l_relro_* and GL(dl_rtld_map)->l_relro_*.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 3a8ede8579..e0f9f28944 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -224,8 +224,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
memcpy (GL(dl_rtld_map).l_info, info->l.l_info,
sizeof GL(dl_rtld_map).l_info);
GL(dl_rtld_map).l_mach = info->l.l_mach;
- GL(dl_rtld_map).l_relro_addr = info->l.l_relro_addr;
- GL(dl_rtld_map).l_relro_size = info->l.l_relro_size;
#endif
_dl_setup_hash (&GL(dl_rtld_map));
GL(dl_rtld_map).l_opencount = 1;
@@ -351,17 +349,16 @@ _dl_start (void *arg)
on the `l_addr' value, which is not the value we want when prelinked. */
#if USE___THREAD
dtv_t initdtv[3];
-#endif /* USE___THREAD */
ElfW(Ehdr) *ehdr
# ifdef DONT_USE_BOOTSTRAP_MAP
= (ElfW(Ehdr) *) &_begin;
# else
+# error This will not work with prelink.
= (ElfW(Ehdr) *) bootstrap_map.l_addr;
# endif
ElfW(Phdr) *phdr = (ElfW(Phdr) *) ((void *) ehdr + ehdr->e_phoff);
size_t cnt = ehdr->e_phnum; /* PT_TLS is usually the last phdr. */
while (cnt-- > 0)
-#if USE___THREAD
if (phdr[cnt].p_type == PT_TLS)
{
void *tlsblock;
@@ -456,14 +453,11 @@ _dl_start (void *arg)
/* So far this is module number one. */
bootstrap_map.l_tls_modid = 1;
+
+ /* There can only be one PT_TLS entry. */
+ break;
}
- else
#endif /* USE___THREAD */
- if (phdr[cnt].p_type == PT_GNU_RELRO)
- {
- bootstrap_map.l_relro_addr = phdr[cnt].p_vaddr;
- bootstrap_map.l_relro_size = phdr[cnt].p_memsz;
- }
#ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
ELF_MACHINE_BEFORE_RTLD_RELOC (bootstrap_map.l_info);
@@ -958,6 +952,11 @@ of this helper program; chances are you did not intend to run this program.\n\
case PT_GNU_STACK:
GL(dl_stack_flags) = ph->p_flags;
break;
+
+ case PT_GNU_RELRO:
+ GL(dl_loaded)->l_relro_addr = ph->p_vaddr;
+ GL(dl_loaded)->l_relro_size = ph->p_memsz;
+ break;
}
#ifdef USE_TLS
/* Adjust the address of the TLS initialization image in case
@@ -1020,6 +1019,7 @@ of this helper program; chances are you did not intend to run this program.\n\
GL(dl_loaded)->l_next = &GL(dl_rtld_map);
GL(dl_rtld_map).l_prev = GL(dl_loaded);
++GL(dl_nloaded);
+ ++GL(dl_load_adds);
/* If LD_USE_LOAD_BIAS env variable has not been seen, default
to not using bias for non-prelinked PIEs and libraries
@@ -1030,10 +1030,21 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Set up the program header information for the dynamic linker
itself. It is needed in the dl_iterate_phdr() callbacks. */
ElfW(Ehdr) *rtld_ehdr = (ElfW(Ehdr) *) GL(dl_rtld_map).l_map_start;
- GL(dl_rtld_map).l_phdr = (ElfW(Phdr) *) (GL(dl_rtld_map).l_map_start
- + rtld_ehdr->e_phoff);
+ ElfW(Phdr) *rtld_phdr = (ElfW(Phdr) *) (GL(dl_rtld_map).l_map_start
+ + rtld_ehdr->e_phoff);
+ GL(dl_rtld_map).l_phdr = rtld_phdr;
GL(dl_rtld_map).l_phnum = rtld_ehdr->e_phnum;
+ /* PT_GNU_RELRO is usually the last phdr. */
+ size_t cnt = rtld_ehdr->e_phnum;
+ while (cnt-- > 0)
+ if (rtld_phdr[cnt].p_type == PT_GNU_RELRO)
+ {
+ GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
+ GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
+ break;
+ }
+
/* We have two ways to specify objects to preload: via environment
variable and via the file /etc/ld.so.preload. The latter can also
be used when security is enabled. */