summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-02-02 16:57:59 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-02-02 16:57:59 +0000
commit9de3e81d3ae0edf58696f5ef45356a2fbc615b9e (patch)
tree68a91274148408935b2018b28ae24be4b18c8c26
parent09e6d0d93f5a520c5819dda4ad20beeb4823f0d9 (diff)
knf & ansi; drahn ok
-rw-r--r--libexec/ld.so/dir.c19
-rw-r--r--libexec/ld.so/dl_printf.c4
-rw-r--r--libexec/ld.so/dlfcn.c26
-rw-r--r--libexec/ld.so/i386/ldasm.S6
-rw-r--r--libexec/ld.so/i386/rtld_machine.c8
-rw-r--r--libexec/ld.so/library.c35
-rw-r--r--libexec/ld.so/loader.c33
-rw-r--r--libexec/ld.so/mips/ldasm.S6
-rw-r--r--libexec/ld.so/mips/rtld_machine.c8
-rw-r--r--libexec/ld.so/powerpc/ldasm.S4
-rw-r--r--libexec/ld.so/powerpc/rtld_machine.c12
-rw-r--r--libexec/ld.so/resolve.c21
-rw-r--r--libexec/ld.so/resolve.h6
-rw-r--r--libexec/ld.so/sod.c21
-rw-r--r--libexec/ld.so/sparc/ldasm.S6
-rw-r--r--libexec/ld.so/sparc/rtld_machine.c12
-rw-r--r--libexec/ld.so/sparc64/ldasm.S4
-rw-r--r--libexec/ld.so/sparc64/rtld_machine.c14
-rw-r--r--libexec/ld.so/util.c16
19 files changed, 114 insertions, 147 deletions
diff --git a/libexec/ld.so/dir.c b/libexec/ld.so/dir.c
index 5526612d02b..a9b2707b7db 100644
--- a/libexec/ld.so/dir.c
+++ b/libexec/ld.so/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.5 2003/01/31 22:25:34 drahn Exp $ */
+/* $OpenBSD: dir.c,v 1.6 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -52,13 +52,11 @@ static char rcsid[] = ": opendir.c,v 1.6 1998/08/15 08:10:14 deraadt Exp $";
long _dl_telldir(const DIR *dirp);
void _dl_seekdir(DIR *dirp, long loc);
-
/*
* Open a directory.
*/
DIR *
-_dl_opendir(name)
- const char *name;
+_dl_opendir(const char *name)
{
DIR *dirp;
int fd;
@@ -120,8 +118,7 @@ static char rcsid[] = "$ closedir.c,v 1.3 1998/11/20 11:18:37 d Exp $";
* close a directory.
*/
int
-_dl_closedir(dirp)
- DIR *dirp;
+_dl_closedir(DIR *dirp)
{
int fd;
int ret;
@@ -144,8 +141,7 @@ static char rcsid[] = "$ readdir.c,v 1.5 2001/05/17 20:20:36 rees Exp $";
* get next entry in a directory.
*/
struct dirent *
-_dl_readdir(dirp)
- DIR *dirp;
+_dl_readdir(DIR *dirp)
{
struct dirent *dp;
@@ -211,8 +207,7 @@ static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
* return a pointer into a directory
*/
long
-_dl_telldir(dirp)
- const DIR *dirp;
+_dl_telldir(const DIR *dirp)
{
int index;
struct ddloc *lp;
@@ -233,9 +228,7 @@ _dl_telldir(dirp)
* Only values returned by "telldir" should be passed to seekdir.
*/
void
-_dl_seekdir(dirp, loc)
- DIR *dirp;
- long loc;
+_dl_seekdir(DIR *dirp, long loc)
{
struct ddloc *lp;
struct ddloc **prevlp;
diff --git a/libexec/ld.so/dl_printf.c b/libexec/ld.so/dl_printf.c
index 0a33ee33037..200d9a26052 100644
--- a/libexec/ld.so/dl_printf.c
+++ b/libexec/ld.so/dl_printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dl_printf.c,v 1.10 2002/10/04 03:01:42 drahn Exp $ */
+/* $OpenBSD: dl_printf.c,v 1.11 2003/02/02 16:57:58 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -185,7 +185,7 @@ reswitch:
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
if (lflag)
l = (sizeof(ulong) * 8) - 4;
- else
+ else
l = (sizeof(u_int) * 8) - 4;
while (l >= 0) {
put("0123456789abcdef"[(ul >> l) & 0xf], fd);
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index 5b418c8c9ff..67e6856e2c3 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.23 2002/11/23 04:09:34 drahn Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.24 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -68,11 +68,11 @@ dlopen(const char *libname, int how)
return((void *)object); /* Already loaded */
/*
- * Check for 'needed' objects. For each 'needed' object we
- * create a 'shadow' object and add it to a list attached to
- * the object so we know our dependencies. This list should
- * also be used to determine the library search order when
- * resolving undefined symbols. This is not yet done. XXX
+ * Check for 'needed' objects. For each 'needed' object we
+ * create a 'shadow' object and add it to a list attached to
+ * the object so we know our dependencies. This list should
+ * also be used to determine the library search order when
+ * resolving undefined symbols. This is not yet done. XXX
*/
dynobj = object;
while (dynobj) {
@@ -192,8 +192,8 @@ _dl_real_close(void *handle)
}
/*
- * Scan through the shadow dep list and 'unload' every library
- * we depend upon. Shadow objects are removed when removing ourself.
+ * Scan through the shadow dep list and 'unload' every library
+ * we depend upon. Shadow objects are removed when removing ourself.
*/
static void
_dl_unload_deps(elf_object_t *object)
@@ -212,12 +212,10 @@ _dl_unload_deps(elf_object_t *object)
}
/*
- * dlerror()
- *
- * Return a character string describing the last dl... error occurred.
+ * Return a character string describing the last dl... error occurred.
*/
const char *
-dlerror()
+dlerror(void)
{
switch (_dl_errno) {
case 0: /* NO ERROR */
@@ -244,7 +242,7 @@ dlerror()
}
void
-_dl_show_objects()
+_dl_show_objects(void)
{
elf_object_t *object;
char *objtypename;
@@ -254,7 +252,7 @@ _dl_show_objects()
object = _dl_objects;
if (_dl_traceld)
outputfd = STDOUT_FILENO;
- else
+ else
outputfd = STDERR_FILENO;
if (sizeof(long) == 8)
diff --git a/libexec/ld.so/i386/ldasm.S b/libexec/ld.so/i386/ldasm.S
index c3ff47b5234..cf20d25310d 100644
--- a/libexec/ld.so/i386/ldasm.S
+++ b/libexec/ld.so/i386/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.3 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: ldasm.S,v 1.4 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -266,13 +266,13 @@ _dl_bind_start:
pushl %edi
pushl %ds
pushl %es
-
+
pushl 44(%esp) # Copy of reloff
pushl 44(%esp) # Copy of obj
call _dl_bind@PLT # Call the binder
addl $8,%esp # pop binder args
movl %eax,44(%esp) # Store function to be called in obj
-
+
popl %es # restore registers
popl %ds
popl %edi
diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c
index e8ce94c1927..750bb2f4c1b 100644
--- a/libexec/ld.so/i386/rtld_machine.c
+++ b/libexec/ld.so/i386/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.6 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.7 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -384,7 +384,7 @@ _dl_bind(elf_object_t *object, int index)
sigfillset(&nmask);
_dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
_dl_mprotect((void*)object->got_addr, object->got_size,
- PROT_READ|PROT_WRITE);
+ PROT_READ|PROT_WRITE);
}
_dl_reloc_plt(addr, ooff + this->st_value);
@@ -471,7 +471,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
}
/* PLT is already RO on i386, no point in mprotecting it, just GOT */
- if (object->got_addr != NULL && object->got_size != 0)
+ if (object->got_addr != NULL && object->got_size != 0)
_dl_mprotect((void*)object->got_addr, object->got_size,
- PROT_READ);
+ PROT_READ);
}
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c
index 97efb7450bd..9638f03995e 100644
--- a/libexec/ld.so/library.c
+++ b/libexec/ld.so/library.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library.c,v 1.25 2003/01/30 03:46:46 drahn Exp $ */
+/* $OpenBSD: library.c,v 1.26 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -78,15 +78,13 @@ _dl_match_file(struct sod *sodp, char *name, int namelen)
lname = name;
if (sodp->sod_library) {
- if (_dl_strncmp(name, "lib", 3)) {
+ if (_dl_strncmp(name, "lib", 3))
return 0;
- }
lname += 3;
}
if (_dl_strncmp(lname, (char *)sodp->sod_name,
- _dl_strlen((char *)sodp->sod_name))) {
+ _dl_strlen((char *)sodp->sod_name)))
return 0;
- }
_dl_build_sod(name, &lsod);
@@ -111,14 +109,11 @@ char _dl_hint_store[MAXPATHLEN];
char *
_dl_find_shlib(struct sod *sodp, const char *searchpath, int nohints)
{
- int len;
- char *hint;
- char lp[PATH_MAX + 10];
- char *path;
+ char *hint, lp[PATH_MAX + 10], *path;
+ struct dirent *dp;
const char *pp;
+ int match, len;
DIR *dd;
- struct dirent *dp;
- int match;
/* if we are to search default directories, and hints
* are not to be used, search the standard path from ldconfig
@@ -156,6 +151,7 @@ _dl_find_shlib(struct sod *sodp, const char *searchpath, int nohints)
pp = 0;
}
}
+
/*
* For each directory in the searchpath, read the directory
* entries looking for a match to sod. filename compare is
@@ -180,7 +176,8 @@ nohints:
while ((dp = _dl_readdir(dd)) != NULL) {
if (_dl_match_file(sodp, dp->d_name,
dp->d_namlen)) {
- /* When a match is found, sodp is
+ /*
+ * When a match is found, sodp is
* updated with the minor found.
* We continue looking at this
* directory, thus this will find
@@ -190,7 +187,6 @@ nohints:
* so that it doesn't have to be
* recreated from the hint.
*/
-
match = 1;
len = _dl_strlcpy(_dl_hint_store, lp,
MAXPATHLEN);
@@ -199,7 +195,7 @@ nohints:
len++;
}
_dl_strlcpy(&_dl_hint_store[len],
- dp->d_name, MAXPATHLEN-len);
+ dp->d_name, MAXPATHLEN-len);
}
}
_dl_closedir(dd);
@@ -235,12 +231,10 @@ nohints:
elf_object_t *
_dl_load_shlib(const char *libname, elf_object_t *parent, int type)
{
+ int try_any_minor, ignore_hints;
+ struct sod sod, req_sod;
elf_object_t *object;
- struct sod sod;
- struct sod req_sod;
char *hint;
- int try_any_minor;
- int ignore_hints;
try_any_minor = 0;
ignore_hints = 0;
@@ -251,7 +245,6 @@ _dl_load_shlib(const char *libname, elf_object_t *parent, int type)
return(object);
}
-
_dl_build_sod(libname, &sod);
req_sod = sod;
@@ -514,9 +507,9 @@ _dl_link_sub(elf_object_t *dep, elf_object_t *p)
if (p->first_child) {
p->last_child->next_sibling = n;
p->last_child = n;
- } else {
+ } else
p->first_child = p->last_child = n;
- }
+
DL_DEB(("linking dep %s as child of %s\n", dep->load_name,
p->load_name));
}
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index 0302039a9f6..7be6c73e70d 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.53 2003/01/30 03:46:46 drahn Exp $ */
+/* $OpenBSD: loader.c,v 1.54 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -95,8 +95,7 @@ _dl_dtors(void)
}
void
-_dl_dopreload(paths)
- char *paths;
+_dl_dopreload(char *paths)
{
char *cp, *dp;
@@ -186,8 +185,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
exe_obj = _dl_add_object(argv[0],
(Elf_Dyn *)phdp->p_vaddr, dl_data, OBJTYPE_EXE,
0, 0);
- }
- else if (phdp->p_type == PT_INTERP) {
+ } else if (phdp->p_type == PT_INTERP) {
us = _dl_strdup((char *)phdp->p_vaddr);
}
phdp++;
@@ -260,18 +258,19 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
sym = NULL;
ooff = _dl_find_symbol("atexit", _dl_objects, &sym,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, "");
- if (sym == NULL) {
+ if (sym == NULL)
_dl_printf("cannot find atexit, destructors will not be run!\n");
- } else {
- (*(void (*)(Elf_Addr))(sym->st_value + ooff))((Elf_Addr)_dl_dtors);
- }
+ else
+ (*(void (*)(Elf_Addr))(sym->st_value + ooff))
+ ((Elf_Addr)_dl_dtors);
}
/*
* Finally make something to help gdb when poking around in the code.
*/
#ifdef __mips__
- map_link = (struct r_debug **)(exe_obj->Dyn.info[DT_MIPS_RLD_MAP - DT_LOPROC + DT_NUM]);
+ map_link = (struct r_debug **)(exe_obj->Dyn.info[DT_MIPS_RLD_MAP -
+ DT_LOPROC + DT_NUM]);
#else
map_link = NULL;
for (dynp = exe_obj->load_dyn; dynp->d_tag; dynp++) {
@@ -280,9 +279,8 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
break;
}
}
- if (dynp->d_tag != DT_DEBUG) {
+ if (dynp->d_tag != DT_DEBUG)
DL_DEB(("failed to mark DTDEBUG\n"));
- }
#endif
if (map_link) {
debug_map = (struct r_debug *)_dl_malloc(sizeof(*debug_map));
@@ -314,15 +312,13 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
void
_dl_boot_bind(const long sp, long *dl_data)
{
+ struct elf_object dynld; /* Resolver data for the loader */
AuxInfo *auxstack;
long *stack;
Elf_Dyn *dynp;
- int n;
- int argc;
- char **argv;
- char **envp;
+ int n, argc;
+ char **argv, **envp;
long loff;
- struct elf_object dynld; /* Resolver data for the loader */
/*
* Scan argument and environment vectors. Find dynamic
@@ -411,7 +407,6 @@ _dl_boot_bind(const long sp, long *dl_data)
if (dynld.Dyn.info[val] != 0)
dynld.Dyn.info[val] += loff;
}
-
}
{
@@ -444,7 +439,6 @@ _dl_boot_bind(const long sp, long *dl_data)
RELOC_REL(rp, sp, ra, loff);
rp++;
}
-
}
for (n = 0; n < 2; n++) {
@@ -573,5 +567,4 @@ _dl_unsetenv(const char *var, char **env)
}
env++;
}
-
}
diff --git a/libexec/ld.so/mips/ldasm.S b/libexec/ld.so/mips/ldasm.S
index 9d5b9a503a8..a79b35f4f64 100644
--- a/libexec/ld.so/mips/ldasm.S
+++ b/libexec/ld.so/mips/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.3 2002/10/23 12:38:29 pefo Exp $ */
+/* $OpenBSD: ldasm.S,v 1.4 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -39,11 +39,11 @@
* char *kargv[1]; size depends on kargc
* char kargstr[1]; size varies
* char kenvstr[1]; size varies
- * };
+ * };
*/
LEAF(_dl_start) /* Not really LEAF, but we simplify */
- addu sp, -64 # Some space.
+ addu sp, -64 # Some space.
.cprestore 12
la a1, 1f
diff --git a/libexec/ld.so/mips/rtld_machine.c b/libexec/ld.so/mips/rtld_machine.c
index 45467e3b9cf..cc9644cf491 100644
--- a/libexec/ld.so/mips/rtld_machine.c
+++ b/libexec/ld.so/mips/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.10 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.11 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -226,10 +226,10 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value));
}
object->status |= STAT_GOT_DONE;
- if (object->got_addr != NULL && object->got_size != 0)
+ if (object->got_addr != NULL && object->got_size != 0)
_dl_mprotect((void*)object->got_addr, object->got_size,
- PROT_READ);
- if (object->plt_addr != NULL && object->plt_size != 0)
+ PROT_READ);
+ if (object->plt_addr != NULL && object->plt_size != 0)
_dl_mprotect((void*)object->plt_addr, object->plt_size,
PROT_READ|PROT_EXEC);
}
diff --git a/libexec/ld.so/powerpc/ldasm.S b/libexec/ld.so/powerpc/ldasm.S
index bc9ab5e3b2a..02c85582092 100644
--- a/libexec/ld.so/powerpc/ldasm.S
+++ b/libexec/ld.so/powerpc/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.9 2002/12/09 20:56:34 drahn Exp $ */
+/* $OpenBSD: ldasm.S,v 1.10 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -80,7 +80,7 @@ ENTRY(_dl_start)
* operation that would be below would calulate.
*/
add 28, 18, 5
- mr 6, 5 # save offset for later use
+ mr 6, 5 # save offset for later use
/* mprotect GOT-4 for correct execution of blrl instruction */
li 0, SYS_mprotect
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c
index b1040ac86a6..db8093904f8 100644
--- a/libexec/ld.so/powerpc/rtld_machine.c
+++ b/libexec/ld.so/powerpc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.21 2003/01/30 06:40:38 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.22 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -66,7 +66,7 @@ void _dl_syncicache(char *from, size_t len);
lval &= ~0xfc000000; \
lval |= 0x48000000; \
(from) = lval; \
-}while(0)
+} while (0)
/* these are structures/functions offset from PLT region */
#define PLT_CALL_OFFSET 6
@@ -248,7 +248,7 @@ _dl_printf("rel1 r_addr %x val %x loff %x ooff %x addend %x\n", r_addr,
relas->r_addend;
Elf32_Addr val = target - (Elf32_Addr)r_addr;
- if(!B24_VALID_RANGE(val)){
+ if (!B24_VALID_RANGE(val)){
int index;
#ifdef DL_PRINTF_DEBUG
_dl_printf(" ooff %x, sym val %x, addend %x"
@@ -296,7 +296,7 @@ _dl_printf(" symn [%s] val 0x%x\n", symn, val);
{
Elf32_Addr val = ooff + this->st_value +
relas->r_addend - (Elf32_Addr)r_addr;
- if(!B24_VALID_RANGE(val)){
+ if (!B24_VALID_RANGE(val)){
/* invalid offset */
_dl_exit(20);
}
@@ -520,7 +520,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
PROT_READ|PROT_EXEC); /* only PPC is PROT_EXE */
_dl_syncicache((void*)object->got_addr, 4);
}
- if (object->plt_addr != NULL && object->plt_size != 0)
+ if (object->plt_addr != NULL && object->plt_size != 0)
_dl_mprotect((void*)object->plt_addr, object->plt_size,
PROT_READ|PROT_EXEC);
}
@@ -561,7 +561,7 @@ _dl_bind(elf_object_t *object, int reloff)
sigfillset(&nmask);
_dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
_dl_mprotect((void*)object->plt_addr, object->plt_size,
- PROT_READ|PROT_WRITE|PROT_EXEC);
+ PROT_READ|PROT_WRITE|PROT_EXEC);
}
value = ooff + this->st_value;
diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c
index 903b4f1399b..c3205c527a6 100644
--- a/libexec/ld.so/resolve.c
+++ b/libexec/ld.so/resolve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.c,v 1.16 2003/01/30 03:46:46 drahn Exp $ */
+/* $OpenBSD: resolve.c,v 1.17 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -46,12 +46,12 @@ elf_object_t *_dl_objects;
elf_object_t *_dl_last_object;
/*
- * Initialize and add a new dynamic object to the object list.
- * Perform necessary relocations of pointers.
+ * Initialize and add a new dynamic object to the object list.
+ * Perform necessary relocations of pointers.
*/
elf_object_t *
_dl_add_object(const char *objname, Elf_Dyn *dynp, const u_long *dl_data,
- const int objtype, const long laddr, const long loff)
+ const int objtype, const long laddr, const long loff)
{
elf_object_t *object;
#if 0
@@ -194,8 +194,7 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
h &= ~g;
}
- for (object = startlook;
- object;
+ for (object = startlook; object;
object = ((flags & SYM_SEARCH_SELF) ? 0 : object->next)) {
const Elf_Sym *symt = object->dyn.symtab;
const char *strt = object->dyn.strtab;
@@ -215,8 +214,7 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
continue;
symn = strt + sym->st_name;
- if (sym != *ref &&
- _dl_strcmp(symn, name))
+ if (sym != *ref && _dl_strcmp(symn, name))
continue;
/* allow this symbol if we are referring to a function
@@ -226,11 +224,10 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
* if flags has SYM_PLT set, we must have actual
* symbol, so this symbol is skipped.
*/
- if (sym->st_shndx == SHN_UNDEF) {
+ if (sym->st_shndx == SHN_UNDEF) {
if ((flags & SYM_PLT) || sym->st_value == 0 ||
- ELF_ST_TYPE(sym->st_info) != STT_FUNC) {
+ ELF_ST_TYPE(sym->st_info) != STT_FUNC)
continue;
- }
}
if (ELF_ST_BIND(sym->st_info) == STB_GLOBAL) {
@@ -268,5 +265,5 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
weak_symn);
_dl_printf("relink your program\n");
}
- return(weak_offs);
+ return (weak_offs);
}
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 702a296b0b9..752e721363d 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.20 2003/01/30 03:46:46 drahn Exp $ */
+/* $OpenBSD: resolve.h,v 1.21 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -148,8 +148,8 @@ Elf_Addr _dl_find_symbol(const char *name, elf_object_t *startlook,
const Elf_Sym **ref, int flags, int sym_size, const char *module_name);
/*
* defines for _dl_find_symbol() flag field, three bits of meaning
- * myself - clear: search all objects, set: search only this object
- * warnnotfound - clear: no warning, set: warn if not found
+ * myself - clear: search all objects, set: search only this object
+ * warnnotfound - clear: no warning, set: warn if not found
* inplt - clear: possible plt ref set: real matching function.
*
* inplt - due to how ELF handles function addresses in shared libraries
diff --git a/libexec/ld.so/sod.c b/libexec/ld.so/sod.c
index d1bf155e5a2..f8589611ddf 100644
--- a/libexec/ld.so/sod.c
+++ b/libexec/ld.so/sod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sod.c,v 1.15 2002/07/29 22:43:36 art Exp $ */
+/* $OpenBSD: sod.c,v 1.16 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -55,9 +55,7 @@ int _dl_hinthash(char *cp, int vmajor, int vminor);
* Populate sod struct for dlopen's call to map_object
*/
void
-_dl_build_sod(name, sodp)
- const char *name;
- struct sod *sodp;
+_dl_build_sod(const char *name, struct sod *sodp)
{
unsigned int tuplet;
int major, minor;
@@ -116,9 +114,8 @@ _dl_build_sod(name, sodp)
goto backout;
}
}
- if (realname == NULL) {
+ if (realname == NULL)
goto backout;
- }
cp = (char *)sodp->sod_name;
sodp->sod_name = (long)_dl_strdup(realname);
_dl_free(cp);
@@ -142,7 +139,7 @@ char *_dl_hint_search_path = NULL;
#define HINTS_VALID (hheader != NULL && hheader != (struct hints_header *)-1)
void
-_dl_maphints()
+_dl_maphints(void)
{
caddr_t addr;
@@ -197,10 +194,7 @@ _dl_maphints()
}
char *
-_dl_findhint(name, major, minor, prefered_path)
- char *name;
- int major, minor;
- char *prefered_path;
+_dl_findhint(char *name, int major, int minor, char *prefered_path)
{
struct hints_bucket *bp;
@@ -253,10 +247,9 @@ _dl_findhint(name, major, minor, prefered_path)
/* No hints available for name */
return NULL;
}
+
int
-_dl_hinthash(cp, vmajor, vminor)
- char *cp;
- int vmajor, vminor;
+_dl_hinthash(char *cp, int vmajor, int vminor)
{
int k = 0;
diff --git a/libexec/ld.so/sparc/ldasm.S b/libexec/ld.so/sparc/ldasm.S
index c7a3cf5f86c..b5beae47e50 100644
--- a/libexec/ld.so/sparc/ldasm.S
+++ b/libexec/ld.so/sparc/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.10 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: ldasm.S,v 1.11 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 2001 Jason L. Wright (jason@thought.net)
@@ -104,7 +104,7 @@ _dl_start:
nop
add %sp, DL_DATA_SIZE, %sp ! restore stack
-
+
jmp %o0
mov %l1, %g1 ! restore ps_strings
@@ -306,7 +306,7 @@ _dl_sigprocmask:
cmp %o2, 0
bne,a 1f
st %o0, [%o2]
-1:
+1:
retl
clr %o0
diff --git a/libexec/ld.so/sparc/rtld_machine.c b/libexec/ld.so/sparc/rtld_machine.c
index 9e630647de4..96349dba377 100644
--- a/libexec/ld.so/sparc/rtld_machine.c
+++ b/libexec/ld.so/sparc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.12 2002/12/18 19:21:01 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.13 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -361,7 +361,7 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
_dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
/* mprotect the actual modified region, not the whole plt */
_dl_mprotect((void*)addr,sizeof (Elf_Addr) * 3,
- PROT_READ|PROT_WRITE|PROT_EXEC);
+ PROT_READ|PROT_WRITE|PROT_EXEC);
}
_dl_reloc_plt(addr, value);
@@ -370,7 +370,7 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
if (object->plt_addr != NULL && object->plt_size != 0) {
/* mprotect the actual modified region, not the whole plt */
_dl_mprotect((void*)addr,sizeof (Elf_Addr) * 3,
- PROT_READ|PROT_EXEC);
+ PROT_READ|PROT_EXEC);
_dl_sigprocmask(SIG_SETMASK, &omask, NULL);
}
@@ -447,10 +447,10 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
return;
}
- if (object->got_addr != NULL && object->got_size != 0)
+ if (object->got_addr != NULL && object->got_size != 0)
_dl_mprotect((void*)object->got_addr, object->got_size,
- PROT_READ);
- if (object->plt_addr != NULL && object->plt_size != 0)
+ PROT_READ);
+ if (object->plt_addr != NULL && object->plt_size != 0)
_dl_mprotect((void*)object->plt_addr, object->plt_size,
PROT_READ|PROT_EXEC);
}
diff --git a/libexec/ld.so/sparc64/ldasm.S b/libexec/ld.so/sparc64/ldasm.S
index 2391fbe1b40..43c53c92eb4 100644
--- a/libexec/ld.so/sparc64/ldasm.S
+++ b/libexec/ld.so/sparc64/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.16 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: ldasm.S,v 1.17 2003/02/02 16:57:58 deraadt Exp $ */
/* $NetBSD: rtld_start.S,v 1.5 2001/08/14 22:17:48 eeh Exp $ */
/*
@@ -377,7 +377,7 @@ _dl_sigprocmask:
ld [%o1], %o1 ! indirect for new mask
mov SYS_sigprocmask, %g1 ! call sys_sigprocmask
t ST_SYSCALL ! off to wonderland
- ! what about errors?
+ ! what about errors?
cmp %o2, 0
bne,a 1f ! if oset != NULL
st %o0, [%o2] ! *oset = oldmask
diff --git a/libexec/ld.so/sparc64/rtld_machine.c b/libexec/ld.so/sparc64/rtld_machine.c
index a46e471b300..cddca12dc09 100644
--- a/libexec/ld.so/sparc64/rtld_machine.c
+++ b/libexec/ld.so/sparc64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.23 2002/12/18 19:20:02 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.24 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -648,7 +648,7 @@ _dl_bind(elf_object_t *object, int index)
sigfillset(&nmask);
_dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
_dl_mprotect((void*)object->plt_addr, object->plt_size,
- PROT_READ|PROT_WRITE|PROT_EXEC);
+ PROT_READ|PROT_WRITE|PROT_EXEC);
}
_dl_reloc_plt(addr, ooff + this->st_value, rela);
@@ -656,7 +656,7 @@ _dl_bind(elf_object_t *object, int index)
/* if PLT is (to be protected), change back to RO/X */
if (object->plt_addr != NULL && object->plt_size != 0) {
_dl_mprotect((void*)object->plt_addr, object->plt_size,
- PROT_READ|PROT_EXEC);
+ PROT_READ|PROT_EXEC);
_dl_sigprocmask(SIG_SETMASK, &omask, NULL);
}
@@ -725,7 +725,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
NULL);
if (this != NULL)
object->plt_addr = ooff + this->st_value;
-
+
this = NULL;
ooff = _dl_find_symbol("__plt_end", object, &this,
SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, SYM_NOTPLT,
@@ -743,10 +743,10 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
pltgot[8] = (Elf_Addr)object;
- if (object->got_addr != NULL && object->got_size != 0)
+ if (object->got_addr != NULL && object->got_size != 0)
_dl_mprotect((void*)object->got_addr, object->got_size,
- PROT_READ);
- if (object->plt_addr != NULL && object->plt_size != 0)
+ PROT_READ);
+ if (object->plt_addr != NULL && object->plt_size != 0)
_dl_mprotect((void*)object->plt_addr, object->plt_size,
PROT_READ|PROT_EXEC);
}
diff --git a/libexec/ld.so/util.c b/libexec/ld.so/util.c
index 98e63d09646..c8c4383970c 100644
--- a/libexec/ld.so/util.c
+++ b/libexec/ld.so/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.12 2002/12/02 23:17:36 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.13 2003/02/02 16:57:58 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -43,6 +43,7 @@
* this would end up dragging too much code from libc here.
*/
long __guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+
void
__stack_smash_handler(char func[], int damaged)
{
@@ -69,14 +70,13 @@ _dl_strdup(const char *orig)
}
/*
- * The following malloc/free code is a very simplified implementation
- * of a malloc function. However, we do not need to be very complex here
- * because we only free memory when 'dlclose()' is called and we can
- * reuse at least the memory allocated for the object descriptor. We have
- * one dynamic string allocated, the library name and it is likely that
- * we can reuse that one to without a lot of complex colapsing code.
+ * The following malloc/free code is a very simplified implementation
+ * of a malloc function. However, we do not need to be very complex here
+ * because we only free memory when 'dlclose()' is called and we can
+ * reuse at least the memory allocated for the object descriptor. We have
+ * one dynamic string allocated, the library name and it is likely that
+ * we can reuse that one to without a lot of complex colapsing code.
*/
-
void *
_dl_malloc(size_t size)
{