svn commit: r339879 - in head/libexec/rtld-elf: . riscv

Alex Richardson arichardson at FreeBSD.org
Mon Oct 29 21:08:31 UTC 2018


Author: arichardson
Date: Mon Oct 29 21:08:28 2018
New Revision: 339879
URL: https://svnweb.freebsd.org/changeset/base/339879

Log:
  rtld-elf: fix more warnings to allow compiling with WARNS=6
  
  Reviewed By:	kib
  Approved By:	brooks (mentor)
  Differential Revision: https://reviews.freebsd.org/D17154

Modified:
  head/libexec/rtld-elf/Makefile
  head/libexec/rtld-elf/libmap.c
  head/libexec/rtld-elf/malloc.c
  head/libexec/rtld-elf/map_object.c
  head/libexec/rtld-elf/riscv/reloc.c
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/rtld_lock.c
  head/libexec/rtld-elf/rtld_printf.c

Modified: head/libexec/rtld-elf/Makefile
==============================================================================
--- head/libexec/rtld-elf/Makefile	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/Makefile	Mon Oct 29 21:08:28 2018	(r339879)
@@ -33,7 +33,7 @@ LDFLAGS+=	-nostdlib -e .rtld_start
 .endif
 
 NO_WCAST_ALIGN=	yes
-WARNS?=		4
+WARNS?=		6
 INSTALLFLAGS=	-C -b
 PRECIOUSPROG=
 BINDIR=		/libexec
@@ -98,7 +98,12 @@ SUBDIR.${MK_TESTS}+= tests
 ${PROG_FULL}:	${VERSION_MAP}
 .include <bsd.symver.mk>
 
-.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

Modified: head/libexec/rtld-elf/libmap.c
==============================================================================
--- head/libexec/rtld-elf/libmap.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/libmap.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -25,7 +25,7 @@ struct lm {
 	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;

Modified: head/libexec/rtld-elf/malloc.c
==============================================================================
--- head/libexec/rtld-elf/malloc.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/malloc.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -151,7 +151,6 @@ botch(s)
  * 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 @@ calloc(size_t num, size_t size)
  * 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 @@ morecore(bucket)
 }
 
 void
-free(cp)
-	void *cp;
+free(void * cp)
 {
 	int size;
 	union overhead *op;
@@ -339,12 +336,10 @@ free(cp)
  * 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 @@ realloc(cp, nbytes)
  * 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 @@ findbucket(freep, srchlen)
  * 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 @@ mstats(s)
 
 
 static int
-morepages(n)
-int	n;
+morepages(int n)
 {
 	int	fd = -1;
 	int	offset;

Modified: head/libexec/rtld-elf/map_object.c
==============================================================================
--- head/libexec/rtld-elf/map_object.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/map_object.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -115,6 +115,7 @@ map_object(int fd, const char *path, const struct stat
     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;

Modified: head/libexec/rtld-elf/riscv/reloc.c
==============================================================================
--- head/libexec/rtld-elf/riscv/reloc.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/riscv/reloc.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -50,8 +50,6 @@ __FBSDID("$FreeBSD$");
 #define	RELOC_ALIGNED_P(x) \
 	(((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
 
-void _exit(int);
-
 uint64_t
 set_gp(Obj_Entry *obj)
 {

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/rtld.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -73,6 +73,14 @@ __FBSDID("$FreeBSD$");
 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 @@ func_ptr_type _rtld(Elf_Addr *sp, func_ptr_type *exit_
 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 @@ char **main_argv;
 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

Modified: head/libexec/rtld-elf/rtld_lock.c
==============================================================================
--- head/libexec/rtld-elf/rtld_lock.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/rtld_lock.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -184,7 +184,7 @@ thread_mask_clear(int mask)
 }
 
 #define	RTLD_LOCK_CNT	3
-struct rtld_lock {
+static struct rtld_lock {
 	void	*handle;
 	int	 mask;
 } rtld_locks[RTLD_LOCK_CNT];

Modified: head/libexec/rtld-elf/rtld_printf.c
==============================================================================
--- head/libexec/rtld-elf/rtld_printf.c	Mon Oct 29 21:08:19 2018	(r339878)
+++ head/libexec/rtld-elf/rtld_printf.c	Mon Oct 29 21:08:28 2018	(r339879)
@@ -187,6 +187,7 @@ reswitch:	switch (ch = (u_char)*fmt++) {
 				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 @@ reswitch:	switch (ch = (u_char)*fmt++) {
 			goto handle_nosign;
 		case 'X':
 			upper = 1;
+			/* FALLTHROUGH */
 		case 'x':
 			base = 16;
 			goto handle_nosign;


More information about the svn-src-head mailing list