am 8e2b0e55: am bb3b1303: Merge "Enable -Wold-style-cast warnings for linker"

* commit '8e2b0e550a8e64da23c95fe265dbea7c6701e7c1':
  Enable -Wold-style-cast warnings for linker
This commit is contained in:
Dmitriy Ivanov 2015-01-23 03:28:02 +00:00 committed by Android Git Automerger
commit 4d2dcb896a
5 changed files with 15 additions and 10 deletions

View File

@ -35,6 +35,7 @@ LOCAL_CONLYFLAGS += \
LOCAL_CPPFLAGS += \ LOCAL_CPPFLAGS += \
-std=gnu++11 \ -std=gnu++11 \
-Wold-style-cast \
ifeq ($(TARGET_IS_64_BIT),true) ifeq ($(TARGET_IS_64_BIT),true)
LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT

View File

@ -151,7 +151,7 @@ static void log_signal_summary(int signum, const siginfo_t* info) {
} }
char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination
if (prctl(PR_GET_NAME, (unsigned long)thread_name, 0, 0, 0) != 0) { if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(thread_name), 0, 0, 0) != 0) {
strcpy(thread_name, "<name unknown>"); strcpy(thread_name, "<name unknown>");
} else { } else {
// short names are null terminated by prctl, but the man page // short names are null terminated by prctl, but the man page

View File

@ -71,6 +71,10 @@
* and NOEXEC * and NOEXEC
*/ */
// Override macros to use C++ style casts
#undef ELF_ST_TYPE
#define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)
#if defined(__LP64__) #if defined(__LP64__)
#define SEARCH_NAME(x) x #define SEARCH_NAME(x) x
#else #else
@ -364,12 +368,12 @@ static void parse_LD_PRELOAD(const char* path) {
// //
// This function is exposed via dlfcn.cpp and libdl.so. // This function is exposed via dlfcn.cpp and libdl.so.
_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) { _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
unsigned addr = (unsigned)pc; uintptr_t addr = reinterpret_cast<uintptr_t>(pc);
for (soinfo* si = solist; si != 0; si = si->next) { for (soinfo* si = solist; si != 0; si = si->next) {
if ((addr >= si->base) && (addr < (si->base + si->size))) { if ((addr >= si->base) && (addr < (si->base + si->size))) {
*pcount = si->ARM_exidx_count; *pcount = si->ARM_exidx_count;
return (_Unwind_Ptr)si->ARM_exidx; return reinterpret_cast<_Unwind_Ptr>(si->ARM_exidx);
} }
} }
*pcount = 0; *pcount = 0;
@ -2090,7 +2094,7 @@ bool soinfo::prelink_image() {
break; break;
case DT_INIT_ARRAYSZ: case DT_INIT_ARRAYSZ:
init_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); init_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_FINI_ARRAY: case DT_FINI_ARRAY:
@ -2099,7 +2103,7 @@ bool soinfo::prelink_image() {
break; break;
case DT_FINI_ARRAYSZ: case DT_FINI_ARRAYSZ:
fini_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); fini_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_PREINIT_ARRAY: case DT_PREINIT_ARRAY:
@ -2108,7 +2112,7 @@ bool soinfo::prelink_image() {
break; break;
case DT_PREINIT_ARRAYSZ: case DT_PREINIT_ARRAYSZ:
preinit_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); preinit_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_TEXTREL: case DT_TEXTREL:

View File

@ -688,7 +688,7 @@ int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, El
*/ */
int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias, ElfW(Addr) load_bias,
ElfW(Addr)** arm_exidx, unsigned* arm_exidx_count) { ElfW(Addr)** arm_exidx, size_t* arm_exidx_count) {
const ElfW(Phdr)* phdr = phdr_table; const ElfW(Phdr)* phdr = phdr_table;
const ElfW(Phdr)* phdr_limit = phdr + phdr_count; const ElfW(Phdr)* phdr_limit = phdr + phdr_count;
@ -698,7 +698,7 @@ int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count,
} }
*arm_exidx = reinterpret_cast<ElfW(Addr)*>(load_bias + phdr->p_vaddr); *arm_exidx = reinterpret_cast<ElfW(Addr)*>(load_bias + phdr->p_vaddr);
*arm_exidx_count = (unsigned)(phdr->p_memsz / 8); *arm_exidx_count = phdr->p_memsz / 8;
return 0; return 0;
} }
*arm_exidx = nullptr; *arm_exidx = nullptr;
@ -757,7 +757,7 @@ bool ElfReader::FindPhdr() {
ElfW(Addr) elf_addr = load_bias_ + phdr->p_vaddr; ElfW(Addr) elf_addr = load_bias_ + phdr->p_vaddr;
const ElfW(Ehdr)* ehdr = reinterpret_cast<const ElfW(Ehdr)*>(elf_addr); const ElfW(Ehdr)* ehdr = reinterpret_cast<const ElfW(Ehdr)*>(elf_addr);
ElfW(Addr) offset = ehdr->e_phoff; ElfW(Addr) offset = ehdr->e_phoff;
return CheckPhdr((ElfW(Addr))ehdr + offset); return CheckPhdr(reinterpret_cast<ElfW(Addr)>(ehdr) + offset);
} }
break; break;
} }

View File

@ -98,7 +98,7 @@ int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, El
#if defined(__arm__) #if defined(__arm__)
int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias, int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias,
ElfW(Addr)** arm_exidx, unsigned* arm_exidix_count); ElfW(Addr)** arm_exidx, size_t* arm_exidix_count);
#endif #endif
void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count, void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count,