summaryrefslogtreecommitdiff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-03-27 03:40:33 +0000
committerUlrich Drepper <drepper@redhat.com>2004-03-27 03:40:33 +0000
commiteec8b6cae586451deadf30c371f7b5e4c9d573d1 (patch)
treeb005437b5b7d69778e06694e4bd836a3e7c42f6a /elf/rtld.c
parent17c263876bf38178d3a4ba720bf81d7a214bba51 (diff)
Update.
2004-03-26 Ulrich Drepper <drepper@redhat.com> * elf/dl-caller.c: New file. * include/caller.h: New file. * Makefile (distribute): Add include/caller.h. * elf/Makefile (dl-routines): Add dl-caller. * elf/dl-load.c (_dl_map_object_from_fd): Record l_text_end. * elf/dl-open.c (check_libc_caller): Removed. (dl_open_worker): Use __check_caller instead. * elf/rtld.c (_rtld_global_ro): Initialize _dl_check_caller. (_dl_start_final): Record l_text_end for ld.so map. (dl_main): Record l_text_end for main object and vdso. * include/link.h (struct link_map): Add l_text_end field. * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Add _dl_check_caller field. Define enum allowmask. Add declaration of _dl_check_caller. * sysdeps/unix/sysv/linux/dl-execstack.c: Also use __check_caller test.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 139358c80d..31521c6484 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -142,6 +142,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
._dl_start_profile = _dl_start_profile,
._dl_mcount = _dl_mcount_internal,
._dl_lookup_symbol_x = _dl_lookup_symbol_x,
+ ._dl_check_caller = _dl_check_caller
};
/* If we would use strong_alias here the compiler would see a
non-hidden definition. This would undo the effect of the previous
@@ -208,6 +209,7 @@ static ElfW(Addr) _dl_start_final (void *arg,
/* These defined magically in the linker script. */
extern char _begin[] attribute_hidden;
+extern char _etext[] attribute_hidden;
extern char _end[] attribute_hidden;
@@ -268,6 +270,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
GL(dl_rtld_map).l_opencount = 1;
GL(dl_rtld_map).l_map_start = (ElfW(Addr)) _begin;
GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
+ GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
/* Copy the TLS related data if necessary. */
#if USE_TLS && !defined DONT_USE_BOOTSTRAP_MAP
# if USE___THREAD
@@ -899,6 +902,7 @@ of this helper program; chances are you did not intend to run this program.\n\
}
GL(dl_loaded)->l_map_end = 0;
+ GL(dl_loaded)->l_text_end = 0;
/* Perhaps the executable has no PT_LOAD header entries at all. */
GL(dl_loaded)->l_map_start = ~0;
/* We opened the file, account for it. */
@@ -969,6 +973,8 @@ of this helper program; chances are you did not intend to run this program.\n\
allocend = GL(dl_loaded)->l_addr + ph->p_vaddr + ph->p_memsz;
if (GL(dl_loaded)->l_map_end < allocend)
GL(dl_loaded)->l_map_end = allocend;
+ if ((ph->p_flags & PF_X) && allocend > GL(dl_loaded)->l_text_end)
+ GL(dl_loaded)->l_text_end = allocend;
}
break;
#ifdef USE_TLS
@@ -1012,6 +1018,8 @@ of this helper program; chances are you did not intend to run this program.\n\
#endif
if (! GL(dl_loaded)->l_map_end)
GL(dl_loaded)->l_map_end = ~0;
+ if (! GL(dl_loaded)->l_text_end)
+ GL(dl_loaded)->l_text_end = ~0;
if (! GL(dl_rtld_map).l_libname && GL(dl_rtld_map).l_name)
{
/* We were invoked directly, so the program might not have a
@@ -1271,11 +1279,15 @@ ERROR: ld.so: object '%s' from %s cannot be preloaded: ignored.\n",
l->l_addr = ph->p_vaddr;
else if (ph->p_vaddr + ph->p_memsz >= l->l_map_end)
l->l_map_end = ph->p_vaddr + ph->p_memsz;
+ else if ((ph->p_flags & PF_X)
+ && ph->p_vaddr + ph->p_memsz >= l->l_text_end)
+ l->l_text_end = ph->p_vaddr + ph->p_memsz;
}
}
l->l_map_start = (ElfW(Addr)) GLRO(dl_sysinfo_dso);
l->l_addr = l->l_map_start - l->l_addr;
l->l_map_end += l->l_addr;
+ l->l_text_end += l->l_addr;
l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr);
elf_get_dynamic_info (l, dyn_temp);
_dl_setup_hash (l);