rtld-elf: compile with WANRS=4 warnings other than -Wcast-align

Reviewed By:	kib
Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D17153
This commit is contained in:
Alex Richardson 2018-10-29 21:08:19 +00:00
parent 78b648465d
commit 903e0ffd07
20 changed files with 249 additions and 208 deletions

View File

@ -31,7 +31,9 @@ LDFLAGS+= -nostdlib -e _rtld_start
.else
LDFLAGS+= -nostdlib -e .rtld_start
.endif
WARNS?= 2
NO_WCAST_ALIGN= yes
WARNS?= 4
INSTALLFLAGS= -C -b
PRECIOUSPROG=
BINDIR= /libexec
@ -95,3 +97,8 @@ SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
${PROG_FULL}: ${VERSION_MAP}
.include <bsd.symver.mk>
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300
# Silence -Wshadow false positives in ancient GCC
CFLAGS+= -Wno-shadow
.endif

View File

@ -84,7 +84,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *)((char *)dstobj->rela +
relalim = (const Elf_Rela *)((const char *)dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) != R_AARCH64_COPY)
@ -128,6 +128,8 @@ struct tls_data {
const Elf_Rela *rela;
};
int64_t rtld_tlsdesc_handle(struct tls_data *tlsdesc, int flags);
static struct tls_data *
reloc_tlsdesc_alloc(Obj_Entry *obj, const Elf_Rela *rela)
{
@ -205,7 +207,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -243,7 +245,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Sym *def;
struct tls_data *tlsdesc;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
@ -289,7 +291,7 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
if (!obj->irelative)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_AARCH64_IRELATIVE) {
ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend);
@ -316,7 +318,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
if (!obj->gnu_ifunc)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_AARCH64_JUMP_SLOT) {
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -338,8 +340,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_AARCH64_JUMP_SLOT ||
@ -386,7 +389,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
/*
* First, resolve symbol for relocations which
@ -471,7 +474,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);

View File

@ -67,7 +67,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela + dstobj->relasize);
relalim = (const Elf_Rela *)((const char *) dstobj->rela + dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_X86_64_COPY) {
void *dstaddr;
@ -80,7 +80,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -104,7 +104,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return -1;
}
srcaddr = (const void *) (defobj->relocbase + srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase + srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
}
}
@ -147,7 +147,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char*)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
/*
* First, resolve symbol for relocations which
@ -254,7 +254,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -274,7 +275,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -322,7 +324,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -355,7 +357,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (obj->jmpslots_done)
return 0;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
const Elf_Sym *def;
@ -392,8 +394,9 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
/* Fixup the jump slot at "where" to transfer control to "target". */
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj,
const Elf_Rel *rel)
const struct Struct_Obj_Entry *obj __unused,
const struct Struct_Obj_Entry *refobj __unused,
const Elf_Rel *rel __unused)
{
#ifdef dbg
dbg("reloc_jmpslot: *%p = %p", where, (void *)target);
@ -411,7 +414,7 @@ reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
if (!obj->irelative)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target, *ptr;
@ -441,7 +444,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (!obj->gnu_ifunc)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
const Elf_Sym *def;

View File

@ -75,7 +75,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *) dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) == R_ARM_COPY) {
void *dstaddr;
@ -88,7 +88,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
dstaddr = (void *)(dstobj->relocbase + rel->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -125,8 +125,6 @@ do_copy_relocations(Obj_Entry *dstobj)
void _rtld_bind_start(void);
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
int open();
int _open();
void
_rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
{
@ -145,7 +143,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
break;
}
}
rellim = (const Elf_Rel *)((caddr_t)rel + relsz);
rellim = (const Elf_Rel *)((const char *)rel + relsz);
size = (rellim - 1)->r_offset - rel->r_offset;
for (; rel < rellim; rel++) {
where = (Elf_Addr *)(relocbase + rel->r_offset);
@ -375,7 +373,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
if (reloc_nonplt_object(obj, rel, cache, flags, lockstate) < 0)
goto done;
@ -396,7 +394,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel +
rellim = (const Elf_Rel *)((const char *)obj->pltrel +
obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -423,7 +421,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
@ -445,7 +443,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -453,8 +452,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -462,8 +461,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);

View File

@ -67,7 +67,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *)dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) == R_386_COPY) {
void *dstaddr;
@ -80,7 +80,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
dstaddr = (void *)(dstobj->relocbase + rel->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -104,7 +104,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return -1;
}
srcaddr = (const void *) (defobj->relocbase + srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase + srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
}
}
@ -146,7 +146,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
rellim = (const Elf_Rel *)((caddr_t) obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
switch (ELF_R_TYPE(rel->r_info)) {
case R_386_32:
@ -239,7 +239,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -278,7 +279,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where/*, val*/;
@ -311,7 +312,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (obj->jmpslots_done)
return 0;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where, target;
const Elf_Sym *def;
@ -349,8 +350,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
/* Fixup the jump slot at "where" to transfer control to "target". */
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj,
const Elf_Rel *rel)
const Obj_Entry *obj __unused, const Obj_Entry *refobj __unused,
const Elf_Rel *rel __unused)
{
#ifdef dbg
dbg("reloc_jmpslot: *%p = %p", where, (void *)target);
@ -369,7 +370,7 @@ reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
if (!obj->irelative)
return (0);
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
switch (ELF_R_TYPE(rel->r_info)) {
case R_386_IRELATIVE:
@ -393,7 +394,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (!obj->gnu_ifunc)
return (0);
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where, target;
const Elf_Sym *def;

View File

@ -58,7 +58,7 @@ extern uint32_t cpu_feature2;
extern uint32_t cpu_stdext_feature;
extern uint32_t cpu_stdext_feature2;
#define call_ifunc_resolver(ptr) \
(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))ptr)( \
(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))(ptr))( \
cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2))
#define round(size, align) \

