summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-09-21 20:42:44 +0000
committerRich Felker <dalias@aerifal.cx>2015-09-21 20:42:44 +0000
commitd874064579f4dd8150b0d6ff6d98942af6fcd1c3 (patch)
tree0f2b4071be5cf895894964d54a712c60fdc8321e
parent2a5473382014aa49c6ff236db3a60c8050b9e327 (diff)
downloadmusl-d874064579f4dd8150b0d6ff6d98942af6fcd1c3.tar.gz
musl-d874064579f4dd8150b0d6ff6d98942af6fcd1c3.tar.bz2
musl-d874064579f4dd8150b0d6ff6d98942af6fcd1c3.tar.xz
musl-d874064579f4dd8150b0d6ff6d98942af6fcd1c3.zip
simplify dlstart code by using integer type for base address
-rw-r--r--src/ldso/dlstart.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ldso/dlstart.c b/src/ldso/dlstart.c
index a968baab..e84e073e 100644
--- a/src/ldso/dlstart.c
+++ b/src/ldso/dlstart.c
@@ -21,6 +21,7 @@ __attribute__((__visibility__("hidden")))
void _dlstart_c(size_t *sp, size_t *dynv)
{
size_t i, aux[AUX_CNT], dyn[DYN_CNT];
+ size_t *rel, rel_size, base;
int argc = *sp;
char **argv = (void *)(sp+1);
@@ -40,14 +41,14 @@ void _dlstart_c(size_t *sp, size_t *dynv)
* address is not available in the aux vector. Instead, compute
* the load address as the difference between &_DYNAMIC and the
* virtual address in the PT_DYNAMIC program header. */
- unsigned char *base = (void *)aux[AT_BASE];
+ base = aux[AT_BASE];
if (!base) {
size_t phnum = aux[AT_PHNUM];
size_t phentsize = aux[AT_PHENT];
Phdr *ph = (void *)aux[AT_PHDR];
for (i=phnum; i--; ph = (void *)((char *)ph + phentsize)) {
if (ph->p_type == PT_DYNAMIC) {
- base = (void *)((size_t)dynv - ph->p_vaddr);
+ base = (size_t)dynv - ph->p_vaddr;
break;
}
}
@@ -61,17 +62,15 @@ void _dlstart_c(size_t *sp, size_t *dynv)
size_t *got = (void *)(base + dyn[DT_PLTGOT]);
for (i=0; dynv[i]; i+=2) if (dynv[i]==DT_MIPS_LOCAL_GOTNO)
local_cnt = dynv[i+1];
- for (i=0; i<local_cnt; i++) got[i] += (size_t)base;
+ for (i=0; i<local_cnt; i++) got[i] += base;
}
- size_t *rel, rel_size;
-
rel = (void *)(base+dyn[DT_REL]);
rel_size = dyn[DT_RELSZ];
for (; rel_size; rel+=2, rel_size-=2*sizeof(size_t)) {
if (!IS_RELATIVE(rel[1])) continue;
size_t *rel_addr = (void *)(base + rel[0]);
- *rel_addr += (size_t)base;
+ *rel_addr += base;
}
rel = (void *)(base+dyn[DT_RELA]);
@@ -79,12 +78,12 @@ void _dlstart_c(size_t *sp, size_t *dynv)
for (; rel_size; rel+=3, rel_size-=3*sizeof(size_t)) {
if (!IS_RELATIVE(rel[1])) continue;
size_t *rel_addr = (void *)(base + rel[0]);
- *rel_addr = (size_t)base + rel[2];
+ *rel_addr = base + rel[2];
}
stage2_func dls2;
GETFUNCSYM(&dls2, __dls2, base+dyn[DT_PLTGOT]);
- dls2(base, sp);
+ dls2((void *)base, sp);
}
#endif