diff options
author | Roland McGrath <roland@gnu.org> | 1996-06-21 21:37:08 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-06-21 21:37:08 +0000 |
commit | 0d3726c3fb54d21126a030c445dc2a5245afaacd (patch) | |
tree | 2c9c31dd582e02ed79cab922280679c6bc53eb9e | |
parent | * sysdeps/sparc/elf/start.S: New file. (diff) | |
download | glibc-cvs/libc-960622.tar.gz glibc-cvs/libc-960622.tar.bz2 glibc-cvs/libc-960622.zip |
* elf/dl-load.c (_dl_map_object_from_fd): Fix mapping and l_phdrcvs/libc-960622
guessing to not assume p_vaddr of first load cmd is zero.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | elf/dl-load.c | 20 |
2 files changed, 18 insertions, 5 deletions
@@ -1,5 +1,8 @@ Fri Jun 21 00:27:51 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> + * elf/dl-load.c (_dl_map_object_from_fd): Fix mapping and l_phdr + guessing to not assume p_vaddr of first load cmd is zero. + * sysdeps/sparc/elf/start.S: New file. * sysdeps/sparc/dl-machine.h: New file. diff --git a/elf/dl-load.c b/elf/dl-load.c index f655fdacef..1e0db77c55 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -278,7 +278,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, unallocated. Then jump into the normal segment-mapping loop to handle the portion of the segment past the end of the file mapping. */ - __mprotect (mapat + c->mapend, + __mprotect ((caddr_t) (l->l_addr + c->mapend), loadcmds[nloadcmds - 1].allocend - c->mapend, 0); goto postmap; @@ -337,6 +337,20 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, ++c; } + + if (l->l_phdr == 0) + { + /* There was no PT_PHDR specified. We need to find the phdr in the + load image ourselves. We assume it is in fact in the load image + somewhere, and that the first load command starts at the + beginning of the file and thus contains the ELF file header. */ + ElfW(Addr) bof = l->l_addr + loadcmds[0].mapstart; + assert (loadcmds[0].mapoff == 0); + l->l_phdr = (void *) (bof + ((const ElfW(Ehdr) *) bof)->e_phoff); + } + else + /* Adjust the PT_PHDR value by the runtime load address. */ + (ElfW(Addr)) l->l_phdr += l->l_addr; } /* We are done mapping in the file. We no longer need the descriptor. */ @@ -353,10 +367,6 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, else (ElfW(Addr)) l->l_ld += l->l_addr; - if (l->l_phdr == 0) - l->l_phdr = (void *) ((const ElfW(Ehdr) *) l->l_addr)->e_phoff; - (ElfW(Addr)) l->l_phdr += l->l_addr; - l->l_entry += l->l_addr; elf_get_dynamic_info (l->l_ld, l->l_info); |