summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/ld.so/dlfcn.c6
-rw-r--r--libexec/ld.so/library.c28
-rw-r--r--libexec/ld.so/loader.c100
-rw-r--r--libexec/ld.so/resolve.c57
-rw-r--r--libexec/ld.so/resolve.h68
-rw-r--r--libexec/ld.so/strdup.c3
6 files changed, 138 insertions, 124 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index f51a3bab83a..442f6dbcacf 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.2 2000/09/17 17:50:57 deraadt Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.3 2001/04/02 23:11:20 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -56,7 +56,7 @@ dlopen(const char *libname, int how)
{
elf_object_t *object;
elf_object_t *dynobj;
- Elf32_Dyn *dynp;
+ Elf_Dyn *dynp;
if (_dl_debug) {
_dl_printf("loading: %s\n", libname);
@@ -120,7 +120,7 @@ dlsym(void *handle, const char *name)
elf_object_t *object;
elf_object_t *dynobj;
void *retval;
- const Elf32_Sym *sym = 0;
+ const Elf_Sym *sym = 0;
object = (elf_object_t *)handle;
dynobj = _dl_objects;
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c
index a591772ea32..6d249f08366 100644
--- a/libexec/ld.so/library.c
+++ b/libexec/ld.so/library.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library.c,v 1.4 2001/03/30 01:35:20 drahn Exp $ */
+/* $OpenBSD: library.c,v 1.5 2001/04/02 23:11:20 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -192,13 +192,13 @@ _dl_tryload_shlib(const char *libname, int type)
int libfile;
int i;
char hbuf[4096];
- Elf32_Ehdr *ehdr;
- Elf32_Phdr *phdp;
- Elf32_Dyn *dynp = 0;
- Elf32_Addr maxva = 0;
- Elf32_Addr minva = 0x7fffffff;
- Elf32_Addr libaddr;
- Elf32_Addr loff;
+ Elf_Ehdr *ehdr;
+ Elf_Phdr *phdp;
+ Elf_Dyn *dynp = 0;
+ Elf_Addr maxva = 0;
+ Elf_Addr minva = 0x7fffffff; /* XXX Correct for 64bit? */
+ Elf_Addr libaddr;
+ Elf_Addr loff;
int align = _dl_pagesz - 1;
elf_object_t *object;
load_list_t *next_load, *load_list = NULL;
@@ -216,7 +216,7 @@ _dl_tryload_shlib(const char *libname, int type)
}
_dl_read(libfile, hbuf, sizeof(hbuf));
- ehdr = (Elf32_Ehdr *)hbuf;
+ ehdr = (Elf_Ehdr *)hbuf;
if(_dl_strncmp(ehdr->e_ident, ELFMAG, SELFMAG) ||
ehdr->e_type != ET_DYN || ehdr->e_machine != MACHID) {
_dl_close(libfile);
@@ -229,7 +229,7 @@ _dl_tryload_shlib(const char *libname, int type)
* Figure out how much VM space we need.
*/
- phdp = (Elf32_Phdr *)(hbuf + ehdr->e_phoff);
+ phdp = (Elf_Phdr *)(hbuf + ehdr->e_phoff);
for(i = 0; i < ehdr->e_phnum; i++, phdp++) {
switch(phdp->p_type) {
case PT_LOAD:
@@ -242,7 +242,7 @@ _dl_tryload_shlib(const char *libname, int type)
break;
case PT_DYNAMIC:
- dynp = (Elf32_Dyn *)phdp->p_vaddr;
+ dynp = (Elf_Dyn *)phdp->p_vaddr;
break;
default:
@@ -256,7 +256,7 @@ _dl_tryload_shlib(const char *libname, int type)
* We map the entire area to see that we can get the VM
* space required. Map it unaccessible to start with.
*/
- libaddr = (Elf32_Addr)_dl_mmap(0, maxva - minva, PROT_NONE,
+ libaddr = (Elf_Addr)_dl_mmap(0, maxva - minva, PROT_NONE,
MAP_COPY|MAP_ANON, -1, 0);
if(_dl_check_error(libaddr)) {
_dl_printf("%s: rtld mmap failed mapping %s.\n",
@@ -267,7 +267,7 @@ _dl_tryload_shlib(const char *libname, int type)
}
loff = libaddr - minva;
- phdp = (Elf32_Phdr *)(hbuf + ehdr->e_phoff);
+ phdp = (Elf_Phdr *)(hbuf + ehdr->e_phoff);
for(i = 0; i < ehdr->e_phnum; i++, phdp++) {
if(phdp->p_type == PT_LOAD) {
@@ -319,7 +319,7 @@ _dl_tryload_shlib(const char *libname, int type)
}
_dl_close(libfile);
- dynp = (Elf32_Dyn *)((int)dynp + loff);
+ dynp = (Elf_Dyn *)((unsigned long)dynp + loff);
object = _dl_add_object(libname, dynp, 0, type, libaddr, loff);
if(object) {
object->load_size = maxva - minva; /*XXX*/
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index e4b33a7f704..9d001f15e22 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.6 2001/02/03 22:11:41 drahn Exp $ */
+/* $OpenBSD: loader.c,v 1.7 2001/04/02 23:11:20 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -54,7 +54,7 @@
*/
static void *_dl_malloc_base;
static void *_dl_malloc_pool = 0;
-static int *_dl_malloc_free = 0;
+static long *_dl_malloc_free = 0;
const char *_dl_progname;
int _dl_pagesz;
@@ -107,7 +107,7 @@ putstring(char *string, unsigned int off)
{
int len = 0;
char * str1;
- if ((unsigned int) string < 0x10000000) {
+ if ((unsigned long) string < 0x10000000) {
string += off;
}
for ( str1 = string; len < 30 && *str1++ != '\0'; len++);
@@ -125,16 +125,16 @@ putc(char c)
/*
* This is the dynamic loader entrypoint. When entering here, depending
* on architecture type, the stack and registers are set up according
- * to the architectures ABI specification. The first thing requiered
+ * to the architectures ABI specification. The first thing required
* to do is to dig out all information we need to accomplish out task.
*/
-int
-_dl_boot(const char **argv, const char **envp, const int loff,
- Elf32_Dyn *dynp, int *dl_data)
+unsigned long
+_dl_boot(const char **argv, const char **envp, const long loff,
+ Elf_Dyn *dynp, long *dl_data)
{
int n;
int brk_addr;
- Elf32_Phdr *phdp;
+ Elf_Phdr *phdp;
char *us = "";
elf_object_t *dynobj;
struct elf_object *exe_obj; /* Pointer to executable object */
@@ -177,14 +177,14 @@ _dl_boot(const char **argv, const char **envp, const int loff,
/*
* Examine the user application and set up object information.
*/
- phdp = (Elf32_Phdr *) dl_data[AUX_phdr];
+ phdp = (Elf_Phdr *) dl_data[AUX_phdr];
for(n = 0; n < dl_data[AUX_phnum]; n++) {
if(phdp->p_type == PT_LOAD) { /*XXX*/
if(phdp->p_vaddr + phdp->p_memsz > brk_addr) /*XXX*/
brk_addr = phdp->p_vaddr + phdp->p_memsz;
} /*XXX*/
if(phdp->p_type == PT_DYNAMIC) {
- exe_obj = _dl_add_object("", (Elf32_Dyn *)phdp->p_vaddr,
+ exe_obj = _dl_add_object("", (Elf_Dyn *)phdp->p_vaddr,
dl_data, OBJTYPE_EXE, 0, 0);
}
if(phdp->p_type == PT_INTERP) {
@@ -226,7 +226,7 @@ _dl_boot(const char **argv, const char **envp, const int loff,
* so we can use the _dl_ code when serving dl.... calls.
*/
- dynp = (Elf32_Dyn *)((int)_DYNAMIC);
+ dynp = (Elf_Dyn *)((void *)_DYNAMIC);
dyn_obj = _dl_add_object(us, dynp, 0, OBJTYPE_LDR, dl_data[AUX_base], loff);
dyn_obj->status |= STAT_RELOC_DONE;
@@ -255,7 +255,7 @@ _dl_boot(const char **argv, const char **envp, const int loff,
debug_map = (struct r_debug *)_dl_malloc(sizeof(*debug_map));
debug_map->r_version = 1;
debug_map->r_map = (struct link_map *)_dl_objects;
- debug_map->r_brk = (Elf32_Addr)_dl_debug_state;
+ debug_map->r_brk = (Elf_Addr)_dl_debug_state;
debug_map->r_state = RT_CONSISTENT;
debug_map->r_ldbase = loff;
_dl_debug_map = debug_map;
@@ -265,7 +265,7 @@ _dl_boot(const char **argv, const char **envp, const int loff,
for(dynp = dynobj->load_dyn; dynp->d_tag; dynp++) {
if (dynp->d_tag == DT_DEBUG) {
- dynp->d_un.d_ptr = (Elf32_Addr) debug_map;
+ dynp->d_un.d_ptr = (Elf_Addr) debug_map;
done = 1;
break;
}
@@ -282,7 +282,7 @@ _dl_boot(const char **argv, const char **envp, const int loff,
debug_map = (struct r_debug *)_dl_malloc(sizeof(*debug_map));
debug_map->r_version = 1;
debug_map->r_map = (struct link_map *)_dl_objects;
- debug_map->r_brk = (Elf32_Addr)_dl_debug_state;
+ debug_map->r_brk = (Elf_Addr)_dl_debug_state;
debug_map->r_state = RT_CONSISTENT;
debug_map->r_ldbase = loff;
_dl_debug_map = debug_map;
@@ -307,12 +307,12 @@ _dl_boot(const char **argv, const char **envp, const int loff,
void
-_dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
- const char **envp, Elf32_Dyn *dynamicp, int *dl_data)
+_dl_boot_bind(const long sp, const long loff, int argc, const char **argv,
+ const char **envp, Elf_Dyn *dynamicp, long *dl_data)
{
- Elf32_Dyn *dynp;
+ Elf_Dyn *dynp;
int n;
- int *stack;
+ long *stack;
AuxInfo *auxstack;
struct elf_object dynld; /* Resolver data for the loader */
@@ -326,16 +326,16 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
* data vector put after them.
*/
#ifdef _mips_
- stack = (int *)sp;
+ stack = (long *)sp;
argc = *stack++;
argv = (const char **)stack;
envp = &argv[argc + 1];
#endif /* _mips_ */
- stack = (int *)envp;
+ stack = (long *)envp;
while(*stack++ != NULL) {};
/*
- * Dig out auxilary data set up by exec call. Move all known
+ * Dig out auxiliary data set up by exec call. Move all known
* tags to an indexed local table for easy access.
*/
@@ -356,10 +356,10 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
* Cache the data for easier access.
*/
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__alpha__)
dynp = dynamicp;
#else
- dynp = (Elf32_Dyn *)((int)_DYNAMIC + loff);
+ dynp = (Elf_Dyn *)((long)_DYNAMIC + loff);
#endif
while(dynp != NULL && dynp->d_tag != DT_NULL) {
if(dynp->d_tag < DT_LOPROC) {
@@ -431,24 +431,24 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
{
int i;
u_int32_t rs;
- Elf32_Rel *rp;
+ Elf_Rel *rp;
- rp = (Elf32_Rel *)(dynld.Dyn.info[DT_REL]);
+ rp = (Elf_Rel *)(dynld.Dyn.info[DT_REL]);
rs = dynld.dyn.relsz;
- for(i = 0; i < rs; i += sizeof (Elf32_Rel)) {
- Elf32_Addr *ra;
- const Elf32_Sym *sp;
+ for(i = 0; i < rs; i += sizeof (Elf_Rel)) {
+ Elf_Addr *ra;
+ const Elf_Sym *sp;
sp = dynld.dyn.symtab;
- sp += ELF32_R_SYM(rp->r_info);
+ sp += ELF_R_SYM(rp->r_info);
#if 1
putstring("reloc ", loff);
putstring(((char *)dynld.dyn.strtab) + sp->st_name, 0);
putstring(" ", loff);
#endif
- if(ELF32_R_SYM(rp->r_info) && sp->st_value == 0) {
+ if(ELF_R_SYM(rp->r_info) && sp->st_value == 0) {
#if 0
/* cannot printf in this function */
_dl_wrstderr("Dynamic loader failure: self bootstrapping impossible.\n");
@@ -459,7 +459,7 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
_dl_exit(5);
}
- ra = (Elf32_Addr *)(rp->r_offset + loff);
+ ra = (Elf_Addr *)(rp->r_offset + loff);
#if 0
put_x((unsigned int)ra);
putstring("\n", loff);
@@ -474,15 +474,15 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
for(n = 0; n < 2; n++) {
int i;
u_int32_t rs;
- Elf32_Rela *rp;
+ Elf_RelA *rp;
switch (n) {
case 0:
- rp = (Elf32_Rela *)(dynld.Dyn.info[DT_JMPREL]);
+ rp = (Elf_RelA *)(dynld.Dyn.info[DT_JMPREL]);
rs = dynld.dyn.pltrelsz;
break;
case 1:
- rp = (Elf32_Rela *)(dynld.Dyn.info[DT_RELA]);
+ rp = (Elf_RelA *)(dynld.Dyn.info[DT_RELA]);
rs = dynld.dyn.relasz;
break;
@@ -491,13 +491,13 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
rs = 0;
;
}
- for(i = 0; i < rs; i += sizeof (Elf32_Rela)) {
- Elf32_Addr *ra;
- const Elf32_Sym *sp;
+ for(i = 0; i < rs; i += sizeof (Elf_RelA)) {
+ Elf_Addr *ra;
+ const Elf_Sym *sp;
sp = dynld.dyn.symtab;
- sp += ELF32_R_SYM(rp->r_info);
- if(ELF32_R_SYM(rp->r_info) && sp->st_value == 0) {
+ sp += ELF_R_SYM(rp->r_info);
+ if(ELF_R_SYM(rp->r_info) && sp->st_value == 0) {
#if 0
_dl_wrstderr("Dynamic loader failure: self bootstrapping impossible.\n");
_dl_wrstderr("Undefined symbol: ");
@@ -507,7 +507,7 @@ _dl_boot_bind(const int sp, const int loff, int argc, const char **argv,
_dl_exit(6);
}
- ra = (Elf32_Addr *)(rp->r_offset + loff);
+ ra = (Elf_Addr *)(rp->r_offset + loff);
RELOC_RELA(rp, sp, ra, loff);
/*
@@ -552,9 +552,9 @@ _dl_rtld(elf_object_t *object)
void
_dl_call_init(elf_object_t *object)
{
- Elf32_Addr ooff;
- const Elf32_Sym *sym;
- static void (*_dl_atexit)(Elf32_Addr) = NULL;
+ Elf_Addr ooff;
+ const Elf_Sym *sym;
+ static void (*_dl_atexit)(Elf_Addr) = NULL;
if(object->next) {
_dl_call_init(object->next);
@@ -642,16 +642,16 @@ _dl_getenv(const char *var, const char **env)
void *
_dl_malloc(int size)
{
- int *p;
- int *t, *n;
+ long *p;
+ long *t, *n;
size = (size + 8 + DL_MALLOC_ALIGN - 1) & ~(DL_MALLOC_ALIGN - 1);
if((t = _dl_malloc_free) != 0) { /* Try free list first */
- n = (int *)&_dl_malloc_free;
+ n = (long *)&_dl_malloc_free;
while(t && t[-1] < size) {
n = t;
- t = (int *)*t;
+ t = (long *)*t;
}
if(t) {
*n = *t;
@@ -665,7 +665,7 @@ _dl_malloc(int size)
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_COPY, -1, 0);
if(_dl_malloc_pool == 0 ||
- _dl_malloc_pool == (void*)0xffffffff )
+ _dl_malloc_pool == MAP_FAILED )
{
_dl_printf("Dynamic loader failure: malloc.\n");
_dl_exit(7);
@@ -682,8 +682,8 @@ _dl_malloc(int size)
void
_dl_free(void *p)
{
- int *t = (int *)p;
+ long *t = (long *)p;
- *t = (int)_dl_malloc_free;
+ *t = (long)_dl_malloc_free;
_dl_malloc_free = p;
}
diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c
index e7639dc0377..bcdba36403b 100644
--- a/libexec/ld.so/resolve.c
+++ b/libexec/ld.so/resolve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.c,v 1.1 2000/06/13 03:34:07 rahnds Exp $ */
+/* $OpenBSD: resolve.c,v 1.2 2001/04/02 23:11:21 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -36,14 +36,16 @@
#include <sys/types.h>
+#include <nlist.h>
#include <link.h>
-#include "resolve.h"
#include "syscall.h"
#include "archdep.h"
+#include "resolve.h"
elf_object_t *_dl_objects;
elf_object_t *_dl_last_object;
+void * _dl_malloc(int);
/*
* Initialize and add a new dynamic object to the object list.
@@ -51,11 +53,15 @@ elf_object_t *_dl_last_object;
*/
elf_object_t *
-_dl_add_object(const char *objname, Elf32_Dyn *dynp,
- const u_int32_t *dl_data, const int objtype,
- const int laddr, const int loff)
+_dl_add_object(const char *objname, Elf_Dyn *dynp,
+ const u_long *dl_data, const int objtype,
+ const long laddr, const long loff)
{
elf_object_t *object;
+#if 0
+ _dl_printf("objname [%s], dynp %p, dl_data %p, objtype %x laddr %lx, loff %lx\n",
+ objname, dynp, dl_data, objtype, laddr, loff);
+#endif
object = (elf_object_t *)_dl_malloc(sizeof(elf_object_t));
@@ -70,10 +76,10 @@ _dl_add_object(const char *objname, Elf32_Dyn *dynp,
object->load_dyn = dynp;
while(dynp->d_tag != DT_NULL) {
- if(dynp->d_tag < DT_PROCNUM) {
+ if(dynp->d_tag < DT_NUM) {
object->Dyn.info[dynp->d_tag] = dynp->d_un.d_val;
}
- else if(dynp->d_tag >= DT_LOPROC && dynp->d_tag < DT_LOPROC + DT_PROCNUM) {
+ else if(dynp->d_tag >= DT_LOPROC && dynp->d_tag < DT_LOPROC + DT_NUM) {
object->Dyn.info[dynp->d_tag + DT_NUM - DT_LOPROC] = dynp->
d_un.d_val;
}
@@ -103,13 +109,15 @@ d_un.d_val;
if(object->Dyn.info[DT_SONAME])
object->Dyn.info[DT_SONAME] += loff;
if(object->Dyn.info[DT_RPATH])
- object->Dyn.info[DT_RPATH] += loff;
+ object->Dyn.info[DT_RPATH] += object->Dyn.info[DT_STRTAB];
if(object->Dyn.info[DT_REL])
object->Dyn.info[DT_REL] += loff;
if(object->Dyn.info[DT_INIT])
object->Dyn.info[DT_INIT] += loff;
if(object->Dyn.info[DT_FINI])
object->Dyn.info[DT_FINI] += loff;
+ if(object->Dyn.info[DT_JMPREL])
+ object->Dyn.info[DT_JMPREL] += loff;
object->buckets = object->dyn.hash;
if(object->buckets != 0) {
@@ -119,7 +127,7 @@ d_un.d_val;
}
if(dl_data) {
- object->phdrp = (Elf32_Phdr *) dl_data[AUX_phdr];
+ object->phdrp = (Elf_Phdr *) dl_data[AUX_phdr];
object->phdrc = dl_data[AUX_phnum];
}
object->obj_type = objtype;
@@ -169,15 +177,15 @@ _dl_lookup_object(const char *name)
}
-Elf32_Addr
+Elf_Addr
_dl_find_symbol(const char *name, elf_object_t *startlook,
- const Elf32_Sym **ref, int myself)
+ const Elf_Sym **ref, int myself, int warnnotfound)
{
u_int32_t h = 0;
const char *p = name;
elf_object_t *object;
- const Elf32_Sym *weak_sym = 0;
- Elf32_Addr weak_offs = 0;
+ const Elf_Sym *weak_sym = 0;
+ Elf_Addr weak_offs = 0;
while(*p) {
u_int32_t g;
@@ -189,7 +197,7 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
}
for(object = startlook; object; object = (myself ? 0 : object->next)) {
- const Elf32_Sym *symt;
+ const Elf_Sym *symt;
const char *strt;
u_int32_t si;
@@ -198,16 +206,16 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
for(si = object->buckets[h % object->nbuckets];
si != STN_UNDEF; si = object->chains[si]) {
- const Elf32_Sym *sym = symt + si;
+ const Elf_Sym *sym = symt + si;
if(sym->st_value == 0 ||
sym->st_shndx == SHN_UNDEF) {
continue;
}
- if(ELF32_ST_TYPE(sym->st_info) != STT_NOTYPE &&
- ELF32_ST_TYPE(sym->st_info) != STT_OBJECT &&
- ELF32_ST_TYPE(sym->st_info) != STT_FUNC) {
+ if(ELF_ST_TYPE(sym->st_info) != STT_NOTYPE &&
+ ELF_ST_TYPE(sym->st_info) != STT_OBJECT &&
+ ELF_ST_TYPE(sym->st_info) != STT_FUNC) {
continue;
}
@@ -215,11 +223,11 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
continue;
}
- if(ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
+ if(ELF_ST_BIND(sym->st_info) == STB_GLOBAL) {
*ref = sym;
return(object->load_offs);
}
- else if(ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
+ else if(ELF_ST_BIND(sym->st_info) == STB_WEAK) {
if(!weak_sym) {
weak_sym = sym;
weak_offs = object->load_offs;
@@ -227,8 +235,13 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
}
}
}
- if(!weak_sym && *ref && ELF32_ST_BIND((*ref)->st_info) != STB_WEAK) {
- _dl_printf("%s: undefined symbol '%s'\n", _dl_progname, name);
+ if (warnnotfound) {
+ if(!weak_sym &&
+ *ref && ELF_ST_BIND((*ref)->st_info) != STB_WEAK)
+ {
+ _dl_printf("%s: undefined symbol '%s'\n",
+ _dl_progname, name);
+ }
}
*ref = weak_sym;
return(weak_offs);
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 7186dd6661c..9106a703c87 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.2 2001/03/30 01:35:21 drahn Exp $ */
+/* $OpenBSD: resolve.h,v 1.3 2001/04/02 23:11:21 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -50,10 +50,10 @@ typedef struct load_list {
* with struct link_map in sys/link.h
*/
typedef struct elf_object {
- Elf32_Addr load_addr; /* Real load address */
- Elf32_Addr load_offs; /* Load offset from link address */
+ Elf_Addr load_addr; /* Real load address */
+ Elf_Addr load_offs; /* Load offset from link address */
char *load_name; /* Pointer to object name */
- Elf32_Dyn *load_dyn; /* Pointer to object dynamic data */
+ Elf_Dyn *load_dyn; /* Pointer to object dynamic data */
struct elf_object *next;
struct elf_object *prev;
/* End struct link_map compatible */
@@ -63,33 +63,33 @@ typedef struct elf_object {
u_int32_t load_size;
union {
- u_int32_t info[DT_NUM + DT_PROCNUM];
+ u_long info[DT_NUM + DT_PROCNUM];
struct {
- Elf32_Word null; /* Not used */
- Elf32_Word needed; /* Not used */
- Elf32_Word pltrelsz;
- Elf32_Word *pltgot;
- Elf32_Word *hash;
+ Elf_Word null; /* Not used */
+ Elf_Word needed; /* Not used */
+ Elf_Word pltrelsz;
+ Elf_Word *pltgot;
+ Elf_Word *hash;
const char *strtab;
- const Elf32_Sym *symtab;
- Elf32_Rela *rela;
- Elf32_Word relasz;
- Elf32_Word relaent;
- Elf32_Word strsz;
- Elf32_Word syment;
+ const Elf_Sym *symtab;
+ Elf_RelA *rela;
+ Elf_Word relasz;
+ Elf_Word relaent;
+ Elf_Word strsz;
+ Elf_Word syment;
void (*init)(void);
void (*fini)(void);
const char *soname;
const char *rpath;
- Elf32_Word symbolic;
- Elf32_Rel *rel;
- Elf32_Word relsz;
- Elf32_Word relent;
- Elf32_Word pltrel;
- Elf32_Word debug;
- Elf32_Word textrel;
- Elf32_Word jmprel;
- Elf32_Word bind_now;
+ Elf_Word symbolic;
+ Elf_Rel *rel;
+ Elf_Word relsz;
+ Elf_Word relent;
+ Elf_Word pltrel;
+ Elf_Word debug;
+ Elf_Word textrel;
+ Elf_Word jmprel;
+ Elf_Word bind_now;
} u;
} Dyn;
#define dyn Dyn.u
@@ -101,7 +101,7 @@ typedef struct elf_object {
#define STAT_GOT_DONE 2
#define STAT_INIT_DONE 4
- Elf32_Phdr *phdrp;
+ Elf_Phdr *phdrp;
int phdrc;
int refcount;
@@ -111,19 +111,19 @@ typedef struct elf_object {
#define OBJTYPE_LIB 3
#define OBJTYPE_DLO 4
- u_int32_t *buckets;
+ u_long *buckets;
u_int32_t nbuckets;
- u_int32_t *chains;
+ u_long *chains;
u_int32_t nchains;
- Elf32_Dyn *dynamic;
+ Elf_Dyn *dynamic;
} elf_object_t;
extern void _dl_rt_resolve(void);
-extern elf_object_t *_dl_add_object(const char *objname, Elf32_Dyn *dynp,
- const u_int32_t *, const int objtype,
- const int laddr, const int loff);
+extern elf_object_t *_dl_add_object(const char *objname, Elf_Dyn *dynp,
+ const u_long *, const int objtype,
+ const long laddr, const long loff);
extern void _dl_remove_object(elf_object_t *object);
extern elf_object_t *_dl_lookup_object(const char *objname);
@@ -133,8 +133,8 @@ extern void _dl_unload_shlib(elf_object_t *object);
extern int _dl_md_reloc(elf_object_t *object, int rel, int relsz);
extern void _dl_md_reloc_got(elf_object_t *object, int lazy);
-Elf32_Addr _dl_find_symbol(const char *name, elf_object_t *startlook,
- const Elf32_Sym **ref, int myself, int warnnotfound);
+Elf_Addr _dl_find_symbol(const char *name, elf_object_t *startlook,
+ const Elf_Sym **ref, int myself, int warnnotfound);
void * _dl_malloc(const int size);
void _dl_free(void *);
diff --git a/libexec/ld.so/strdup.c b/libexec/ld.so/strdup.c
index 9b84c6398ae..c5d7615b2cb 100644
--- a/libexec/ld.so/strdup.c
+++ b/libexec/ld.so/strdup.c
@@ -1,5 +1,6 @@
-/* $OpenBSD: strdup.c,v 1.2 2001/01/28 19:34:29 niklas Exp $ */
+/* $OpenBSD: strdup.c,v 1.3 2001/04/02 23:11:21 drahn Exp $ */
+#include <string.h>
void * _dl_malloc(int);