summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1995-06-27 09:53:27 +0000
committerdfr <dfr@FreeBSD.org>1995-06-27 09:53:27 +0000
commit6da3ef32238f37b3b45cf709205fcff60bcbda7f (patch)
treeb2f08f6f168c7683bfcb9675e76d2b7d12267c7e /lib
parente99bd397ee99a54805081daa8655d6ae246f14d0 (diff)
downloadFreeBSD-src-6da3ef32238f37b3b45cf709205fcff60bcbda7f.zip
FreeBSD-src-6da3ef32238f37b3b45cf709205fcff60bcbda7f.tar.gz
Change ld.so to correctly load dependant libraries for dlopen and unload them
on dlclose. Also correctly call constructors and destructors for libraries linked with /usr/lib/c++rt0.o. Change interpretation of dlopen manpage to call _init() rather than init() for dlopened objects. Change c++rt0.o to avoid using atexit to call destructors, allowing dlclose to call destructors when an object is unloaded. Change interface between crt0 and ld.so to allow crt0 to call a function on exit to call destructors for shared libraries explicitly. These changes are backwards compatible. Old binaries will work with the new ld.so and new binaries will work with the old ld.so. A version number has been introduced in the crt0-ld.so interface to allow for future changes. Reviewed by: GAWollman, Craig Struble <cstruble@singularity.bevc.blacksburg.va.us>
Diffstat (limited to 'lib')
-rw-r--r--lib/csu/i386/c++rt0.c10
-rw-r--r--lib/csu/i386/crt0.c10
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/csu/i386/c++rt0.c b/lib/csu/i386/c++rt0.c
index df85907..aa28109 100644
--- a/lib/csu/i386/c++rt0.c
+++ b/lib/csu/i386/c++rt0.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: c++rt0.c,v 1.1 1994/03/09 17:12:59 nate Exp $
+ * $Id: c++rt0.c,v 1.2 1995/05/30 05:39:36 rgrimes Exp $
*/
/*
@@ -61,6 +61,7 @@ __ctors(void)
}
extern void __init() asm(".init");
+extern void __fini() asm(".fini");
void
__init(void)
@@ -74,7 +75,12 @@ __init(void)
if (!initialized) {
initialized = 1;
__ctors();
- atexit(__dtors);
}
}
+
+void
+__fini(void)
+{
+ __dtors();
+}
diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c
index f6f0759..7959e66 100644
--- a/lib/csu/i386/crt0.c
+++ b/lib/csu/i386/crt0.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: crt0.c,v 1.15 1995/02/07 13:27:29 jkh Exp $
+ * $Id: crt0.c,v 1.16 1995/02/24 07:51:13 phk Exp $
*/
@@ -194,6 +194,7 @@ __do_dynamic_link ()
struct exec hdr;
char *ldso;
int (*entry)();
+ int ret;
#ifdef DEBUG
/* Provision for alternate ld.so - security risk! */
@@ -259,11 +260,16 @@ __do_dynamic_link ()
crt.crt_prog = __progname;
entry = (int (*)())(crt.crt_ba + sizeof hdr);
- if ((*entry)(CRT_VERSION_BSD_3, &crt) == -1) {
+ ret = (*entry)(CRT_VERSION_BSD_3, &crt);
+ if (ret == -1) {
_FATAL("ld.so failed\n");
}
ld_entry = _DYNAMIC.d_entry;
+
+ if (ret >= LDSO_VERSION_HAS_DLEXIT)
+ atexit(ld_entry->dlexit);
+
return;
}
OpenPOWER on IntegriCloud