summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Chien <loganchien@google.com>2012-02-26 22:30:46 +0800
committerLogan Chien <loganchien@google.com>2012-02-26 22:30:46 +0800
commit8d2a1230eae323981b4f6e03406e801a51018432 (patch)
tree2b7195917e71bcd713165f4559293ed56b856cec
parent50b814ae8797a929bc0416d6a97e3551b24eaf30 (diff)
downloadlinkloader-8d2a1230eae323981b4f6e03406e801a51018432.tar.gz
Cast void* type to intptr_t before we cast it to int32_t.
Change-Id: I1d55bcc8784401ffe07f3b40761877ee02302f84
-rw-r--r--include/impl/ELFObject.hxx10
-rw-r--r--lib/GOT.cpp2
2 files changed, 6 insertions, 6 deletions
diff --git a/include/impl/ELFObject.hxx b/include/impl/ELFObject.hxx
index a16ea45..24ec1b2 100644
--- a/include/impl/ELFObject.hxx
+++ b/include/impl/ELFObject.hxx
@@ -433,7 +433,7 @@ relocateMIPS(void *(*find_sym)(void *context, char const *name),
void *stub = text->getStubLayout()->allocateStub((void *)A);
rsl_assert(stub && "cannot allocate stub.");
sym->setAddress(stub);
- S = (int32_t)stub;
+ S = (int32_t)(intptr_t)stub;
*inst |= ((S >> 2) & 0x3FFFFFF);
rsl_assert(((P + 4) >> 28) == (S >> 28) && "stub is too far.");
}
@@ -445,7 +445,7 @@ relocateMIPS(void *(*find_sym)(void *context, char const *name),
void *stub = text->getStubLayout()->allocateStub((void *)S);
rsl_assert(stub && "cannot allocate stub.");
sym->setAddress(stub);
- S = (int32_t)stub;
+ S = (int32_t)(intptr_t)stub;
*inst |= ((S >> 2) & 0x3FFFFFF);
rsl_assert(((P + 4) >> 28) == (S >> 28) && "stub is too far.");
}
@@ -467,7 +467,7 @@ relocateMIPS(void *(*find_sym)(void *context, char const *name),
}
}
if (strcmp (sym->getName(), "_gp_disp") == 0) {
- S = (int)got_address() + GP_OFFSET - (int)P;
+ S = (int)(intptr_t)got_address() + GP_OFFSET - (int)P;
sym->setAddress((void *)S);
}
*inst |= (((S + A + (int)0x8000) >> 16) & 0xFFFF);
@@ -477,7 +477,7 @@ relocateMIPS(void *(*find_sym)(void *context, char const *name),
*inst &= 0xFFFF0000;
A = A & 0xFFFF;
if (strcmp (sym->getName(), "_gp_disp") == 0) {
- S = (Inst_t)sym->getAddress(EM_MIPS);
+ S = (Inst_t)(intptr_t)sym->getAddress(EM_MIPS);
}
*inst |= ((S + A) & 0xFFFF);
break;
@@ -519,7 +519,7 @@ relocateMIPS(void *(*find_sym)(void *context, char const *name),
break;
case R_MIPS_GPREL32:
- *inst = A + S - ((int)got_address() + GP_OFFSET);
+ *inst = A + S - ((int)(intptr_t)got_address() + GP_OFFSET);
break;
}
}
diff --git a/lib/GOT.cpp b/lib/GOT.cpp
index cd2c96a..3f523c5 100644
--- a/lib/GOT.cpp
+++ b/lib/GOT.cpp
@@ -33,7 +33,7 @@ int search_got(int symbol_index, void *addr, uint8_t bind_type)
// For local symbols (R_MIPS_GOT16), we only store the high 16-bit value
// after adding 0x8000.
if (bind_type == STB_LOCAL)
- addr = (void *)(((int)addr + 0x8000) & 0xFFFF0000);
+ addr = (void *)(((intptr_t)addr + 0x8000) & 0xFFFF0000);
for (i = 0; i < got_symbol_count; i++) {
if (got_symbol_indexes[i] == symbol_index) {