View File

@ -44,8 +44,8 @@ struct lmc {
static int lm_count;
static void lmc_parse(char *, size_t);
static void lmc_parse_file(char *);
static void lmc_parse_dir(char *);
static void lmc_parse_file(const char *);
static void lmc_parse_dir(const char *);
static void lm_add(const char *, const char *, const char *);
static void lm_free(struct lm_list *);
static char *lml_find(struct lm_list *, const char *);
@ -96,7 +96,7 @@ lm_init(char *libmap_override)
}
static void
lmc_parse_file(char *path)
lmc_parse_file(const char *path)
{
struct lmc *p;
char *lm_map;
@ -149,7 +149,7 @@ lmc_parse_file(char *path)
}
static void
lmc_parse_dir(char *idir)
lmc_parse_dir(const char *idir)
{
DIR *d;
struct dirent *dp;

View File

@ -154,13 +154,12 @@ botch(s)
extern size_t *pagesizes;
void *
malloc(nbytes)
size_t nbytes;
malloc(size_t nbytes)
{
union overhead *op;
int bucket;
size_t n;
unsigned amt;
ssize_t n;
size_t amt;
/*
* First time malloc is called, setup page size and

View File

@ -104,7 +104,7 @@ map_object(int fd, const char *path, const struct stat *sb)
*
* We expect that the loadable segments are ordered by load address.
*/
phdr = (Elf_Phdr *) ((char *)hdr + hdr->e_phoff);
phdr = (Elf_Phdr *)((char *)hdr + hdr->e_phoff);
phsize = hdr->e_phnum * sizeof (phdr[0]);
phlimit = phdr + hdr->e_phnum;
nsegs = -1;
@ -289,11 +289,11 @@ map_object(int fd, const char *path, const struct stat *sb)
obj->textsize = text_end - base_vaddr;
obj->vaddrbase = base_vaddr;
obj->relocbase = mapbase - base_vaddr;
obj->dynamic = (const Elf_Dyn *) (obj->relocbase + phdyn->p_vaddr);
obj->dynamic = (const Elf_Dyn *)(obj->relocbase + phdyn->p_vaddr);
if (hdr->e_entry != 0)
obj->entry = (caddr_t) (obj->relocbase + hdr->e_entry);
obj->entry = (caddr_t)(obj->relocbase + hdr->e_entry);
if (phdr_vaddr != 0) {
obj->phdr = (const Elf_Phdr *) (obj->relocbase + phdr_vaddr);
obj->phdr = (const Elf_Phdr *)(obj->relocbase + phdr_vaddr);
} else {
obj->phdr = malloc(phsize);
if (obj->phdr == NULL) {
@ -301,12 +301,12 @@ map_object(int fd, const char *path, const struct stat *sb)
_rtld_error("%s: cannot allocate program header", path);
goto error1;
}
memcpy((char *)obj->phdr, (char *)hdr + hdr->e_phoff, phsize);
memcpy(__DECONST(char *, obj->phdr), (char *)hdr + hdr->e_phoff, phsize);
obj->phdr_alloc = true;
}
obj->phsize = phsize;
if (phinterp != NULL)
obj->interp = (const char *) (obj->relocbase + phinterp->p_vaddr);
obj->interp = (const char *)(obj->relocbase + phinterp->p_vaddr);
if (phtls != NULL) {
tls_dtv_generation++;
obj->tlsindex = ++tls_max_index;
@ -430,13 +430,13 @@ obj_free(Obj_Entry *obj)
if (obj->origin_path)
free(obj->origin_path);
if (obj->z_origin)
free(obj->rpath);
free(__DECONST(void*, obj->rpath));
if (obj->priv)
free(obj->priv);
if (obj->path)
free(obj->path);
if (obj->phdr_alloc)
free((void *)obj->phdr);
free(__DECONST(void *, obj->phdr));
free(obj);
}

View File

@ -126,7 +126,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
rellim = (const Elf_Rel *)((caddr_t)dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *)dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) != R_MIPS_COPY)
continue;
@ -265,7 +265,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
++got;
}
rellim = (const Elf_Rel *)((caddr_t)rel + relsz);
rellim = (const Elf_Rel *)((const char *)rel + relsz);
for (; rel < rellim; rel++) {
Elf_Word r_symndx, r_type;
@ -469,7 +469,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
}
got = obj->pltgot;
rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
Elf_Word r_symndx, r_type;
void *where;
@ -657,7 +657,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -687,7 +687,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Rel *rel;
const Elf_Sym *def;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -714,7 +714,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -722,8 +723,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -731,8 +732,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_MIPS_JUMP_SLOT);

