diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2005-11-09 16:41:30 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2005-11-09 16:41:30 +0000 |
commit | 055e9ae6eeb7810687cd1bbbbb2216433a2bf429 (patch) | |
tree | 1536ce2abc09f52218a805fa676b12a8c455a079 /libexec | |
parent | c55ef26cb97b7ece8611850357d258f19147f0f4 (diff) |
add RTLD_NOW support to dlopen and propogate -z now to dep libs.
ok drahn@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/library.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/library_mquery.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/loader.c | 18 | ||||
-rw-r--r-- | libexec/ld.so/resolve.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/resolve.h | 3 |
5 files changed, 19 insertions, 14 deletions
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c index 3a34b628963..7c948adae24 100644 --- a/libexec/ld.so/library.c +++ b/libexec/ld.so/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.51 2005/10/12 20:48:15 kurt Exp $ */ +/* $OpenBSD: library.c,v 1.52 2005/11/09 16:41:29 kurt Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -246,7 +246,7 @@ _dl_tryload_shlib(const char *libname, int type, int flags) /* set inode, dev from stat info */ object->dev = sb.st_dev; object->inode = sb.st_ino; - object->obj_flags = flags; + object->obj_flags |= flags; } else { /* XXX not possible. object cannot come back NULL */ _dl_munmap((void *)libaddr, maxva - minva); diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index e6615f2180b..fa38340b8f8 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.31 2005/10/12 20:36:16 kurt Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.32 2005/11/09 16:41:29 kurt Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -284,7 +284,7 @@ retry: /* set inode, dev from stat info */ object->dev = sb.st_dev; object->inode = sb.st_ino; - object->obj_flags = flags; + object->obj_flags |= flags; } else { /* XXX no point. object is never returned NULL */ diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 8d2bbe2af40..31a28fbd10c 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.99 2005/10/21 15:24:10 kurt Exp $ */ +/* $OpenBSD: loader.c,v 1.100 2005/11/09 16:41:29 kurt Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -174,7 +174,7 @@ _dl_dopreload(char *paths) while ((cp = _dl_strsep(&dp, ":")) != NULL) { shlib = _dl_load_shlib(cp, _dl_objects, OBJTYPE_LIB, - DL_LAZY|RTLD_GLOBAL); + _dl_objects->obj_flags); if (shlib == NULL) { _dl_printf("%s: can't load library '%s'\n", _dl_progname, cp); @@ -241,11 +241,16 @@ _dl_load_dep_libs(elf_object_t *object, int flags, int booting) Elf_Dyn *dynp; unsigned int loop; int libcount; + int depflags; dynobj = object; while(dynobj) { DL_DEB(("examining: '%s'\n", dynobj->load_name)); libcount = 0; + + /* propagate RTLD_NOW to deplibs (can be set by dynamic tags) */ + depflags = flags | (dynobj->obj_flags & RTLD_NOW); + for (dynp = dynobj->load_dyn; dynp->d_tag; dynp++) { if (dynp->d_tag == DT_NEEDED) { libcount++; @@ -294,7 +299,7 @@ _dl_load_dep_libs(elf_object_t *object, int flags, int booting) DL_DEB(("loading: %s required by %s\n", libname, dynobj->load_name)); depobj = _dl_load_shlib(libname, dynobj, - OBJTYPE_LIB, flags); + OBJTYPE_LIB, depflags); if (depobj == 0) { if (booting) { _dl_printf( @@ -403,7 +408,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data) } phdp++; } - exe_obj->obj_flags = RTLD_GLOBAL; + exe_obj->obj_flags |= RTLD_GLOBAL; n = _dl_malloc(sizeof *n); if (n == NULL) @@ -415,7 +420,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data) if (_dl_preload != NULL) _dl_dopreload(_dl_preload); - _dl_load_dep_libs(exe_obj, DL_LAZY|RTLD_GLOBAL, 1); + _dl_load_dep_libs(exe_obj, exe_obj->obj_flags, 1); /* * Now add the dynamic loader itself last in the object list @@ -754,7 +759,8 @@ _dl_rtld(elf_object_t *object) */ fails =_dl_md_reloc(object, DT_REL, DT_RELSZ); fails += _dl_md_reloc(object, DT_RELA, DT_RELASZ); - _dl_md_reloc_got(object, !(_dl_bindnow || object->dyn.bind_now)); + _dl_md_reloc_got(object, !(_dl_bindnow || + object->obj_flags & RTLD_NOW)); if (_dl_symcache != NULL) { if (sz != 0) diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c index ec7acbda769..fc72d807584 100644 --- a/libexec/ld.so/resolve.c +++ b/libexec/ld.so/resolve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.c,v 1.45 2005/10/21 15:24:10 kurt Exp $ */ +/* $OpenBSD: resolve.c,v 1.46 2005/11/09 16:41:29 kurt Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -93,7 +93,7 @@ _dl_finalize_object(const char *objname, Elf_Dyn *dynp, const long *dl_data, if (dynp->d_tag == DT_SYMBOLIC) object->dyn.symbolic = 1; if (dynp->d_tag == DT_BIND_NOW) - object->dyn.bind_now = 1; + object->obj_flags = RTLD_NOW; dynp++; } diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h index c58fe64ba19..d3c20b1bdcf 100644 --- a/libexec/ld.so/resolve.h +++ b/libexec/ld.so/resolve.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.h,v 1.49 2005/10/16 04:14:22 kurt Exp $ */ +/* $OpenBSD: resolve.h,v 1.50 2005/11/09 16:41:29 kurt Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -93,7 +93,6 @@ struct elf_object { Elf_Addr debug; Elf_Addr textrel; Elf_Addr jmprel; - Elf_Addr bind_now; } u; } Dyn; #define dyn Dyn.u |