Index: head/libexec/rtld-elf/Makefile =================================================================== --- head/libexec/rtld-elf/Makefile +++ head/libexec/rtld-elf/Makefile @@ -33,7 +33,7 @@ .endif NO_WCAST_ALIGN= yes -WARNS?= 4 +WARNS?= 6 INSTALLFLAGS= -C -b PRECIOUSPROG= BINDIR= /libexec @@ -98,7 +98,12 @@ ${PROG_FULL}: ${VERSION_MAP} .include -.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300 +.if ${COMPILER_TYPE} == "gcc" +# GCC warns about redeclarations even though they have __exported +# and are therefore not identical to the ones from the system headers. +CFLAGS+= -Wno-redundant-decls +.if ${COMPILER_VERSION} < 40300 # Silence -Wshadow false positives in ancient GCC CFLAGS+= -Wno-shadow +.endif .endif Index: head/libexec/rtld-elf/libmap.c =================================================================== --- head/libexec/rtld-elf/libmap.c +++ head/libexec/rtld-elf/libmap.c @@ -25,7 +25,7 @@ TAILQ_ENTRY(lm) lm_link; }; -TAILQ_HEAD(lmp_list, lmp) lmp_head = TAILQ_HEAD_INITIALIZER(lmp_head); +static TAILQ_HEAD(lmp_list, lmp) lmp_head = TAILQ_HEAD_INITIALIZER(lmp_head); struct lmp { char *p; enum { T_EXACT=0, T_BASENAME, T_DIRECTORY } type; Index: head/libexec/rtld-elf/malloc.c =================================================================== --- head/libexec/rtld-elf/malloc.c +++ head/libexec/rtld-elf/malloc.c @@ -151,7 +151,6 @@ * must contain at least one page size. The page sizes must be stored in * increasing order. */ -extern size_t *pagesizes; void * malloc(size_t nbytes) @@ -256,8 +255,7 @@ * Allocate more memory to the indicated bucket. */ static void -morecore(bucket) - int bucket; +morecore(int bucket) { union overhead *op; int sz; /* size of desired block */ @@ -300,8 +298,7 @@ } void -free(cp) - void *cp; +free(void * cp) { int size; union overhead *op; @@ -339,12 +336,10 @@ * is extern so the caller can modify it). If that fails we just copy * however many bytes was given to realloc() and hope it's not huge. */ -int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ +static int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ void * -realloc(cp, nbytes) - void *cp; - size_t nbytes; +realloc(void *cp, size_t nbytes) { u_int onb; int i; @@ -413,9 +408,7 @@ * Return bucket number, or -1 if not found. */ static int -findbucket(freep, srchlen) - union overhead *freep; - int srchlen; +findbucket(union overhead *freep, int srchlen) { union overhead *p; int i, j; @@ -439,8 +432,7 @@ * for each size category, the second showing the number of mallocs - * frees for each size category. */ -mstats(s) - char *s; +mstats(char * s) { int i, j; union overhead *p; @@ -466,8 +458,7 @@ static int -morepages(n) -int n; +morepages(int n) { int fd = -1; int offset; Index: head/libexec/rtld-elf/map_object.c =================================================================== --- head/libexec/rtld-elf/map_object.c +++ head/libexec/rtld-elf/map_object.c @@ -115,6 +115,7 @@ note_start = 0; note_end = 0; note_map = NULL; + note_map_len = 0; segs = alloca(sizeof(segs[0]) * hdr->e_phnum); stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; text_end = 0; Index: head/libexec/rtld-elf/riscv/reloc.c =================================================================== --- head/libexec/rtld-elf/riscv/reloc.c +++ head/libexec/rtld-elf/riscv/reloc.c @@ -50,8 +50,6 @@ #define RELOC_ALIGNED_P(x) \ (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0) -void _exit(int); - uint64_t set_gp(Obj_Entry *obj) { Index: head/libexec/rtld-elf/rtld.c =================================================================== --- head/libexec/rtld-elf/rtld.c +++ head/libexec/rtld-elf/rtld.c @@ -73,6 +73,14 @@ typedef void (*func_ptr_type)(void); typedef void * (*path_enum_proc) (const char *path, size_t len, void *arg); + +/* Variables that cannot be static: */ +extern struct r_debug r_debug; /* For GDB */ +extern int _thread_autoinit_dummy_decl; +extern char* __progname; +extern void (*__cleanup)(void); + + /* * Function declarations. */ @@ -243,7 +251,8 @@ Elf_Addr _rtld_bind(Obj_Entry *obj, Elf_Size reloff); -int npagesizes, osreldate; +int npagesizes; +static int osreldate; size_t *pagesizes; static int stack_prot = PROT_READ | PROT_WRITE | RTLD_DEFAULT_STACK_EXEC; @@ -268,11 +277,11 @@ size_t tls_last_offset; /* Static TLS offset of last module */ size_t tls_last_size; /* Static TLS size of last module */ size_t tls_static_space; /* Static TLS space allocated */ -size_t tls_static_max_align; +static size_t tls_static_max_align; Elf_Addr tls_dtv_generation = 1; /* Used to detect when dtv size changes */ int tls_max_index = 1; /* Largest module index allocated */ -bool ld_library_path_rpath = false; +static bool ld_library_path_rpath = false; /* * Globals for path names, and such Index: head/libexec/rtld-elf/rtld_lock.c =================================================================== --- head/libexec/rtld-elf/rtld_lock.c +++ head/libexec/rtld-elf/rtld_lock.c @@ -184,7 +184,7 @@ } #define RTLD_LOCK_CNT 3 -struct rtld_lock { +static struct rtld_lock { void *handle; int mask; } rtld_locks[RTLD_LOCK_CNT]; Index: head/libexec/rtld-elf/rtld_printf.c =================================================================== --- head/libexec/rtld-elf/rtld_printf.c +++ head/libexec/rtld-elf/rtld_printf.c @@ -187,6 +187,7 @@ padc = '0'; goto reswitch; } + /* FALLTHROUGH */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': for (n = 0;; ++fmt) { @@ -324,6 +325,7 @@ goto handle_nosign; case 'X': upper = 1; + /* FALLTHROUGH */ case 'x': base = 16; goto handle_nosign;