rtld-elf: make it compile with WARNS=3
Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17150
This commit is contained in:
parent
ca7e27bbce
commit
78b648465d
@ -199,8 +199,7 @@ lmc_parse(char *lm_p, size_t lm_len)
|
|||||||
char prog[MAXPATHLEN];
|
char prog[MAXPATHLEN];
|
||||||
/* allow includedir + full length path */
|
/* allow includedir + full length path */
|
||||||
char line[MAXPATHLEN + 13];
|
char line[MAXPATHLEN + 13];
|
||||||
size_t cnt;
|
size_t cnt, i;
|
||||||
int i;
|
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
@ -403,7 +402,7 @@ lm_find(const char *p, const char *f)
|
|||||||
* replacement library, or NULL.
|
* replacement library, or NULL.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
lm_findn(const char *p, const char *f, const int n)
|
lm_findn(const char *p, const char *f, const size_t n)
|
||||||
{
|
{
|
||||||
char pathbuf[64], *s, *t;
|
char pathbuf[64], *s, *t;
|
||||||
|
|
||||||
|
@ -5,4 +5,4 @@
|
|||||||
int lm_init (char *);
|
int lm_init (char *);
|
||||||
void lm_fini (void);
|
void lm_fini (void);
|
||||||
char * lm_find (const char *, const char *);
|
char * lm_find (const char *, const char *);
|
||||||
char * lm_findn (const char *, const char *, const int);
|
char * lm_findn (const char *, const char *, const size_t);
|
||||||
|
@ -60,15 +60,11 @@ static char *rcsid = "$FreeBSD$";
|
|||||||
#include "rtld_printf.h"
|
#include "rtld_printf.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
|
||||||
static void morecore();
|
|
||||||
static int findbucket();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pre-allocate mmap'ed pages
|
* Pre-allocate mmap'ed pages
|
||||||
*/
|
*/
|
||||||
#define NPOOLPAGES (128*1024/pagesz)
|
#define NPOOLPAGES (128*1024/pagesz)
|
||||||
static caddr_t pagepool_start, pagepool_end;
|
static caddr_t pagepool_start, pagepool_end;
|
||||||
static int morepages();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The overhead on a block is at least 4 bytes. When free, this space
|
* The overhead on a block is at least 4 bytes. When free, this space
|
||||||
@ -96,6 +92,11 @@ union overhead {
|
|||||||
#define ov_size ovu.ovu_size
|
#define ov_size ovu.ovu_size
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void morecore(int bucket);
|
||||||
|
static int morepages(int n);
|
||||||
|
static int findbucket(union overhead *freep, int srchlen);
|
||||||
|
|
||||||
|
|
||||||
#define MAGIC 0xef /* magic # on accounting info */
|
#define MAGIC 0xef /* magic # on accounting info */
|
||||||
#define RMAGIC 0x5555 /* magic # on range info */
|
#define RMAGIC 0x5555 /* magic # on range info */
|
||||||
|
|
||||||
@ -156,10 +157,10 @@ void *
|
|||||||
malloc(nbytes)
|
malloc(nbytes)
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
{
|
{
|
||||||
register union overhead *op;
|
union overhead *op;
|
||||||
register int bucket;
|
int bucket;
|
||||||
register long n;
|
size_t n;
|
||||||
register unsigned amt;
|
unsigned amt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First time malloc is called, setup page size and
|
* First time malloc is called, setup page size and
|
||||||
@ -259,8 +260,8 @@ static void
|
|||||||
morecore(bucket)
|
morecore(bucket)
|
||||||
int bucket;
|
int bucket;
|
||||||
{
|
{
|
||||||
register union overhead *op;
|
union overhead *op;
|
||||||
register int sz; /* size of desired block */
|
int sz; /* size of desired block */
|
||||||
int amt; /* amount to allocate */
|
int amt; /* amount to allocate */
|
||||||
int nblks; /* how many blocks we get */
|
int nblks; /* how many blocks we get */
|
||||||
|
|
||||||
@ -303,8 +304,8 @@ void
|
|||||||
free(cp)
|
free(cp)
|
||||||
void *cp;
|
void *cp;
|
||||||
{
|
{
|
||||||
register int size;
|
int size;
|
||||||
register union overhead *op;
|
union overhead *op;
|
||||||
|
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
return;
|
return;
|
||||||
@ -346,8 +347,8 @@ realloc(cp, nbytes)
|
|||||||
void *cp;
|
void *cp;
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
{
|
{
|
||||||
register u_int onb;
|
u_int onb;
|
||||||
register int i;
|
int i;
|
||||||
union overhead *op;
|
union overhead *op;
|
||||||
char *res;
|
char *res;
|
||||||
int was_alloced = 0;
|
int was_alloced = 0;
|
||||||
@ -417,8 +418,8 @@ findbucket(freep, srchlen)
|
|||||||
union overhead *freep;
|
union overhead *freep;
|
||||||
int srchlen;
|
int srchlen;
|
||||||
{
|
{
|
||||||
register union overhead *p;
|
union overhead *p;
|
||||||
register int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < NBUCKETS; i++) {
|
for (i = 0; i < NBUCKETS; i++) {
|
||||||
j = 0;
|
j = 0;
|
||||||
@ -442,8 +443,8 @@ findbucket(freep, srchlen)
|
|||||||
mstats(s)
|
mstats(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register int i, j;
|
int i, j;
|
||||||
register union overhead *p;
|
union overhead *p;
|
||||||
int totfree = 0,
|
int totfree = 0,
|
||||||
totused = 0;
|
totused = 0;
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ get_elf_header(int fd, const char *path, const struct stat *sbp)
|
|||||||
Elf_Ehdr *hdr;
|
Elf_Ehdr *hdr;
|
||||||
|
|
||||||
/* Make sure file has enough data for the ELF header */
|
/* Make sure file has enough data for the ELF header */
|
||||||
if (sbp != NULL && sbp->st_size < sizeof(Elf_Ehdr)) {
|
if (sbp != NULL && sbp->st_size < (off_t)sizeof(Elf_Ehdr)) {
|
||||||
_rtld_error("%s: invalid file format", path);
|
_rtld_error("%s: invalid file format", path);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "notes.h"
|
#include "notes.h"
|
||||||
|
|
||||||
/* Types. */
|
/* Types. */
|
||||||
typedef void (*func_ptr_type)();
|
typedef void (*func_ptr_type)(void);
|
||||||
typedef void * (*path_enum_proc) (const char *path, size_t len, void *arg);
|
typedef void * (*path_enum_proc) (const char *path, size_t len, void *arg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -236,6 +236,13 @@ int _rtld_get_stack_prot(void) __exported;
|
|||||||
int _rtld_is_dlopened(void *) __exported;
|
int _rtld_is_dlopened(void *) __exported;
|
||||||
void _rtld_error(const char *, ...) __exported;
|
void _rtld_error(const char *, ...) __exported;
|
||||||
|
|
||||||
|
/* Only here to fix -Wmissing-prototypes warnings */
|
||||||
|
int __getosreldate(void);
|
||||||
|
void __pthread_cxa_finalize(struct dl_phdr_info *a);
|
||||||
|
func_ptr_type _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp);
|
||||||
|
Elf_Addr _rtld_bind(Obj_Entry *obj, Elf_Size reloff);
|
||||||
|
|
||||||
|
|
||||||
int npagesizes, osreldate;
|
int npagesizes, osreldate;
|
||||||
size_t *pagesizes;
|
size_t *pagesizes;
|
||||||
|
|
||||||
@ -262,7 +269,7 @@ 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_last_size; /* Static TLS size of last module */
|
||||||
size_t tls_static_space; /* Static TLS space allocated */
|
size_t tls_static_space; /* Static TLS space allocated */
|
||||||
size_t tls_static_max_align;
|
size_t tls_static_max_align;
|
||||||
int tls_dtv_generation = 1; /* Used to detect when dtv size changes */
|
Elf_Addr tls_dtv_generation = 1; /* Used to detect when dtv size changes */
|
||||||
int tls_max_index = 1; /* Largest module index allocated */
|
int tls_max_index = 1; /* Largest module index allocated */
|
||||||
|
|
||||||
bool ld_library_path_rpath = false;
|
bool ld_library_path_rpath = false;
|
||||||
@ -4846,7 +4853,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
|
|||||||
char *tls;
|
char *tls;
|
||||||
Elf_Addr *dtv, *olddtv;
|
Elf_Addr *dtv, *olddtv;
|
||||||
Elf_Addr segbase, oldsegbase, addr;
|
Elf_Addr segbase, oldsegbase, addr;
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
ralign = tcbalign;
|
ralign = tcbalign;
|
||||||
if (tls_static_max_align > ralign)
|
if (tls_static_max_align > ralign)
|
||||||
|
@ -54,7 +54,7 @@ typedef unsigned char bool;
|
|||||||
extern size_t tls_last_offset;
|
extern size_t tls_last_offset;
|
||||||
extern size_t tls_last_size;
|
extern size_t tls_last_size;
|
||||||
extern size_t tls_static_space;
|
extern size_t tls_static_space;
|
||||||
extern int tls_dtv_generation;
|
extern Elf_Addr tls_dtv_generation;
|
||||||
extern int tls_max_index;
|
extern int tls_max_index;
|
||||||
|
|
||||||
extern int npagesizes;
|
extern int npagesizes;
|
||||||
|
Loading…
Reference in New Issue
Block a user