View File

@ -43,6 +43,9 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
Elf_Addr _mips_rtld_bind(struct Struct_Obj_Entry *obj, Elf_Size reloff);
void *_mips_get_tls(void);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -69,10 +69,10 @@
#define SOFT_STANDARD_LIBRARY_PATH "/usr/libsoft"
#define LD_SOFT_ "LD_SOFT_"
extern char *ld_elf_hints_default;
extern char *ld_path_libmap_conf;
extern char *ld_path_rtld;
extern char *ld_standard_library_path;
extern char *ld_env_prefix;
extern const char *ld_elf_hints_default;
extern const char *ld_path_libmap_conf;
extern const char *ld_path_rtld;
extern const char *ld_standard_library_path;
extern const char *ld_env_prefix;
#endif /* PATHS_H */

View File

@ -71,7 +71,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
relalim = (const Elf_Rela *)((const char *) dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
void *dstaddr;
@ -88,7 +88,7 @@ do_copy_relocations(Obj_Entry *dstobj)
continue;
}
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -113,7 +113,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return (-1);
}
srcaddr = (const void *) (defobj->relocbase+srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase+srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
dbg("copy_reloc: src=%p,dst=%p,size=%d\n",srcaddr,dstaddr,size);
}
@ -149,7 +149,7 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
/*
* Relocate these values
*/
relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
relalim = (const Elf_Rela *)((const char *)rela + relasz);
for (; rela < relalim; rela++) {
where = (Elf_Addr *)(relocbase + rela->r_offset);
*where = (Elf_Addr)(relocbase + rela->r_addend);
@ -161,8 +161,8 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
* Relocate a non-PLT object with addend.
*/
static int
reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
SymCache *cache, int flags, RtldLockState *lockstate)
reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
{
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
const Elf_Sym *def;
@ -249,7 +249,8 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for static "
"Thread Local Storage", obj->path);
return (-1);
@ -315,7 +316,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* "The PowerPC family uses only the Elf32_Rela relocation
* entries with explicit addends."
*/
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj_rtld, obj, rela, cache, flags,
lockstate) < 0)
@ -398,7 +399,7 @@ reloc_plt(Obj_Entry *obj)
if (obj->pltrelasize != 0) {
relalim = (const Elf_Rela *)((char *)obj->pltrela +
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
@ -433,7 +434,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -469,8 +471,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
* trampoline call and jump table.
*/
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj, const Elf_Rel *rel)
{
Elf_Addr offset;
const Elf_Rela *rela = (const Elf_Rela *) rel;
@ -529,7 +531,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -537,8 +540,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -650,7 +653,7 @@ allocate_initial_tls(Obj_Entry *list)
tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8)
tp = (Elf_Addr **)((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
/*

View File

@ -42,6 +42,7 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -67,7 +67,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
relalim = (const Elf_Rela *)((const char *) dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
void *dstaddr;
@ -84,7 +84,7 @@ do_copy_relocations(Obj_Entry *dstobj)
continue;
}
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -109,7 +109,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return (-1);
}
srcaddr = (const void *) (defobj->relocbase+srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase+srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
dbg("copy_reloc: src=%p,dst=%p,size=%zd\n",srcaddr,dstaddr,size);
}
@ -145,7 +145,7 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
/*
* Relocate these values
*/
relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
relalim = (const Elf_Rela *)((const char *)rela + relasz);
for (; rela < relalim; rela++) {
where = (Elf_Addr *)(relocbase + rela->r_offset);
*where = (Elf_Addr)(relocbase + rela->r_addend);
@ -157,8 +157,8 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
* Relocate a non-PLT object with addend.
*/
static int
reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
SymCache *cache, int flags, RtldLockState *lockstate)
reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
{
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
const Elf_Sym *def;
@ -246,7 +246,8 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for static "
"Thread Local Storage", obj->path);
return (-1);
@ -315,7 +316,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* "The PowerPC family uses only the Elf32_Rela relocation
* entries with explicit addends."
*/
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj_rtld, obj, rela, cache, flags,
lockstate) < 0)
@ -370,7 +371,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *rela;
if (obj->pltrelasize != 0) {
relalim = (const Elf_Rela *)((char *)obj->pltrela +
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
@ -398,7 +399,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -435,7 +437,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
*/
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
const Obj_Entry *obj __unused, const Elf_Rel *rel __unused)
{
/*
@ -494,7 +496,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -502,8 +505,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -555,7 +558,7 @@ allocate_initial_tls(Obj_Entry *list)
tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *)allocate_tls(list, NULL, TLS_TCB_SIZE, 16)
tp = (Elf_Addr **)((char *)allocate_tls(list, NULL, TLS_TCB_SIZE, 16)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
__asm __volatile("mr 13,%0" :: "r"(tp));

View File

@ -42,6 +42,7 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -105,7 +105,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *)((char *)dstobj->rela +
relalim = (const Elf_Rela *)((const char *)dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) != R_RISCV_COPY)
@ -152,7 +152,8 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -176,7 +177,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Rela *rela;
const Elf_Sym *def;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -203,7 +205,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -211,8 +214,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -220,8 +223,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_RISCV_JUMP_SLOT);
@ -260,7 +264,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
symnum = ELF_R_SYM(rela->r_info);
@ -315,7 +319,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);
@ -341,7 +346,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);
@ -390,7 +396,7 @@ allocate_initial_tls(Obj_Entry *objs)
tls_static_space = tls_last_offset + tls_last_size +
RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *)allocate_tls(objs, NULL, TLS_TCB_SIZE, 16)
tp = (Elf_Addr **)((char *)allocate_tls(objs, NULL, TLS_TCB_SIZE, 16)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
__asm __volatile("mv tp, %0" :: "r"(tp));
@ -407,5 +413,5 @@ __tls_get_addr(tls_index* ti)
p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)_tp - TLS_TP_OFFSET
- TLS_TCB_SIZE), ti->ti_module, ti->ti_offset);
return (p + TLS_DTV_OFFSET);
return ((char*)p + TLS_DTV_OFFSET);
}

View File

@ -159,7 +159,7 @@ static void unref_dag(Obj_Entry *);
static void ref_dag(Obj_Entry *);
static char *origin_subst_one(Obj_Entry *, char *, const char *,
const char *, bool);
static char *origin_subst(Obj_Entry *, char *);
static char *origin_subst(Obj_Entry *, const char *);
static bool obj_resolve_origin(Obj_Entry *obj);
static void preinit_main(void);
static int rtld_verify_versions(const Objlist *);
@ -196,8 +196,8 @@ static char *ld_library_path; /* Environment variable for search path */
static char *ld_library_dirs; /* Environment variable for library descriptors */
static char *ld_preload; /* Environment variable for libraries to
load first */
static char *ld_elf_hints_path; /* Environment variable for alternative hints path */
static char *ld_tracing; /* Called from ldd to print libs */
static const char *ld_elf_hints_path; /* Environment variable for alternative hints path */
static const char *ld_tracing; /* Called from ldd to print libs */
static char *ld_utrace; /* Use utrace() to log events. */
static struct obj_entry_q obj_list; /* Queue of all loaded objects */
static Obj_Entry *obj_main; /* The main program shared object */
@ -277,11 +277,11 @@ bool ld_library_path_rpath = false;
/*
* Globals for path names, and such
*/
char *ld_elf_hints_default = _PATH_ELF_HINTS;
char *ld_path_libmap_conf = _PATH_LIBMAP_CONF;
char *ld_path_rtld = _PATH_RTLD;
char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
char *ld_env_prefix = LD_;
const char *ld_elf_hints_default = _PATH_ELF_HINTS;
const char *ld_path_libmap_conf = _PATH_LIBMAP_CONF;
const char *ld_path_rtld = _PATH_RTLD;
const char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
const char *ld_env_prefix = LD_;
/*
* Fill in a DoneList with an allocation large enough to hold all of
@ -363,7 +363,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
RtldLockState lockstate;
struct stat st;
Elf_Addr *argcp;
char **argv, *argv0, **env, **envp, *kexecpath, *library_path_rpath;
char **argv, **env, **envp, *kexecpath, *library_path_rpath;
const char *argv0;
caddr_t imgentry;
char buf[MAXPATHLEN];
int argc, fd, i, phnum, rtld_argc;
@ -797,11 +798,11 @@ _rtld_bind(Obj_Entry *obj, Elf_Size reloff)
if (sigsetjmp(lockstate.env, 0) != 0)
lock_upgrade(rtld_bind_lock, &lockstate);
if (obj->pltrel)
rel = (const Elf_Rel *) ((caddr_t) obj->pltrel + reloff);
rel = (const Elf_Rel *)((const char *)obj->pltrel + reloff);
else
rel = (const Elf_Rel *) ((caddr_t) obj->pltrela + reloff);
rel = (const Elf_Rel *)((const char *)obj->pltrela + reloff);
where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, SYMLOOK_IN_PLT,
NULL, &lockstate);
if (def == NULL)
@ -944,7 +945,7 @@ origin_subst_one(Obj_Entry *obj, char *real, const char *kw,
}
static char *
origin_subst(Obj_Entry *obj, char *real)
origin_subst(Obj_Entry *obj, const char *real)
{
char *res1, *res2, *res3, *res4;
@ -956,7 +957,9 @@ origin_subst(Obj_Entry *obj, char *real)
return (NULL);
}
}
res1 = origin_subst_one(obj, real, "$ORIGIN", NULL, false);
/* __DECONST is safe here since without may_free real is unchanged */
res1 = origin_subst_one(obj, __DECONST(char *, real), "$ORIGIN", NULL,
false);
res2 = origin_subst_one(NULL, res1, "$OSNAME", uts.sysname, true);
res3 = origin_subst_one(NULL, res2, "$OSREL", uts.release, true);
res4 = origin_subst_one(NULL, res3, "$PLATFORM", uts.machine, true);
@ -1003,7 +1006,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
switch (dynp->d_tag) {
case DT_REL:
obj->rel = (const Elf_Rel *) (obj->relocbase + dynp->d_un.d_ptr);
obj->rel = (const Elf_Rel *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_RELSZ:
@ -1024,7 +1027,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_RELA:
obj->rela = (const Elf_Rela *) (obj->relocbase + dynp->d_un.d_ptr);
obj->rela = (const Elf_Rela *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_RELASZ:
@ -1050,7 +1053,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_STRTAB:
obj->strtab = (const char *) (obj->relocbase + dynp->d_un.d_ptr);
obj->strtab = (const char *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_STRSZ:
@ -1058,7 +1061,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_VERNEED:
obj->verneed = (const Elf_Verneed *) (obj->relocbase +
obj->verneed = (const Elf_Verneed *)(obj->relocbase +
dynp->d_un.d_val);
break;
@ -1067,7 +1070,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_VERDEF:
obj->verdef = (const Elf_Verdef *) (obj->relocbase +
obj->verdef = (const Elf_Verdef *)(obj->relocbase +
dynp->d_un.d_val);
break;
@ -1103,7 +1106,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords;
obj->maskwords_bm_gnu = nmaskwords - 1;
obj->shift2_gnu = hashtab[3];
obj->bloom_gnu = (Elf_Addr *) (hashtab + 4);
obj->bloom_gnu = (const Elf_Addr *)(hashtab + 4);
obj->buckets_gnu = hashtab + 4 + bloom_size32;
obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu -
obj->symndx_gnu;
@ -1150,7 +1153,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_PLTGOT:
obj->pltgot = (Elf_Addr *) (obj->relocbase + dynp->d_un.d_ptr);
obj->pltgot = (Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_TEXTREL:
@ -1178,7 +1181,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_INIT:
obj->init = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->init = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_PREINIT_ARRAY:
@ -1198,7 +1201,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_FINI:
obj->fini = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->fini = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_FINI_ARRAY:
@ -1218,7 +1221,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
case DT_DEBUG:
if (!early)
dbg("Filling in DT_DEBUG entry");
((Elf_Dyn*)dynp)->d_un.d_ptr = (Elf_Addr) &r_debug;
(__DECONST(Elf_Dyn *, dynp))->d_un.d_ptr = (Elf_Addr)&r_debug;
break;
#endif
@ -1252,7 +1255,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_MIPS_PLTGOT:
obj->mips_pltgot = (Elf_Addr *) (obj->relocbase +
obj->mips_pltgot = (Elf_Addr *)(obj->relocbase +
dynp->d_un.d_ptr);
break;
@ -1260,7 +1263,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
#ifdef __powerpc64__
case DT_PPC64_GLINK:
obj->glink = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->glink = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
#endif
@ -1337,10 +1340,10 @@ digest_dynamic2(Obj_Entry *obj, const Elf_Dyn *dyn_rpath,
rtld_die();
if (dyn_runpath != NULL) {
obj->runpath = (char *)obj->strtab + dyn_runpath->d_un.d_val;
obj->runpath = (const char *)obj->strtab + dyn_runpath->d_un.d_val;
obj->runpath = origin_subst(obj, obj->runpath);
} else if (dyn_rpath != NULL) {
obj->rpath = (char *)obj->strtab + dyn_rpath->d_un.d_val;
obj->rpath = (const char *)obj->strtab + dyn_rpath->d_un.d_val;
obj->rpath = origin_subst(obj, obj->rpath);
}
if (dyn_soname != NULL)
@ -1380,7 +1383,7 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
obj->phdr = phdr;
obj->phsize = ph->p_memsz;
obj->relocbase = (caddr_t)phdr - ph->p_vaddr;
obj->relocbase = __DECONST(char *, phdr) - ph->p_vaddr;
break;
}
@ -1586,14 +1589,15 @@ gnu_hash(const char *s)
static char *
find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
{
char *name, *pathname, *refobj_path;
char *pathname, *refobj_path;
const char *name;
bool nodeflib, objgiven;
objgiven = refobj != NULL;
if (libmap_disable || !objgiven ||
(name = lm_find(refobj->path, xname)) == NULL)
name = (char *)xname;
name = xname;
if (strchr(name, '/') != NULL) { /* Hard coded pathname */
if (name[0] != '/' && !trust) {
@ -1782,7 +1786,8 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
static const char *
gethints(bool nostdlib)
{
static char *hints, *filtered_path;
static char *filtered_path;
static const char *hints;
static struct elfhints_hdr hdr;
struct fill_search_info_args sargs, hargs;
struct dl_serinfo smeta, hmeta, *SLPinfo, *hintinfo;
@ -2518,7 +2523,7 @@ obj_from_addr(const void *addr)
continue;
if (addr < (void *) obj->mapbase)
continue;
if (addr < (void *) (obj->mapbase + obj->mapsize))
if (addr < (void *)(obj->mapbase + obj->mapsize))
return obj;
}
return NULL;
@ -3215,12 +3220,12 @@ dlerror(void)
*/
void
dllockinit(void *context,
void *(*lock_create)(void *context),
void (*rlock_acquire)(void *lock),
void (*wlock_acquire)(void *lock),
void (*lock_release)(void *lock),
void (*lock_destroy)(void *lock),
void (*context_destroy)(void *context))
void *(*_lock_create)(void *context) __unused,
void (*_rlock_acquire)(void *lock) __unused,
void (*_wlock_acquire)(void *lock) __unused,
void (*_lock_release)(void *lock) __unused,
void (*_lock_destroy)(void *lock) __unused,
void (*context_destroy)(void *context))
{
static void *cur_context;
static void (*cur_context_destroy)(void *);
@ -3258,7 +3263,7 @@ rtld_dlopen(const char *name, int fd, int mode)
rlock_acquire(rtld_bind_lock, &lockstate);
if (sigsetjmp(lockstate.env, 0) != 0)
lock_upgrade(rtld_bind_lock, &lockstate);
environ = (char **)*get_program_var_addr("environ", &lockstate);
environ = __DECONST(char **, *get_program_var_addr("environ", &lockstate));
lock_release(rtld_bind_lock, &lockstate);
}
lo_flags = RTLD_LO_DLOPEN;
@ -3971,7 +3976,7 @@ linkmap_delete(Obj_Entry *obj)
* +0 RetAddr
*/
void
r_debug_state(struct r_debug* rd, struct link_map *m)
r_debug_state(struct r_debug* rd __unused, struct link_map *m __unused)
{
/*
* The following is a hack to force the compiler to emit calls to
@ -3989,7 +3994,7 @@ r_debug_state(struct r_debug* rd, struct link_map *m)
* main is not available in the symbol table.
*/
void
_r_debug_postinit(struct link_map *m)
_r_debug_postinit(struct link_map *m __unused)
{
/* See r_debug_state(). */
@ -4310,8 +4315,8 @@ matched_symbol(SymLook *req, const Obj_Entry *obj, Sym_Match_Result *result,
else if (((req->flags & SYMLOOK_IN_PLT) == 0) &&
(ELF_ST_TYPE(symp->st_info) == STT_FUNC))
break;
/* fallthrough */
#endif
/* fallthrough */
default:
return (false);
}
@ -4480,8 +4485,8 @@ symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj)
static void
trace_loaded_objects(Obj_Entry *obj)
{
char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
const char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
main_local = "";
@ -4495,9 +4500,9 @@ trace_loaded_objects(Obj_Entry *obj)
list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL"));
for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
Needed_Entry *needed;
char *name, *path;
bool is_lib;
Needed_Entry *needed;
const char *name, *path;
bool is_lib;
if (obj->marker)
continue;
@ -4512,7 +4517,7 @@ trace_loaded_objects(Obj_Entry *obj)
} else
path = "not found";
name = (char *)obj->strtab + needed->name;
name = obj->strtab + needed->name;
is_lib = strncmp(name, "lib", 3) == 0; /* XXX - bogus */
fmt = is_lib ? fmt1 : fmt2;
@ -4752,7 +4757,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
char *tls_block;
Elf_Addr *dtv, **tcb;
Elf_Addr addr;
int i;
Elf_Addr i;
size_t extra_size, maxalign, post_size, pre_size, tls_block_size;
size_t tls_init_align;
@ -4800,7 +4805,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
if (obj->tlsinitsize > 0)
memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
if (obj->tlssize > obj->tlsinitsize)
memset((void*) (addr + obj->tlsinitsize), 0,
memset((void*)(addr + obj->tlsinitsize), 0,
obj->tlssize - obj->tlsinitsize);
dtv[obj->tlsindex + 1] = addr;
}
@ -4811,7 +4816,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
}
void
free_tls(void *tcb, size_t tcbsize, size_t tcbalign)
free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
{
Elf_Addr *dtv;
Elf_Addr tlsstart, tlsend;
@ -4902,7 +4907,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
if (obj->marker || obj->tlsoffset == 0)
continue;
addr = segbase - obj->tlsoffset;
memset((void*) (addr + obj->tlsinitsize),
memset((void*)(addr + obj->tlsinitsize),
0, obj->tlssize - obj->tlsinitsize);
if (obj->tlsinit)
memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
@ -4914,7 +4919,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
}
void
free_tls(void *tls, size_t tcbsize, size_t tcbalign)
free_tls(void *tls, size_t tcbsize __unused, size_t tcbalign)
{
Elf_Addr* dtv;
size_t size, ralign;
@ -5130,13 +5135,13 @@ check_object_provided_version(Obj_Entry *refobj, const Obj_Entry *depobj,
}
if (vna->vna_hash == vd->vd_hash) {
const Elf_Verdaux *aux = (const Elf_Verdaux *)
((char *)vd + vd->vd_aux);
((const char *)vd + vd->vd_aux);
if (strcmp(vername, depobj->strtab + aux->vda_name) == 0)
return (0);
}
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
if (vna->vna_flags & VER_FLG_WEAK)
return (0);
@ -5172,18 +5177,18 @@ rtld_verify_object_versions(Obj_Entry *obj)
obj->path, vn->vn_version);
return (-1);
}
vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux);
vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
for (;;) {
vernum = VER_NEED_IDX(vna->vna_other);
if (vernum > maxvernum)
maxvernum = vernum;
if (vna->vna_next == 0)
break;
vna = (const Elf_Vernaux *) ((char *)vna + vna->vna_next);
vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next);
}
if (vn->vn_next == 0)
break;
vn = (const Elf_Verneed *) ((char *)vn + vn->vn_next);
vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next);
}
vd = obj->verdef;
@ -5198,7 +5203,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
maxvernum = vernum;
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
if (maxvernum == 0)
@ -5217,7 +5222,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
if ((vd->vd_flags & VER_FLG_BASE) == 0) {
vernum = VER_DEF_IDX(vd->vd_ndx);
assert(vernum <= maxvernum);
vda = (const Elf_Verdaux *)((char *)vd + vd->vd_aux);
vda = (const Elf_Verdaux *)((const char *)vd + vd->vd_aux);
obj->vertab[vernum].hash = vd->vd_hash;
obj->vertab[vernum].name = obj->strtab + vda->vda_name;
obj->vertab[vernum].file = NULL;
@ -5225,7 +5230,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
}
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
vn = obj->verneed;
@ -5233,7 +5238,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
depobj = locate_dependency(obj, obj->strtab + vn->vn_file);
if (depobj == NULL)
return (-1);
vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux);
vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
for (;;) {
if (check_object_provided_version(obj, depobj, vna))
return (-1);
@ -5246,11 +5251,11 @@ rtld_verify_object_versions(Obj_Entry *obj)
VER_INFO_HIDDEN : 0;
if (vna->vna_next == 0)
break;
vna = (const Elf_Vernaux *) ((char *)vna + vna->vna_next);
vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next);
}
if (vn->vn_next == 0)
break;
vn = (const Elf_Verneed *) ((char *)vn + vn->vn_next);
vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next);
}
return 0;
}
@ -5577,7 +5582,7 @@ int _thread_autoinit_dummy_decl = 1;
* No unresolved symbols for rtld.
*/
void
__pthread_cxa_finalize(struct dl_phdr_info *a)
__pthread_cxa_finalize(struct dl_phdr_info *a __unused)
{
}

View File

@ -211,12 +211,12 @@ typedef struct Struct_Obj_Entry {
Elf32_Word maskwords_bm_gnu; /* Bloom filter words - 1 (bitmask) */
Elf32_Word shift2_gnu; /* Bloom filter shift count */
Elf32_Word dynsymcount; /* Total entries in dynsym table */
Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */
const Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */
const Elf_Hashelt *buckets_gnu; /* GNU hash table bucket array */
const Elf_Hashelt *chain_zero_gnu; /* GNU hash table value array (Zeroed) */
char *rpath; /* Search path specified in object */
char *runpath; /* Search path with different priority */
const char *rpath; /* Search path specified in object */
const char *runpath; /* Search path with different priority */
Needed_Entry *needed; /* Shared objects needed by this one (%) */
Needed_Entry *needed_filtees;
Needed_Entry *needed_aux_filtees;

View File

@ -256,7 +256,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
relalim = (const Elf_Rela *)((caddr_t)dstobj->rela + dstobj->relasize);
relalim = (const Elf_Rela *)((const char *)dstobj->rela + dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_SPARC_COPY) {
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
@ -316,7 +316,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj, rela, cache, flags, lockstate) < 0)
goto done;
@ -408,8 +408,8 @@ reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache,
* of) static TLS in dynamically loaded modules. If
* we run out of space, we generate an error.
*/
if (!defobj->tls_done &&
!allocate_tls_offset((Obj_Entry*)defobj)) {
if (!defobj->tls_done && !allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for "
"static Thread Local Storage", obj->path);
return (-1);
@ -487,7 +487,7 @@ reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache,
}
int
reloc_plt(Obj_Entry *obj)
reloc_plt(Obj_Entry *obj __unused)
{
#if 0
const Obj_Entry *defobj;
@ -542,7 +542,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF64_R_TYPE_ID(rela->r_info) == R_SPARC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -551,14 +552,16 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (def == NULL)
return -1;
target = (Elf_Addr)(defobj->relocbase + def->st_value);
reloc_jmpslot(where, target, defobj, obj, (Elf_Rel *)rela);
reloc_jmpslot(where, target, defobj, obj,
(const Elf_Rel *)rela);
}
obj->jmpslots_done = true;
return (0);
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -566,8 +569,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -575,7 +578,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj __unused,
const Obj_Entry *refobj, const Elf_Rel *rel)
{
const Elf_Rela *rela = (const Elf_Rela *)rel;
@ -612,7 +615,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
*/
where = (Elf_Word *)wherep;
offset = ((Elf_Addr)where) - target;
if (offset <= (1L<<20) && offset >= -(1L<<20)) {
if (offset <= (1UL<<20) && offset >= -(1UL<<20)) {
/*
* We're within 1MB -- we can use a direct branch
* instruction.
@ -631,7 +634,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
*/
where[1] = BAA | ((offset >> 2) &0x3fffff);
flush(where, 4);
} else if (target >= 0 && target < (1L<<32)) {
} else if (target < (1UL<<32)) {
/*
* We're within 32-bits of address zero.
*
@ -651,7 +654,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(target, 10);
flush(where, 4);
} else if (target <= 0 && target > -(1L<<32)) {
} else if (target > -(1UL<<32)) {
/*
* We're within 32-bits of address -1.
*
@ -673,7 +676,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(~target, 10);
flush(where, 4);
} else if (offset <= (1L<<32) && offset >= -((1L<<32) - 4)) {
} else if (offset <= (1UL<<32) && offset >= -((1UL<<32) - 4)) {
/*
* We're within 32-bits -- we can use a direct call
* insn
@ -696,7 +699,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = MOV71;
flush(where, 4);
} else if (offset >= 0 && offset < (1L<<44)) {
} else if (offset < (1L<<44)) {
/*
* We're within 44 bits. We can generate this
* pattern:
@ -721,7 +724,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(offset, 22);
flush(where, 4);
} else if (offset < 0 && offset > -(1L<<44)) {
} else if (offset > -(1UL<<44)) {
/*
* We're within 44 bits. We can generate this
* pattern: