summaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>2002-09-07 01:25:35 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>2002-09-07 01:25:35 +0000
commiteeec70e61a5e3e1df45ac2336c12eef05ec1fac5 (patch)
tree8e2634e6bf3af3082560ff834c598e2689cf750c /gnu/usr.bin
parent85adcb803528b6a6a9c464ce3537c1b99cd609a6 (diff)
ansification of ld
* normalized the signatures of the functions passed to each_file() and each_full_file(). In most cases that meant adding a void *dummy. In one case it changed an int to a void*, but the arg was only checked for zero/not-zero so the change was not significant. * removes unused code and structures. * makes sure printf args match their format. * got rid of some of the gcc -Wall warnings OK deraadt@
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/ld/etc.c6
-rw-r--r--gnu/usr.bin/ld/ld.c121
-rw-r--r--gnu/usr.bin/ld/ld.h14
-rw-r--r--gnu/usr.bin/ld/ldconfig/ldconfig.c4
-rw-r--r--gnu/usr.bin/ld/ldd/ldd.c7
-rw-r--r--gnu/usr.bin/ld/ldd/scanlib.c12
-rw-r--r--gnu/usr.bin/ld/lib.c6
-rw-r--r--gnu/usr.bin/ld/rrs.c15
-rw-r--r--gnu/usr.bin/ld/rtld/malloc.c11
-rw-r--r--gnu/usr.bin/ld/rtld/rtld.c29
-rw-r--r--gnu/usr.bin/ld/shlib.c12
-rw-r--r--gnu/usr.bin/ld/symbol.c4
-rw-r--r--gnu/usr.bin/ld/warnings.c26
13 files changed, 111 insertions, 156 deletions
diff --git a/gnu/usr.bin/ld/etc.c b/gnu/usr.bin/ld/etc.c
index ecf51ea51a0..2bc5c007a70 100644
--- a/gnu/usr.bin/ld/etc.c
+++ b/gnu/usr.bin/ld/etc.c
@@ -1,13 +1,17 @@
-/* $OpenBSD: etc.c,v 1.4 2002/05/24 06:08:52 ericj Exp $ */
+/* $OpenBSD: etc.c,v 1.5 2002/09/07 01:25:34 marc Exp $ */
/* Public Domain */
#include <sys/types.h>
+#include <a.out.h>
#include <err.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
+#include "ld.h"
+
#define OOM_MSG "Out of memory"
char *
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
index 367b40f1de9..f84a11a2da7 100644
--- a/gnu/usr.bin/ld/ld.c
+++ b/gnu/usr.bin/ld/ld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.c,v 1.27 2002/07/19 19:28:11 marc Exp $ */
+/* $OpenBSD: ld.c,v 1.28 2002/09/07 01:25:34 marc Exp $ */
/* $NetBSD: ld.c,v 1.52 1998/02/20 03:12:51 jonathan Exp $ */
/*-
@@ -257,24 +257,24 @@ static void enter_global_ref(struct localsymbol *,
char *, struct file_entry *);
static void digest_symbols(void);
static void digest_pass1(void), digest_pass2(void);
-static void consider_file_section_lengths(struct file_entry *);
-static void relocate_file_addresses(struct file_entry *);
-static void consider_relocation(struct file_entry *, int);
-static void consider_local_symbols(struct file_entry *);
+static void consider_file_section_lengths(struct file_entry *, void *);
+static void relocate_file_addresses(struct file_entry *, void *);
+static void consider_relocation(struct file_entry *, void *);
+static void consider_local_symbols(struct file_entry *, void *);
static void perform_relocation(char *, int,
struct relocation_info *, int,
struct file_entry *, int);
-static void copy_text(struct file_entry *);
-static void copy_data(struct file_entry *);
-static void coptxtrel(struct file_entry *);
-static void copdatrel(struct file_entry *);
+static void copy_text(struct file_entry *, void *);
+static void copy_data(struct file_entry *, void *);
+static void coptxtrel(struct file_entry *, void *);
+static void copdatrel(struct file_entry *, void *);
static void write_output(void);
static void write_header(void);
static void write_text(void);
static void write_data(void);
static void write_rel(void);
static void write_syms(void);
-static void assign_symbolnums(struct file_entry *, int *);
+static void assign_symbolnums(struct file_entry *, void *);
static void cleanup(void);
static int parse(char *, char *, char *);
@@ -596,7 +596,7 @@ decode_command(int argc, char **argv)
std_search_path();
}
-void
+static void
add_cmdline_ref(symbol *sp)
{
symbol **ptr;
@@ -869,7 +869,7 @@ do_rpath:
*/
void
-each_file(void (*function)(), void *arg)
+each_file(void (*function)(struct file_entry *, void *), void *arg)
{
int i;
@@ -910,43 +910,10 @@ each_file(void (*function)(), void *arg)
}
}
-/*
- * Call FUNCTION on each input file entry until it returns a non-zero value.
- * Return this value. Do not call for entries for libraries; instead, call
- * once for each library member that is being loaded.
- *
- * FUNCTION receives two arguments: the entry, and ARG. It must be a function
- * returning unsigned long (though this can probably be fudged).
- */
-
-unsigned long
-check_each_file(unsigned long (*function)(), void *arg)
-{
- int i;
- unsigned long return_val;
-
- for (i = 0; i < number_of_files; i++) {
- struct file_entry *entry = &file_table[i];
- if (entry->flags & E_SCRAPPED)
- continue;
- if (entry->flags & E_IS_LIBRARY) {
- struct file_entry *subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- if (return_val = (*function)(subentry, arg))
- return return_val;
- }
- } else if (return_val = (*function)(entry, arg))
- return return_val;
- }
- return 0;
-}
-
/* Like `each_file' but ignore files that were just for symbol definitions. */
void
-each_full_file(void (*function)(), void *arg)
+each_full_file(void (*function)(struct file_entry *, void *), void *arg)
{
int i;
@@ -992,7 +959,7 @@ each_full_file(void (*function)(), void *arg)
/* Close the input file that is now open. */
-void
+static void
file_close(void)
{
close(input_desc);
@@ -1662,22 +1629,6 @@ enter_global_ref(struct localsymbol *lsp, char *name, struct file_entry *entry)
}
/*
- * This returns 0 if the given file entry's symbol table does *not* contain
- * the nlist point entry, and it returns the files entry pointer (cast to
- * unsigned long) if it does.
- */
-
-unsigned long
-contains_symbol(struct file_entry *entry, struct nlist *np)
-{
- if (np >= &entry->symbols->nzlist.nlist &&
- np < &(entry->symbols + entry->nsymbols)->nzlist.nlist)
- return (unsigned long) entry;
- return 0;
-}
-
-
-/*
* Having entered all the global symbols and found the sizes of sections of
* all files to be linked, make all appropriate deductions from this data.
*
@@ -1745,7 +1696,7 @@ digest_symbols(void)
* and TEXT_SIZE.
*/
consider_rrs_section_lengths();
- each_full_file(consider_file_section_lengths, 0);
+ each_full_file(consider_file_section_lengths, (void *)0);
rrs_text_start = text_start + text_size;
text_size += rrs_text_size;
data_size += rrs_data_size;
@@ -1790,7 +1741,7 @@ printf("set_sect_start = %#x, set_sect_size = %#x\n",
/* Compute start addresses of each file's sections and symbols. */
- each_full_file(relocate_file_addresses, 0);
+ each_full_file(relocate_file_addresses, (void*) 0);
relocate_rrs_addresses();
/* Pass 2: assign values to symbols */
@@ -2088,7 +2039,7 @@ printf("pass1: SO definition for %s, type %x in %s at %#x\n",
* of the output file.
*/
static void
-consider_relocation( struct file_entry *entry, int dataseg)
+consider_relocation( struct file_entry *entry, void *dataseg)
{
struct relocation_info *reloc, *end;
struct localsymbol *lsp;
@@ -2274,7 +2225,7 @@ consider_relocation( struct file_entry *entry, int dataseg)
* Determine the disposition of each local symbol.
*/
static void
-consider_local_symbols(struct file_entry *entry)
+consider_local_symbols(struct file_entry *entry, void *dummy)
{
struct localsymbol *lsp, *lspend;
@@ -2344,7 +2295,7 @@ consider_local_symbols(struct file_entry *entry)
* the output file.
*/
static void
-consider_file_section_lengths(struct file_entry *entry)
+consider_file_section_lengths(struct file_entry *entry, void *dummy)
{
entry->text_start_address = text_size;
@@ -2365,7 +2316,7 @@ consider_file_section_lengths(struct file_entry *entry)
* Also relocate the addresses of the file's local and debugger symbols.
*/
static void
-relocate_file_addresses(struct file_entry *entry)
+relocate_file_addresses(struct file_entry *entry, void *dummy)
{
struct localsymbol *lsp, *lspend;
@@ -2525,7 +2476,7 @@ digest_pass2(void)
/* Flag second-hand definitions */
undefined_global_sym_count++;
if (sp->flags & GS_TRACE)
- printf("symbol %s assigned to location %#x\n",
+ printf("symbol %s assigned to location %#lx\n",
sp->name, sp->value);
}
@@ -2590,7 +2541,7 @@ digest_pass2(void)
}
bss_size += size;
if (write_map)
- printf("Allocating %s %s: %x at %x\n",
+ printf("Allocating %s %s: %x at %lx\n",
sp->defined==(N_BSS|N_EXT)?"common":"data",
sp->name, size, sp->value);
@@ -2734,7 +2685,7 @@ write_text(void)
if (trace_files)
fprintf(stderr, "Copying and relocating text:\n\n");
- each_full_file(copy_text, 0);
+ each_full_file(copy_text, (void *)0);
file_close();
if (trace_files)
@@ -2749,7 +2700,7 @@ write_text(void)
* reuse.
*/
void
-copy_text(struct file_entry *entry)
+copy_text(struct file_entry *entry, void *dummy)
{
char *bytes;
int fd;
@@ -2797,7 +2748,7 @@ write_data(void)
if (fseek(outstream, pos, SEEK_SET) != 0)
errx(1, "write_data: fseek");
- each_full_file(copy_data, 0);
+ each_full_file(copy_data, (void *)0);
file_close();
/*
@@ -2823,7 +2774,7 @@ write_data(void)
* reuse. See comments in `copy_text'.
*/
void
-copy_data(struct file_entry *entry)
+copy_data(struct file_entry *entry, void *dummy)
{
char *bytes;
int fd;
@@ -3145,15 +3096,15 @@ write_rel(void)
if (count != global_sym_count)
errx(1, "internal error: write_rel: count = %d", count);
- each_full_file(assign_symbolnums, &count);
+ each_full_file(assign_symbolnums, (void *)&count);
/* Write out the relocations of all files, remembered from copy_text. */
- each_full_file(coptxtrel, 0);
+ each_full_file(coptxtrel, (void *)0);
if (trace_files)
fprintf(stderr, "\nWriting data relocation:\n\n");
- each_full_file(copdatrel, 0);
+ each_full_file(copdatrel, (void *)0);
if (trace_files)
fprintf(stderr, "\n");
@@ -3164,9 +3115,10 @@ write_rel(void)
* Assign symbol ordinal numbers to local symbols in each entry.
*/
static void
-assign_symbolnums(struct file_entry *entry, int *countp)
+assign_symbolnums(struct file_entry *entry, void *arg)
{
struct localsymbol *lsp, *lspend;
+ int *countp = arg;
int n = *countp;
lspend = entry->symbols + entry->nsymbols;
@@ -3183,7 +3135,7 @@ assign_symbolnums(struct file_entry *entry, int *countp)
}
static void
-coptxtrel(struct file_entry *entry)
+coptxtrel(struct file_entry *entry, void *dummy)
{
struct relocation_info *r, *end;
int reloc = entry->text_start_address;
@@ -3247,7 +3199,7 @@ coptxtrel(struct file_entry *entry)
}
static void
-copdatrel(struct file_entry *entry)
+copdatrel(struct file_entry *entry, void *dummy)
{
struct relocation_info *r, *end;
/*
@@ -3310,7 +3262,7 @@ copdatrel(struct file_entry *entry)
sizeof(struct relocation_info), outstream);
}
-void write_file_syms(struct file_entry *, int *);
+void write_file_syms(struct file_entry *, void *);
void write_string_table(void);
/* Offsets and current lengths of symbol and string tables in output file. */
@@ -3529,7 +3481,7 @@ write_syms(void)
nl.n_type = sp->defined;
if (nl.n_type == (N_INDR|N_EXT) &&
sp->value != 0)
- errx(1, "%s: N_INDR has value %#x",
+ errx(1, "%s: N_INDR has value %#lx",
sp->name, sp->value);
nl.n_value = sp->value;
if (sp->def_lsp)
@@ -3650,8 +3602,9 @@ printf("writesym(#%d): %s, type %x\n", syms_written, sp->name, sp->defined);
* would be confused if we did that.
*/
void
-write_file_syms(struct file_entry *entry, int *syms_written_addr)
+write_file_syms(struct file_entry *entry, void *arg)
{
+ int *syms_written_addr = arg;
struct localsymbol *lsp, *lspend;
/* Upper bound on number of syms to be written here. */
diff --git a/gnu/usr.bin/ld/ld.h b/gnu/usr.bin/ld/ld.h
index 0672fb2406a..328d83d54e9 100644
--- a/gnu/usr.bin/ld/ld.h
+++ b/gnu/usr.bin/ld/ld.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.h,v 1.11 2002/07/17 20:33:29 marc Exp $ */
+/* $OpenBSD: ld.h,v 1.12 2002/09/07 01:25:34 marc Exp $ */
/*-
* This code is derived from software copyrighted by the Free Software
@@ -616,9 +616,8 @@ void read_file_symbols(struct file_entry *);
int set_element_prefixed_p(char *);
int text_offset(struct file_entry *);
int file_open(struct file_entry *);
-void each_file(void (*)(), void *);
-void each_full_file(void (*)(), void *);
-unsigned long check_each_file(unsigned long (*)(), void *);
+void each_file(void (*)(struct file_entry *, void *), void *);
+void each_full_file(void (*)(struct file_entry *, void *), void *);
void mywrite(void *, int, int, FILE *);
void padfile(int, FILE *);
extern int will_see_later(const char *);
@@ -650,10 +649,12 @@ int findlib(struct file_entry *);
/* In shlib.c: */
char *findshlib(char *, int *, int *, int);
void add_search_dir(char *);
+void remove_search_path(char *path);
void add_search_path(char *);
void std_search_path(void);
int getdewey(int[], char *);
int cmpndewey(int[], int, int[], int);
+void remove_search_dir(char *);
/* In rrs.c: */
void init_rrs(void);
@@ -684,8 +685,9 @@ void md_fix_jmpslot(jmpslot_t *, long, u_long);
int md_make_reloc(struct relocation_info *, struct relocation_info *, int);
void md_make_jmpreloc(struct relocation_info *, struct relocation_info *, int);
void md_make_gotreloc(struct relocation_info *, struct relocation_info *, int);
-void md_make_copyreloc(struct relocation_info *, struct relocation_info *);
+void md_make_cpyreloc(struct relocation_info *, struct relocation_info *);
void md_set_breakpoint(long, long *);
+int md_midcompat(struct exec *);
#ifdef NEED_SWAP
void md_swapin_exec_hdr(struct exec *);
@@ -693,6 +695,7 @@ void md_swapout_exec_hdr(struct exec *);
void md_swapin_reloc(struct relocation_info *, int);
void md_swapout_reloc(struct relocation_info *, int);
void md_swapout_jmpslot(jmpslot_t *, int);
+#endif
/* In xbits.c: */
void swap_longs(long *, int);
@@ -706,4 +709,3 @@ void swap_so_debug(struct so_debug *);
void swapin_sod(struct sod *, int);
void swapout_sod(struct sod *, int);
void swap_rrs_hash(struct rrs_hash *, int);
-#endif
diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.c b/gnu/usr.bin/ld/ldconfig/ldconfig.c
index 6b85fd0670a..fc1de5cc93d 100644
--- a/gnu/usr.bin/ld/ldconfig/ldconfig.c
+++ b/gnu/usr.bin/ld/ldconfig/ldconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldconfig.c,v 1.13 2002/07/19 19:28:12 marc Exp $ */
+/* $OpenBSD: ldconfig.c,v 1.14 2002/09/07 01:25:34 marc Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@@ -275,7 +275,7 @@ enter(char *dir, char *file, char *name, int dewey[], int ndewey)
#define _PATH_LD_HINTS "./ld.so.hints"
#endif
-int
+static int
hinthash(char *cp, int vmajor, int vminor)
{
int k = 0;
diff --git a/gnu/usr.bin/ld/ldd/ldd.c b/gnu/usr.bin/ld/ldd/ldd.c
index 2ae8f91295c..a0646fce990 100644
--- a/gnu/usr.bin/ld/ldd/ldd.c
+++ b/gnu/usr.bin/ld/ldd/ldd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldd.c,v 1.11 2002/07/19 19:28:12 marc Exp $ */
+/* $OpenBSD: ldd.c,v 1.12 2002/09/07 01:25:34 marc Exp $ */
/* $NetBSD: ldd.c,v 1.12 1995/10/09 00:14:41 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -45,9 +45,10 @@
#include <string.h>
#include <unistd.h>
-extern void scan_library(int, struct exec *, const char *, const char *, const char *);
+extern void scan_library(int, struct exec *, const char *, const char *,
+ const char *);
-void
+static void
usage(void)
{
extern char *__progname;
diff --git a/gnu/usr.bin/ld/ldd/scanlib.c b/gnu/usr.bin/ld/ldd/scanlib.c
index a28e11ef7eb..f8734dfb72c 100644
--- a/gnu/usr.bin/ld/ldd/scanlib.c
+++ b/gnu/usr.bin/ld/ldd/scanlib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scanlib.c,v 1.4 2002/07/19 19:28:12 marc Exp $ */
+/* $OpenBSD: scanlib.c,v 1.5 2002/09/07 01:25:34 marc Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -30,10 +30,16 @@
*/
#include <sys/types.h>
#include <sys/param.h>
-#include <fcntl.h>
-#include <unistd.h>
+
#include <a.out.h>
+#include <err.h>
+#include <fcntl.h>
#include <link.h>
+#include <stdio.h>
+#include <unistd.h>
+
+extern void scan_library(int, struct exec *, const char *, const char *,
+ const char *);
void
scan_library(int fd, struct exec *hdr, const char *name, const char *fmt1,
diff --git a/gnu/usr.bin/ld/lib.c b/gnu/usr.bin/ld/lib.c
index eaf3ce99e31..759f8e26d44 100644
--- a/gnu/usr.bin/ld/lib.c
+++ b/gnu/usr.bin/ld/lib.c
@@ -1,4 +1,4 @@
-/* * $OpenBSD: lib.c,v 1.9 2002/07/19 19:28:11 marc Exp $ - library routines*/
+/* * $OpenBSD: lib.c,v 1.10 2002/09/07 01:25:34 marc Exp $ - library routines*/
/*
*/
@@ -93,7 +93,7 @@ decode_library_subfile(int fd, struct file_entry *library_entry,
if (sscanf(hdr1.ar_size, "%d", &member_length) != 1)
errx(1, "%s: malformatted header of archive member: %.*s",
get_file_name(library_entry),
- sizeof(hdr1.ar_name), hdr1.ar_name);
+ (int) sizeof(hdr1.ar_name), hdr1.ar_name);
subentry = (struct file_entry *) xmalloc(sizeof(struct file_entry));
bzero(subentry, sizeof(struct file_entry));
@@ -120,7 +120,7 @@ decode_library_subfile(int fd, struct file_entry *library_entry,
if (read(fd, name, namelen) != namelen)
errx(1, "%s: malformatted archive member: %.*s",
get_file_name(library_entry),
- sizeof(hdr1.ar_name), hdr1.ar_name);
+ (int) sizeof(hdr1.ar_name), hdr1.ar_name);
name[namelen] = 0;
content_length -= namelen;
starting_offset += namelen;
diff --git a/gnu/usr.bin/ld/rrs.c b/gnu/usr.bin/ld/rrs.c
index 489637d8623..b062d24cc57 100644
--- a/gnu/usr.bin/ld/rrs.c
+++ b/gnu/usr.bin/ld/rrs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rrs.c,v 1.9 2002/07/19 19:28:11 marc Exp $*/
+/* $OpenBSD: rrs.c,v 1.10 2002/09/07 01:25:34 marc Exp $*/
/*
* Copyright (c) 1993 Paul Kranenburg
* All rights reserved.
@@ -78,7 +78,6 @@ static int current_got_offset;
static int max_got_offset;
static int min_got_offset;
static int got_origin;
-static int current_reloc_offset;
static int current_hash_index;
int number_of_shobjs;
@@ -547,7 +546,7 @@ claim_rrs_internal_gotslot(struct file_entry *entry, struct relocation_info *rp,
if (lsp->gotslot_offset != -1) {
/* Already claimed */
if (*GOTP(lsp->gotslot_offset) != addend)
- errx(1, "%s: gotslot at %#x is multiple valued",
+ errx(1, "%s: gotslot at %#lx is multiple valued",
get_file_name(entry), lsp->gotslot_offset);
return lsp->gotslot_offset;
}
@@ -633,7 +632,7 @@ printf("claim_rrs_segment_reloc: %s at %#x\n",
* Fill the RRS hash table for the given symbol name.
* NOTE: the hash value computation must match the one in rtld.
*/
-void
+static void
rrs_insert_hash(char *cp, int index)
{
int hashval = 0;
@@ -676,9 +675,11 @@ void
consider_rrs_section_lengths(void)
{
int n;
- struct shobj *shp, **shpp;
+ struct shobj *shp;
#ifdef notyet
+ struct shobj **shpp;
+
/* We run into trouble with this as long as shared object symbols
are not checked for definitions */
/*
@@ -947,7 +948,7 @@ relocate_rrs_addresses(void)
}
-void
+static void
write_rrs_data(void)
{
long pos;
@@ -989,7 +990,7 @@ write_rrs_data(void)
mywrite(rrs_plt, number_of_jmpslots, sizeof(jmpslot_t), outstream);
}
-void
+static void
write_rrs_text(void)
{
long pos;
diff --git a/gnu/usr.bin/ld/rtld/malloc.c b/gnu/usr.bin/ld/rtld/malloc.c
index 9d5869f3319..eb372e06090 100644
--- a/gnu/usr.bin/ld/rtld/malloc.c
+++ b/gnu/usr.bin/ld/rtld/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.5 2002/07/19 19:28:12 marc Exp $ */
+/* $OpenBSD: malloc.c,v 1.6 2002/09/07 01:25:34 marc Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -35,7 +35,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)malloc.c 5.11 (Berkeley) 2/23/91";*/
-static char *rcsid = "$OpenBSD: malloc.c,v 1.5 2002/07/19 19:28:12 marc Exp $";
+static char *rcsid = "$OpenBSD: malloc.c,v 1.6 2002/09/07 01:25:34 marc Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -56,6 +56,7 @@ static char *rcsid = "$OpenBSD: malloc.c,v 1.5 2002/07/19 19:28:12 marc Exp $";
#include <unistd.h>
#include <sys/param.h>
#include <sys/mman.h>
+
#ifndef BSD
#define MAP_COPY MAP_PRIVATE
#define MAP_FILE 0
@@ -73,7 +74,8 @@ static char *rcsid = "$OpenBSD: malloc.c,v 1.5 2002/07/19 19:28:12 marc Exp $";
*/
#define NPOOLPAGES (32*1024/pagesz)
static caddr_t pagepool_start, pagepool_end;
-static int morepages();
+static int morepages(int);
+extern void xprintf(char *, ...);
/*
* The overhead on a block is at least 4 bytes. When free, this space
@@ -120,7 +122,6 @@ static int findbucket(union overhead *freep, int srchlen);
*/
#define NBUCKETS 30
static union overhead *nextf[NBUCKETS];
-extern char *sbrk();
static int pagesz; /* page size */
static int pagebucket; /* page size bucket */
@@ -387,7 +388,7 @@ realloc(void *cp, size_t nbytes)
* header starts at ``freep''. If srchlen is -1 search the whole list.
* Return bucket number, or -1 if not found.
*/
-static
+static int
findbucket(union overhead *freep, int srchlen)
{
union overhead *p;
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c
index aee02e4ccfa..0fb7e6184b8 100644
--- a/gnu/usr.bin/ld/rtld/rtld.c
+++ b/gnu/usr.bin/ld/rtld/rtld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld.c,v 1.28 2002/07/27 22:06:06 deraadt Exp $ */
+/* $OpenBSD: rtld.c,v 1.29 2002/09/07 01:25:34 marc Exp $ */
/* $NetBSD: rtld.c,v 1.43 1996/01/14 00:35:17 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -1096,7 +1096,7 @@ binder(jmpslot_t *jsp)
}
if (smp == NULL)
- errx(1, "Call to binder from unknown location: %#x", jsp);
+ errx(1, "Call to binder from unknown location: %p", jsp);
index = jsp->reloc_index & JMPSLOT_RELOC_MASK;
@@ -1106,7 +1106,7 @@ binder(jmpslot_t *jsp)
np = lookup(sym, &src_map, 1);
if (np == NULL)
- errx(1, "Undefined symbol \"%s\" called from %s:%s at %#x",
+ errx(1, "Undefined symbol \"%s\" called from %s:%s at %p",
sym, main_progname, smp->som_path, jsp);
/* Fixup jmpslot so future calls transfer directly to target */
@@ -1196,7 +1196,7 @@ unmaphints(void)
}
}
-int
+static int
hinthash(char *cp, int vmajor, int vminor)
{
int k = 0;
@@ -1354,31 +1354,12 @@ preload(char *paths)
return;
}
-static struct somap_private dlmap_private = {
- 0,
- (struct so_map *)0,
- 0,
-#ifdef SUN_COMPAT
- 0,
-#endif
-};
-
-static struct so_map dlmap = {
- (caddr_t)0,
- "internal",
- (struct so_map *)0,
- (struct sod *)0,
- (caddr_t)0,
- (u_int)0,
- (struct _dynamic *)0,
- (caddr_t)&dlmap_private
-};
static int dlerrno;
/*
* Populate sod struct for dlopen's call to map_object
*/
-void
+static void
build_sod(const char *name, struct sod *sodp)
{
unsigned int tuplet;
diff --git a/gnu/usr.bin/ld/shlib.c b/gnu/usr.bin/ld/shlib.c
index c8a170943b0..a90d69aaa8a 100644
--- a/gnu/usr.bin/ld/shlib.c
+++ b/gnu/usr.bin/ld/shlib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shlib.c,v 1.13 2002/07/19 19:28:12 marc Exp $ */
+/* $OpenBSD: shlib.c,v 1.14 2002/09/07 01:25:34 marc Exp $ */
/* $NetBSD: shlib.c,v 1.13 1998/04/04 01:00:29 fvdl Exp $ */
/*
@@ -137,18 +137,18 @@ add_search_path(char *path)
void
remove_search_path(char *path)
{
- char *cp, *dup;
-
- if (path == NULL)
+ char *cp, *dup;
+
+ if (path == NULL)
return;
-
+
/* Remove search directories from `path' */
path = dup = strdup(path);
while ((cp = strsep(&path, ":")) != NULL)
remove_search_dir(cp);
free(dup);
}
-
+
void
std_search_path(void)
{
diff --git a/gnu/usr.bin/ld/symbol.c b/gnu/usr.bin/ld/symbol.c
index b123404f2f0..d0f7a9d2ac0 100644
--- a/gnu/usr.bin/ld/symbol.c
+++ b/gnu/usr.bin/ld/symbol.c
@@ -1,4 +1,4 @@
-/* * $OpenBSD: symbol.c,v 1.6 2002/07/19 19:28:12 marc Exp $ - symbol table routines*/
+/* * $OpenBSD: symbol.c,v 1.7 2002/09/07 01:25:34 marc Exp $ - symbol table routines*/
/*
*/
@@ -72,7 +72,7 @@ symtab_init(int relocatable_output)
* Compute the hash code for symbol name KEY.
*/
-int
+static int
hash_string(char *key)
{
char *cp;
diff --git a/gnu/usr.bin/ld/warnings.c b/gnu/usr.bin/ld/warnings.c
index 6542a9d68ef..2189532e6fb 100644
--- a/gnu/usr.bin/ld/warnings.c
+++ b/gnu/usr.bin/ld/warnings.c
@@ -1,4 +1,4 @@
-/* * $OpenBSD: warnings.c,v 1.8 2002/07/19 19:28:12 marc Exp $*/
+/* * $OpenBSD: warnings.c,v 1.9 2002/09/07 01:25:34 marc Exp $*/
/*
*/
@@ -86,8 +86,8 @@ get_file_name(struct file_entry *entry)
/* Print a complete or partial map of the output file. */
-static void describe_file_sections(struct file_entry *, FILE *);
-static void list_file_locals(struct file_entry *, FILE *);
+static void describe_file_sections(struct file_entry *, void *);
+static void list_file_locals(struct file_entry *, void *);
void
print_symbols(FILE *outfile)
@@ -107,7 +107,7 @@ print_symbols(FILE *outfile)
else if (sp->defined == (N_UNDF|N_EXT))
fprintf(outfile, "common: size %#x", sp->common_size);
else
- fprintf(outfile, "type %d, value %#x, size %#x",
+ fprintf(outfile, "type %d, value %#lx, size %#x",
sp->defined, sp->value, sp->size);
if (sp->alias)
fprintf(outfile, ", aliased to %s", sp->alias->name);
@@ -118,8 +118,10 @@ print_symbols(FILE *outfile)
}
static void
-describe_file_sections(struct file_entry *entry, FILE *outfile)
+describe_file_sections(struct file_entry *entry, void *arg)
{
+ FILE *outfile = arg;
+
fprintf(outfile, " ");
print_file_name(entry, outfile);
if (entry->flags & (E_JUST_SYMS | E_DYNAMIC))
@@ -132,8 +134,9 @@ describe_file_sections(struct file_entry *entry, FILE *outfile)
}
static void
-list_file_locals(struct file_entry *entry, FILE *outfile)
+list_file_locals(struct file_entry *entry, void *arg)
{
+ FILE *outfile = arg;
struct localsymbol *lsp, *lspend;
entry->strings = (char *)alloca(entry->string_size);
@@ -151,7 +154,7 @@ list_file_locals(struct file_entry *entry, FILE *outfile)
* update it if necessary by this file's start address.
*/
if (!(p->n_type & (N_STAB | N_EXT)))
- fprintf(outfile, " %s: 0x%x\n",
+ fprintf(outfile, " %s: 0x%lx\n",
entry->strings + p->n_un.n_strx, p->n_value);
}
@@ -188,8 +191,10 @@ struct line_debug_entry
*/
static int
-reloc_cmp(struct relocation_info *rel1, struct relocation_info *rel2)
+reloc_cmp(const void *arg1, const void *arg2)
{
+ const struct relocation_info *rel1 = arg1;
+ const struct relocation_info *rel2 = arg2;
return RELOC_ADDRESS(rel1) - RELOC_ADDRESS(rel2);
}
@@ -512,8 +517,8 @@ do_relocation_warnings(struct file_entry *entry, int data_segment,
* possible, just the .o file if not.
*/
-void
-do_file_warnings(struct file_entry *entry, FILE *outfile)
+static void
+do_file_warnings(struct file_entry *entry, void *arg)
{
int nsym;
int i;
@@ -522,6 +527,7 @@ do_file_warnings(struct file_entry *entry, FILE *outfile)
int dont_allow_symbol_name;
u_char *nlist_bitvector;
struct line_debug_entry *text_scan, *data_scan;
+ FILE *outfile = arg;
nsym = entry->nsymbols;
nlist_bitvector = (u_char *)alloca((nsym >> 3) + 1);