Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167898244
D17153.id48003.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
17 KB
Referenced Files
None
Subscribers
None
D17153.id48003.diff
View Options
Index: libexec/rtld-elf/amd64/reloc.c
===================================================================
--- libexec/rtld-elf/amd64/reloc.c
+++ libexec/rtld-elf/amd64/reloc.c
@@ -67,7 +67,7 @@
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;
@@ -147,7 +147,7 @@
} 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 @@
* 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 @@
* 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 @@
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 @@
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 @@
/* 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 @@
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 @@
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;
Index: libexec/rtld-elf/libmap.c
===================================================================
--- libexec/rtld-elf/libmap.c
+++ libexec/rtld-elf/libmap.c
@@ -44,8 +44,8 @@
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 @@
}
static void
-lmc_parse_file(char *path)
+lmc_parse_file(const char *path)
{
struct lmc *p;
char *lm_map;
@@ -149,7 +149,7 @@
}
static void
-lmc_parse_dir(char *idir)
+lmc_parse_dir(const char *idir)
{
DIR *d;
struct dirent *dp;
Index: libexec/rtld-elf/map_object.c
===================================================================
--- libexec/rtld-elf/map_object.c
+++ libexec/rtld-elf/map_object.c
@@ -301,7 +301,7 @@
_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;
@@ -430,13 +430,13 @@
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);
}
Index: libexec/rtld-elf/paths.h
===================================================================
--- libexec/rtld-elf/paths.h
+++ libexec/rtld-elf/paths.h
@@ -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 */
Index: libexec/rtld-elf/rtld.h
===================================================================
--- libexec/rtld-elf/rtld.h
+++ libexec/rtld-elf/rtld.h
@@ -211,12 +211,12 @@
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;
Index: libexec/rtld-elf/rtld.c
===================================================================
--- libexec/rtld-elf/rtld.c
+++ libexec/rtld-elf/rtld.c
@@ -158,7 +158,7 @@
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 *);
@@ -195,8 +195,8 @@
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 */
@@ -276,11 +276,11 @@
/*
* 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
@@ -362,7 +362,8 @@
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;
@@ -796,9 +797,9 @@
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);
def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, SYMLOOK_IN_PLT,
@@ -943,7 +944,7 @@
}
static char *
-origin_subst(Obj_Entry *obj, char *real)
+origin_subst(Obj_Entry *obj, const char *real)
{
char *res1, *res2, *res3, *res4;
@@ -955,7 +956,9 @@
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);
@@ -1102,7 +1105,7 @@
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;
@@ -1217,7 +1220,7 @@
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
@@ -1336,10 +1339,10 @@
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)
@@ -1379,7 +1382,7 @@
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,14 @@
find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
{
char *pathname;
- char *name;
+ 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) {
@@ -1772,7 +1775,8 @@
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;
@@ -3201,11 +3205,11 @@
*/
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 *(*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;
@@ -3244,7 +3248,7 @@
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;
@@ -3957,7 +3961,7 @@
* +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
@@ -3975,7 +3979,7 @@
* 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(). */
@@ -4466,7 +4470,7 @@
static void
trace_loaded_objects(Obj_Entry *obj)
{
- char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
+ const char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
@@ -4482,7 +4486,7 @@
for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
Needed_Entry *needed;
- char *name, *path;
+ const char *name, *path;
bool is_lib;
if (obj->marker)
@@ -4498,7 +4502,7 @@
} 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;
@@ -4900,7 +4904,7 @@
}
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;
@@ -5116,13 +5120,13 @@
}
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);
@@ -5158,18 +5162,18 @@
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;
@@ -5184,7 +5188,7 @@
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)
@@ -5203,7 +5207,7 @@
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;
@@ -5211,7 +5215,7 @@
}
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;
@@ -5219,7 +5223,7 @@
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);
@@ -5232,11 +5236,11 @@
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;
}
@@ -5563,7 +5567,7 @@
* No unresolved symbols for rtld.
*/
void
-__pthread_cxa_finalize(struct dl_phdr_info *a)
+__pthread_cxa_finalize(struct dl_phdr_info *a __unused)
{
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 26, 8:08 AM (19 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37277943
Default Alt Text
D17153.id48003.diff (17 KB)
Attached To
Mode
D17153: rtld-elf: fix WANRS=4 warnings other than -Wcast-align
Attached
Detach File
Event Timeline
Log In to Comment