diff options
author | Roland McGrath <roland@gnu.org> | 1995-06-08 09:00:23 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-06-08 09:00:23 +0000 |
commit | 5bf62f2d3a8af353fac661b224fc1604d4de51ea (patch) | |
tree | d71b6ad14564a99917f2d4133a8685df94d24c61 /sysdeps | |
parent | 75598ca67e469359c3c0b6b8704dae17bf2b9d89 (diff) | |
download | glibc-5bf62f2d3a8af353fac661b224fc1604d4de51ea.zip glibc-5bf62f2d3a8af353fac661b224fc1604d4de51ea.tar.gz glibc-5bf62f2d3a8af353fac661b224fc1604d4de51ea.tar.bz2 |
Thu Jun 8 02:50:26 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* elf/rtld.c [! NDEBUG] (__assert_perror_fail): New function.
* hurd/hurdstartup.c (_hurd_startup): Fancier kludge to guess phdr
and user entry point addresses.
* elf/dl-load.c (open_path): Don't do strlen on DIRPATH if it's null.
(_dl_map_object): DT_RPATH value is relative to DT_STRTAB value.
* Makerules (install-lib.so): Don't include libc.so.
[$(build-shared)=yes] (install): Depend on the installed libc.so file.
[$(build-shared)=yes] (install-no-libc.a): Make this, rather than
install, depend on the installed $(install-lib.so) files.
[$(build-shared)=yes] (install-lib.so): Append libc.so after that rule.
* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Add kludge to
allocate high addresses to avoid random mappings appearing there.
(mmap): Comment out mask; always pass zero.
Tue Jun 6 13:34:53 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/i386/dl-machine.h (ELF_MACHINE_USER_ADDRESS_MASK): New macro.
* sysdeps/mach/hurd/dl-sysdep.c (mmap): Use it as mask in vm_map call.
* elf/dl-error.c (_dl_catch_error): Clear *ERRSTRING and *OBJNAME
when successful.
* sysdeps/mach/hurd/dl-sysdep.c (threadvars): New static variable.
(__hurd_threadvar_max, __hurd_threadvar_stack_offset): Define these
variables, using the `threadvars' buffer.
* elf/dl-reloc.c: Don't dereference L->l_prev when it's null.
* sysdeps/i386/dl-runtime.c: Likewise.
* elf/rtld.c (dl_main): Add missing NULL terminating argument in
_dl_sysdep_fatal call.
(__assert_fail): Likewise.
* locale/Makefile (localedef-modules): Renamed ctype to
locale-ctype so as not to conflict with the object file for
ctype/ctype.c in the build directory.
* sysdeps/i386/dl-machine.h (elf_machine_rel): If MAP->l_type is
lt_interpreter, first undo relocation done during bootstrapping.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/i386/dl-machine.h | 20 | ||||
-rw-r--r-- | sysdeps/i386/dl-runtime.c | 6 | ||||
-rw-r--r-- | sysdeps/mach/hurd/dl-sysdep.c | 51 |
3 files changed, 57 insertions, 20 deletions
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index f387a88..5ef56a7 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -88,10 +88,22 @@ elf_machine_rel (struct link_map *map, *reloc_addr = sym_value; break; case R_386_32: + if (map->l_type == lt_interpreter) + { + /* Undo the relocation done here during bootstrapping. Now we will + relocate it anew, possibly using a binding found in the user + program or a loaded library rather than the dynamic linker's + built-in definitions used while loading those libraries. */ + const Elf32_Sym *const dlsymtab + = (void *) (map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr); + *reloc_addr -= (map->l_addr + + dlsymtab[ELF32_R_SYM (reloc->r_info)].st_value); + } *reloc_addr += sym_value; break; case R_386_RELATIVE: - *reloc_addr += map->l_addr; + if (map->l_type != lt_interpreter) /* Already done in dynamic linker. */ + *reloc_addr += map->l_addr; break; case R_386_PC32: *reloc_addr = sym_value - (Elf32_Addr) reloc_addr; @@ -142,6 +154,12 @@ elf_machine_runtime_setup (struct link_map *l) } +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL + + + /* Initial entry point code for the dynamic linker. The C function `_dl_start' is the real entry point; its return value is the user program's entry point. */ diff --git a/sysdeps/i386/dl-runtime.c b/sysdeps/i386/dl-runtime.c index 8e218e2..aac5f99 100644 --- a/sysdeps/i386/dl-runtime.c +++ b/sysdeps/i386/dl-runtime.c @@ -54,8 +54,9 @@ _dl_runtime_resolve (Elf32_Word reloc_offset) real_next = l->l_next; if (l->l_info[DT_SYMBOLIC]) { - l->l_prev->l_next = real_next; l->l_next = _dl_loaded; + if (l->l_prev) + l->l_prev->l_next = real_next; scope = l; } else @@ -67,7 +68,8 @@ _dl_runtime_resolve (Elf32_Word reloc_offset) /* Restore list frobnication done above for DT_SYMBOLIC. */ l->l_next = real_next; - l->l_prev->l_next = l; + if (l->l_prev) + l->l_prev->l_next = l; /* Apply the relocation with that value. */ elf_machine_rel (l, reloc, loadbase, definer); diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index d484521..471c3d1 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -44,6 +44,36 @@ extern char **_environ; struct hurd_startup_data *_dl_hurd_data; +unsigned int __hurd_threadvar_max = _HURD_THREADVAR_MAX; +static unsigned long int threadvars[_HURD_THREADVAR_MAX]; +unsigned long int __hurd_threadvar_stack_offset + = (unsigned long int) &threadvars; + + +/* XXX loser kludge for vm_map kernel bug */ +static vm_address_t fmha; +static vm_size_t fmhs; +static void unfmh(){ +__vm_deallocate(__mach_task_self(),fmha,fmhs);} +static void fmh() { + error_t err;int x;mach_port_t p; + vm_address_t a=0x08000000U,max=VM_MAX_ADDRESS; + while (!(err=__vm_region(__mach_task_self(),&a,&fmhs,&x,&x,&x,&x,&p,&x))){ + __mach_port_deallocate(__mach_task_self(),p); + if (a+fmhs>=0x80000000U){ + max=a;break;} + fmha=a+=fmhs;} + if (err) assert(err==KERN_NO_SPACE); + fmhs=max-fmha; + err = __vm_map (__mach_task_self (), + &fmha, fmhs, 0, 0, MACH_PORT_NULL, 0, 1, + VM_PROT_NONE, VM_PROT_NONE, VM_INHERIT_COPY); + assert_perror(err); + } +/* XXX loser kludge for vm_map kernel bug */ + + + Elf32_Addr _dl_sysdep_start (void **start_argptr, void (*dl_main) (const Elf32_Phdr *phdr, Elf32_Word phent, @@ -62,6 +92,7 @@ _dl_sysdep_start (void **start_argptr, _dl_secure = _dl_hurd_data->flags & EXEC_SECURE; +unfmh(); /* XXX */ /* Call elf/rtld.c's main program. It will set everything up and leave us to transfer control to USER_ENTRY. */ (*dl_main) ((const Elf32_Phdr *) _dl_hurd_data->phdr, @@ -85,6 +116,8 @@ _dl_sysdep_start (void **start_argptr, /* Set up so we can do RPCs. */ __mach_init (); +fmh(); /* XXX */ + /* See hurd/hurdstartup.c; this deals with getting information from the exec server and slicing up the arguments. Then it will call `go', above. */ @@ -92,22 +125,6 @@ _dl_sysdep_start (void **start_argptr, LOSE; } - -/* This is called when all other dynamic linking is finished, before the - dynamic linker re-relocates itself when ld.so itself appears in a - DT_NEEDED entry. It is called whether of not ld.so is being linked in. - - We take this opportunity to deallocate the reply port and task-self send - right user reference we have acquired, since they will not be used again - before the library and user code runs. The C library will acquire its - own ports in its initialization. */ - -void -_dl_sysdep_prepare_for_ld_reloc (void) -{ - __mig_dealloc_reply_port (__mig_get_reply_port ()); - __mach_port_deallocate (__mach_task_self (), __mach_task_self ()); -} int _dl_sysdep_open_zero_fill (void) @@ -415,7 +432,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) mapaddr = (vm_address_t) addr; errno = __vm_map (__mach_task_self (), - &mapaddr, (vm_size_t) len, (vm_address_t) 0, + &mapaddr, (vm_size_t) len, 0 /*ELF_MACHINE_USER_ADDRESS_MASK*/, !(flags & MAP_FIXED), (mach_port_t) fd, (vm_offset_t) offset, flags & (MAP_COPY|MAP_PRIVATE), |