summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1993-12-22 23:28:35 +0000
committerjkh <jkh@FreeBSD.org>1993-12-22 23:28:35 +0000
commit03fd21e05b8bc2f6db3ccad69f0e12436a6dea7a (patch)
tree178b158232c373cae5a5c6eb3b46e5148b27b107 /libexec
parentba8f800748128912d4553f63373a7dcb4d3e5f37 (diff)
downloadFreeBSD-src-03fd21e05b8bc2f6db3ccad69f0e12436a6dea7a.zip
FreeBSD-src-03fd21e05b8bc2f6db3ccad69f0e12436a6dea7a.tar.gz
C++ support changes (+misc fixes) from Paul K.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-aout/rtld.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c
index fd48fb7..422646f 100644
--- a/libexec/rtld-aout/rtld.c
+++ b/libexec/rtld-aout/rtld.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: rtld.c,v 1.10 1993/12/11 20:08:39 jkh Exp $
+ * $Id: rtld.c,v 1.11 1993/12/11 21:06:00 jkh Exp $
*/
#include <machine/vmparam.h>
@@ -141,6 +141,7 @@ static void check_text_reloc __P(( struct relocation_info *,
caddr_t));
static void reloc_maps __P((void));
static void reloc_copy __P((void));
+static void init_maps __P((void));
static char *rtfindlib __P((char *, int, int, int *));
void binder_entry __P((void));
long binder __P((jmpslot_t *));
@@ -216,6 +217,7 @@ struct link_dynamic *dp;
/* Relocate all loaded objects according to their RRS segments */
reloc_maps();
reloc_copy();
+ init_maps();
/* Fill in some field in main's __DYNAMIC structure */
crtp->crt_dp->ld_entry = &ld_entry;
@@ -295,7 +297,7 @@ struct crt_ldso *crtp;
printf("\t%s => %s (%#x)\n", name, path, lmp->lm_addr);
}
- _exit(0);
+ exit(0);
}
/*
@@ -438,15 +440,18 @@ reloc_maps()
check_text_reloc(r, lmp, addr);
if (RELOC_EXTERN_P(r)) {
- struct link_map *src_map;
- struct nzlist *np;
+ struct link_map *src_map = NULL;
+ struct nzlist *p, *np;
long relocation = md_get_addend(r, addr);
if (RELOC_LAZY_P(r))
continue;
- sym = LM_STRINGS(lmp) +
- LM_SYMBOL(lmp,RELOC_SYMBOL(r))->nz_strx;
+ p = LM_SYMBOL(lmp,RELOC_SYMBOL(r));
+ if (p->nz_type == (N_SETV + N_EXT))
+ src_map = lmp;
+
+ sym = LM_STRINGS(lmp) + p->nz_strx;
np = lookup(sym, &src_map, 0/*XXX-jumpslots!*/);
if (np == NULL)
@@ -481,7 +486,9 @@ src_map->lm_addr, np->nz_value, sym, addr, relocation, np->nz_size);
continue;
}
#if DEBUG
-xprintf("RELOCATE(%s) external: %s at %#x, reloc = %#x\n", lmp->lm_name, sym, addr, relocation);
+if (sym[2]=='_'&&(sym[3]=='C'||sym[3]=='D')&&sym[4]=='T')
+xprintf("RELOCATE(%s) external: %s at %#x, reloc = %#x in %s\n",
+lmp->lm_name, sym, addr, relocation, src_map?src_map->lm_name:"(NUL)");
#endif
md_relocate(r, relocation, addr, 0);
@@ -564,23 +571,43 @@ caddr_t addr;
lmp->lm_rwt = 1;
}
+static void
+init_maps()
+{
+ struct link_map *lmp, *src_map;
+ struct nzlist *np;
+ void (*func)();
+
+ for (lmp = link_map_head; lmp; lmp = lmp->lm_next) {
+ src_map = lmp;
+ np = lookup("___init", &src_map, 1);
+#if DEBUG
+if (np)
+xprintf("Calling __init in %s at %#x\n", src_map->lm_name, np->nz_value+src_map->lm_addr);
+#endif
+ if (np) {
+ func = (void (*)())(src_map->lm_addr + np->nz_value);
+ (*func)();
+ }
+ }
+}
+
/*
* Lookup NAME in the link maps. The link map producing a definition
- * is returned in SRC_MAP. If STRONG is set, the symbol returned must
+ * is returned in SRC_MAP. If SRC_MAP is not NULL on entry the search is
+ * confined to that map. If STRONG is set, the symbol returned must
* have a proper type (used by binder()).
*/
static struct nzlist *
lookup(name, src_map, strong)
char *name;
-struct link_map **src_map;
+struct link_map **src_map; /* IN/OUT */
int strong;
{
long common_size = 0;
struct link_map *lmp;
struct rt_symbol *rtsp;
- *src_map = NULL;
-
if ((rtsp = lookup_rts(name)) != NULL)
return rtsp->rt_sp;
@@ -594,6 +621,9 @@ int strong;
char *cp;
struct nzlist *np;
+ if (*src_map && lmp != *src_map)
+ continue;
+
/*
* Compute bucket in which the symbol might be found.
*/
@@ -672,7 +702,7 @@ long
binder(jsp)
jmpslot_t *jsp;
{
- struct link_map *lmp, *src_map;
+ struct link_map *lmp, *src_map = NULL;
long addr;
char *sym;
struct nzlist *np;
@@ -1004,3 +1034,4 @@ char *fmt;
(void)write(1, buf, strlen(buf));
va_end(ap);
}
+
OpenPOWER on IntegriCloud