From 53f770e0f9d405ea8d1888254c6f7ce431b04c6e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 27 Mar 1996 23:23:59 +0000 Subject: Wed Mar 27 14:52:11 1996 Roland McGrath * elf/rtld.c (dl_main): Call _dl_sysdep_start_cleanup after _dl_relocate_object loop. Avoid relocating RTLD_MAP in that loop, and do it individually if necessary after _dl_sysdep_start_cleanup call. * stdlib/Makefile (mpn-routines): Add divrem. Tue Mar 26 22:54:14 Ulrich Drepper * stdio-common/printf_fp.c (__printf_fp): Use mpn_divmod instead of __mpn_divmod. Wed Mar 27 10:26:21 1996 David Mosberger-Tang * sysdeps/alpha/setjmp.S: Must establish global pointer before address of __sigsetjmp_aux can be loaded. Wed Mar 27 02:23:19 1996 Ulrich Drepper * sysdeps/i386/i586/memset.S: New file. Highly optimized version for i586 contributed by Torbjorn Granlund. Adapted for use as bzero. * sysdeps/i386/i586/bzero.S: Use sysdeps/i386/i586/memset.S code to implement bzero(). Tue Mar 26 20:01:17 1996 Roland McGrath * stdlib/Makefile (mpn-routines): Remove divmod. --- elf/rtld.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'elf/rtld.c') diff --git a/elf/rtld.c b/elf/rtld.c index 23e0d35d78..d727e1361f 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -339,23 +339,36 @@ of this helper program; chances are you did not intend to run this program.\n", lazy = !_dl_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0'; - /* Do any necessary cleanups for the startup OS interface code. - We do these now so that no calls are made after real relocation - which might be resolved to different functions than we expect. */ - _dl_sysdep_start_cleanup (); - - /* Now we have all the objects loaded. Relocate them all. - We do this in reverse order so that copy relocs of earlier - objects overwrite the data written by later objects. */ + /* Now we have all the objects loaded. Relocate them all except for + the dynamic linker itself. We do this in reverse order so that + copy relocs of earlier objects overwrite the data written by later + objects. We do not re-relocate the dynamic linker itself in this + loop because that could result in the GOT entries for functions we + call being changed, and that would break us. It is safe to + relocate the dynamic linker out of order because it has no copy + relocs (we know that because it is self-contained). */ l = _dl_loaded; while (l->l_next) l = l->l_next; do { - _dl_relocate_object (l, lazy); + if (l != &rtld_map) + _dl_relocate_object (l, lazy); l = l->l_prev; } while (l); + /* Do any necessary cleanups for the startup OS interface code. + We do these now so that no calls are made after rtld re-relocation + which might be resolved to different functions than we expect. + We cannot do this before relocating the other objects because + _dl_relocate_object might need to call `mprotect' for DT_TEXTREL. */ + _dl_sysdep_start_cleanup (); + + if (rtld_map.l_opencount > 0) + /* There was an explicit ref to the dynamic linker as a shared lib. + Re-relocate ourselves with user-controlled symbol definitions. */ + _dl_relocate_object (&rtld_map, lazy); + /* Tell the debugger where to find the map of loaded objects. */ dl_r_debug.r_version = 1 /* R_DEBUG_VERSION XXX */; dl_r_debug.r_ldbase = rtld_map.l_addr; /* Record our load address. */ -- cgit 1.4.1