diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-10 11:44:09 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-10 11:45:02 +0800 |
commit | 681f1b744aec1b0888f4c7a68165720db9670300 (patch) | |
tree | 960e8c52988d6a34a3930779bc93ff10e902a4bc /sources/android/crazy_linker | |
parent | ac7003e419ed3b02df456a73f707acd7e26f5383 (diff) | |
download | ndk-681f1b744aec1b0888f4c7a68165720db9670300.tar.gz |
Fix vma_start vma_end for 64-bit.
Also fix warnings, and make mips64 in unsupported arch
Change-Id: I69241bca109b5f835b61235a160c4f02a838d7bc
Diffstat (limited to 'sources/android/crazy_linker')
4 files changed, 9 insertions, 5 deletions
diff --git a/sources/android/crazy_linker/src/elf_traits.h b/sources/android/crazy_linker/src/elf_traits.h index 1d9c8e117..82c17afa6 100644 --- a/sources/android/crazy_linker/src/elf_traits.h +++ b/sources/android/crazy_linker/src/elf_traits.h @@ -67,7 +67,7 @@ struct ELF { #define ELF_MACHINE EM_ARM #elif defined(__i386__) #define ELF_MACHINE EM_386 -#elif defined(__mips__) +#elif defined(__mips__) && !defined(__LP64__) // mips64el defines __mips__ too #define ELF_MACHINE EM_MIPS #elif defined(__aarch64__) #define ELF_MACHINE EM_AARCH64 diff --git a/sources/android/crazy_linker/tests/bar_with_relro.cpp b/sources/android/crazy_linker/tests/bar_with_relro.cpp index 46a05f6f8..9e35a0f5c 100644 --- a/sources/android/crazy_linker/tests/bar_with_relro.cpp +++ b/sources/android/crazy_linker/tests/bar_with_relro.cpp @@ -30,7 +30,7 @@ extern "C" void Bar() { for (size_t n = 0; n < sizeof(kStrings) / sizeof(kStrings[0]); ++n) { const char* ptr = kStrings[n]; if (strcmp(ptr, "another example string")) { - printf("%s: Bad string at offset=%d\n", __FUNCTION__, n); + printf("%s: Bad string at offset=%zu\n", __FUNCTION__, n); exit(1); } } diff --git a/sources/android/crazy_linker/tests/foo_with_relro.cpp b/sources/android/crazy_linker/tests/foo_with_relro.cpp index 67ef98ef4..c69a3193c 100644 --- a/sources/android/crazy_linker/tests/foo_with_relro.cpp +++ b/sources/android/crazy_linker/tests/foo_with_relro.cpp @@ -21,7 +21,7 @@ extern "C" void Foo() { for (size_t n = 0; n < sizeof(kStrings) / sizeof(kStrings[0]); ++n) { const char* ptr = kStrings[n]; if (strcmp(ptr, "some example string")) { - printf("%s: Bad string at offset=%d\n", __FUNCTION__, n); + printf("%s: Bad string at offset=%zu\n", __FUNCTION__, n); exit(1); } } diff --git a/sources/android/crazy_linker/tests/test_util.h b/sources/android/crazy_linker/tests/test_util.h index 28fd39fa9..0b876c22d 100644 --- a/sources/android/crazy_linker/tests/test_util.h +++ b/sources/android/crazy_linker/tests/test_util.h @@ -23,6 +23,10 @@ #include <sys/stat.h> #include <sys/uio.h> #include <unistd.h> +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS // to get PRI and SCN in 32-bit inttypes.h +#endif +#include <inttypes.h> namespace { @@ -341,8 +345,8 @@ inline void CheckRelroMaps(int expected_count) { if (!strstr(line, " r--")) Panic("Shared RELRO mapping is not readonly!\n"); // Check that they can't be remapped read-write. - unsigned vma_start, vma_end; - if (sscanf(line, "%x-%x", &vma_start, &vma_end) != 2) + uint64_t vma_start, vma_end; + if (sscanf(line, "%" SCNx64 "-%" SCNx64, &vma_start, &vma_end) != 2) Panic("Could not parse VM address range!\n"); int ret = ::mprotect( (void*)vma_start, vma_end - vma_start, PROT_READ | PROT_WRITE); |