diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-24 19:08:48 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-24 19:08:48 +0000 |
commit | efb1c8a787b8a2a4536908c4d0aad8bed570e60e (patch) | |
tree | ba5c09a9cdc0080deb2754ce44ff349a21e21c69 /gnu/usr.bin/ld | |
parent | 0933e252f86427832226f8ec19bfa905c1518905 (diff) |
Enable dlopen(3) to work in statically linked binaries
Diffstat (limited to 'gnu/usr.bin/ld')
-rw-r--r-- | gnu/usr.bin/ld/rrs.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/gnu/usr.bin/ld/rrs.c b/gnu/usr.bin/ld/rrs.c index 1375c499dc5..2ecc96fd0a0 100644 --- a/gnu/usr.bin/ld/rrs.c +++ b/gnu/usr.bin/ld/rrs.c @@ -1,4 +1,4 @@ -/* * $OpenBSD: rrs.c,v 1.3 1998/05/11 20:27:14 niklas Exp $*/ +/* $OpenBSD: rrs.c,v 1.4 1999/08/24 19:08:47 niklas Exp $*/ /* * Copyright (c) 1993 Paul Kranenburg * All rights reserved. @@ -145,6 +145,32 @@ RRS data segment: +-------------------+ */ +static int +dlopen_is_used() +{ + symbol *sym; + struct localsymbol *lsp; + +#ifdef nounderscore + sym = getsym_soft("dlopen"); +#else + sym = getsym_soft("_dlopen"); +#endif + if (!sym) + return 0; + + /* + * A use is charcterized as being an entry on the "refs" list + * that is not in the text section, because such an entry is the + * definition. + */ + if (sym) + for (lsp = sym->refs; lsp; lsp = lsp->next) + if (!(lsp->nzlist.nlist.n_type & N_TEXT)) + return 1; + return 0; +} + /* * Add NAME to the list of needed run-time objects. * Return 1 if ENTRY was added to the list. @@ -690,7 +716,8 @@ consider_rrs_section_lengths() rrs_section_type = RRS_NONE; else if (link_mode & SHAREABLE) rrs_section_type = RRS_FULL; - else if (number_of_shobjs == 0 /*&& !(link_mode & DYNAMIC)*/) { + else if (number_of_shobjs == 0 && !dlopen_is_used() + /*&& !(link_mode & DYNAMIC)*/) { /* * First slots in both tables are reserved * hence the "> 1" condition |