summaryrefslogtreecommitdiff
path: root/libexec/ld.so
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-06-06 12:45:18 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-06-06 12:45:18 +0000
commit26739eb037c6a803a6098e1d9c79b12868c79290 (patch)
tree46fd8fd556e65e2eae87e2005018e37def7db845 /libexec/ld.so
parentea11f3bcdce1b0c984aaaaa9f249fca110c1c46c (diff)
more cleaning
Diffstat (limited to 'libexec/ld.so')
-rw-r--r--libexec/ld.so/dlfcn.c81
1 files changed, 41 insertions, 40 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index c9c743e0a63..025ae5866d3 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.5 2001/06/06 12:31:52 art Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.6 2001/06/06 12:45:17 art Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -60,11 +60,11 @@ dlopen(const char *libname, int how)
DL_DEB(("loading: %s\n", libname));
object = _dl_load_shlib(libname, _dl_objects, OBJTYPE_DLO);
- if(object == 0) {
+ if (object == 0) {
return((void *)0);
}
- if(object->refcount > 1) {
+ if (object->refcount > 1) {
return((void *)object); /* Already loaded */
}
@@ -76,18 +76,19 @@ dlopen(const char *libname, int how)
* resolving undefined symbols. This is not yet done. XXX
*/
dynobj = object;
- while(dynobj) {
+ while (dynobj) {
elf_object_t *tmpobj = dynobj;
- for(dynp = dynobj->load_dyn; dynp->d_tag; dynp++) {
+
+ for (dynp = dynobj->load_dyn; dynp->d_tag; dynp++) {
const char *libname;
elf_object_t *depobj;
- if(dynp->d_tag != DT_NEEDED) {
+ if (dynp->d_tag != DT_NEEDED) {
continue;
}
libname = dynobj->dyn.strtab + dynp->d_un.d_val;
depobj = _dl_load_shlib(libname, dynobj, OBJTYPE_DLO);
- if(!depobj) {
+ if (!depobj) {
_dl_exit(4);
}
tmpobj->dep_next = _dl_malloc(sizeof(elf_object_t));
@@ -122,28 +123,28 @@ dlsym(void *handle, const char *name)
object = (elf_object_t *)handle;
dynobj = _dl_objects;
- while(dynobj && dynobj != object) {
+ while (dynobj && dynobj != object) {
dynobj = dynobj->next;
}
- if(!dynobj || object != dynobj) {
+ if (!dynobj || object != dynobj) {
_dl_errno = DL_INVALID_HANDLE;
return(0);
}
retval = (void *)_dl_find_symbol(name, object, &sym, 1, 1);
- if(retval) {
+ if (retval) {
retval += sym->st_value;
- }
- else {
+ } else {
_dl_errno = DL_NO_SYMBOL;
}
- return(retval);
+
+ return (retval);
}
int
dlctl(void *handle, int command, void *data)
{
- switch(command) {
+ switch (command) {
#ifdef __mips__
case DL_DUMP_MAP:
@@ -166,14 +167,15 @@ dlclose(void *handle)
retval = _dl_real_close(handle);
#ifdef __mips__
- if(_dl_debug_map->r_brk) {
+ if (_dl_debug_map->r_brk) {
_dl_debug_map->r_state = RT_DELETE;
(*((void (*)())_dl_debug_map->r_brk))();
_dl_debug_map->r_state = RT_CONSISTENT;
(*((void (*)())_dl_debug_map->r_brk))();
}
#endif /* __mips__ */
- return(retval);
+
+ return (retval);
}
static int
@@ -184,22 +186,22 @@ _dl_real_close(void *handle)
object = (elf_object_t *)handle;
dynobj = _dl_objects;
- while(dynobj && dynobj != object) {
+ while (dynobj && dynobj != object) {
dynobj = dynobj->next;
}
- if(!dynobj || object != dynobj) {
+ if (!dynobj || object != dynobj) {
_dl_errno = DL_INVALID_HANDLE;
- return(1);
+ return (1);
}
- if(object->refcount == 1) {
- if(dynobj->dep_next) {
+ if (object->refcount == 1) {
+ if (dynobj->dep_next) {
_dl_unload_deps(dynobj);
}
}
_dl_unload_shlib(object);
- return(0);
+ return (0);
}
/*
@@ -212,9 +214,9 @@ _dl_unload_deps(elf_object_t *object)
elf_object_t *depobj;
depobj = object->dep_next;
- while(depobj) {
- if(depobj->next->refcount == 1) { /* This object will go away */
- if(depobj->next->dep_next) {
+ while (depobj) {
+ if (depobj->next->refcount == 1) { /* This object will go away */
+ if (depobj->next->dep_next) {
_dl_unload_deps(depobj->next);
}
_dl_unload_shlib(depobj->next);
@@ -231,42 +233,41 @@ _dl_unload_deps(elf_object_t *object)
const char *
dlerror()
{
- switch(_dl_errno) {
+ switch (_dl_errno) {
case DL_NOT_FOUND:
- return("File not found");
+ return ("File not found");
case DL_CANT_OPEN:
- return("Can't open file");
+ return ("Can't open file");
case DL_NOT_ELF:
- return("File not an ELF object");
+ return ("File not an ELF object");
case DL_CANT_OPEN_REF:
- return("Can't open referenced object");
+ return ("Can't open referenced object");
case DL_CANT_MMAP:
- return("Can't map ELF object");
+ return ("Can't map ELF object");
case DL_INVALID_HANDLE:
- return("Invalid handle");
+ return ("Invalid handle");
case DL_NO_SYMBOL:
- return("Unable to resolve symbol");
+ return ("Unable to resolve symbol");
case DL_INVALID_CTL:
- return("Invalid dlctl() command");
+ return ("Invalid dlctl() command");
default:
- return("Unknown error");
+ return ("Unknown error");
}
}
-
void
_dl_show_objects()
{
elf_object_t *object;
-static char *otyp[] = {
- "none", "rtld", "exe ", "rlib", "dlib"
-};
+ static char *otyp[] = {
+ "none", "rtld", "exe ", "rlib", "dlib"
+ };
object = _dl_objects;
_dl_printf("\tStart End Type Ref Name\n");
- while(object) {
+ while (object) {
_dl_printf("\t%X %X %s %d %s\n", object->load_addr,
object->load_size, otyp[object->obj_type],
object->refcount, object->load_name);