mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
mips32: Adding mips32/Android support to Valgrind.
Necessary changes to Valgrind to support mips32 on Android. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13767
This commit is contained in:
parent
8e06b09720
commit
423d0643b9
@ -13,6 +13,12 @@ ARM:
|
||||
x86:
|
||||
Android 4.0.3 running on android x86 emulator.
|
||||
|
||||
mips32:
|
||||
Android 4.1.2 running on android mips emulator.
|
||||
Android 4.2.2 running on android mips emulator.
|
||||
Android 4.3 running on android mips emulator.
|
||||
Android 4.0.4 running on BROADCOM bcm7425
|
||||
|
||||
On android-arm, GDBserver might insert breaks at wrong addresses.
|
||||
Feedback on this welcome.
|
||||
|
||||
@ -70,6 +76,10 @@ export AR=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linu
|
||||
export LD=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld
|
||||
export CC=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc
|
||||
|
||||
# For MIPS32
|
||||
export AR=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ar
|
||||
export LD=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ld
|
||||
export CC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-gcc
|
||||
|
||||
# Do configuration stuff. Don't mess with the --prefix in the
|
||||
# configure command below, even if you think it's wrong.
|
||||
@ -97,6 +107,13 @@ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -DANDROID_HARDWARE_$HW
|
||||
--host=i686-android-linux --target=i686-android-linux \
|
||||
--with-tmpdir=/sdcard
|
||||
|
||||
# for MIPS32
|
||||
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips -DANDROID_HARDWARE_$HWKIND" \
|
||||
CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips" \
|
||||
./configure --prefix=/data/local/Inst \
|
||||
--host=mipsel-linux-android --target=mipsel-linux-android \
|
||||
--with-tmpdir=/sdcard
|
||||
|
||||
# At the end of the configure run, a few lines of details
|
||||
# are printed. Make sure that you see these two lines:
|
||||
#
|
||||
@ -108,6 +125,10 @@ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -DANDROID_HARDWARE_$HW
|
||||
# Platform variant: android
|
||||
# Primary -DVGPV string: -DVGPV_x86_linux_android=1
|
||||
#
|
||||
# For mips32:
|
||||
# Platform variant: android
|
||||
# Primary -DVGPV string: -DVGPV_mips32_linux_android=1
|
||||
#
|
||||
# If you see anything else at this point, something is wrong, and
|
||||
# either the build will fail, or will succeed but you'll get something
|
||||
# which won't work.
|
||||
|
||||
@ -957,9 +957,9 @@ DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
|
||||
# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
|
||||
# But there are times where we need a bit more control. The motivating
|
||||
# and currently only case is Android: this is almost identical to
|
||||
# {x86,arm}-linux, but not quite. So this introduces the concept of platform
|
||||
# variant tags, which get passed in the compile as -DVGPV_<arch>_<os>_<variant>
|
||||
# along with the main -DVGP_<arch>_<os> definition.
|
||||
# {x86,arm,mips}-linux, but not quite. So this introduces the concept of
|
||||
# platform variant tags, which get passed in the compile as
|
||||
# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
|
||||
#
|
||||
# In almost all cases, the <variant> bit is "vanilla". But for Android
|
||||
# it is "android" instead.
|
||||
|
||||
@ -222,7 +222,9 @@ static const char *select_platform(const char *clientname)
|
||||
platform = "mips64-linux";
|
||||
}
|
||||
} else if (header[EI_DATA] == ELFDATA2MSB) {
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) \
|
||||
&& !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
if (ehdr->e_machine == EM_PPC64 &&
|
||||
(ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
|
||||
ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
|
||||
|
||||
@ -136,7 +136,8 @@ static void fill_phdr(ESZ(Phdr) *phdr, const NSegment *seg, UInt off, Bool write
|
||||
phdr->p_align = VKI_PAGE_SIZE;
|
||||
}
|
||||
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
/* Android's libc doesn't provide a definition for this. Hence: */
|
||||
typedef
|
||||
struct {
|
||||
@ -159,7 +160,8 @@ static UInt note_size(const struct note *n)
|
||||
+ VG_ROUNDUP(n->note.n_descsz, 4);
|
||||
}
|
||||
|
||||
#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
static void add_note(struct note **list, const HChar *name, UInt type,
|
||||
const void *data, UInt datasz)
|
||||
{
|
||||
@ -605,7 +607,8 @@ void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, ULong max_size)
|
||||
continue;
|
||||
|
||||
# if defined(VGP_x86_linux)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
{
|
||||
vki_elf_fpxregset_t xfpu;
|
||||
fill_xfpu(&VG_(threads)[i], &xfpu);
|
||||
@ -615,18 +618,21 @@ void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, ULong max_size)
|
||||
# endif
|
||||
|
||||
fill_fpu(&VG_(threads)[i], &fpu);
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
add_note(¬elist, "CORE", NT_FPREGSET, &fpu, sizeof(fpu));
|
||||
# endif
|
||||
|
||||
fill_prstatus(&VG_(threads)[i], &prstatus, si);
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
add_note(¬elist, "CORE", NT_PRSTATUS, &prstatus, sizeof(prstatus));
|
||||
# endif
|
||||
}
|
||||
|
||||
fill_prpsinfo(&VG_(threads)[tid], &prpsinfo);
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
add_note(¬elist, "CORE", NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
|
||||
# endif
|
||||
|
||||
|
||||
@ -36,7 +36,8 @@
|
||||
|
||||
/* "on Linux (except android), or on Darwin" */
|
||||
#if (defined(VGO_linux) && \
|
||||
!(defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)) \
|
||||
!(defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)) \
|
||||
|| defined(VGO_darwin))
|
||||
|
||||
#include "pub_core_basics.h"
|
||||
|
||||
@ -640,7 +640,9 @@ Addr setup_client_stack( void* init_sp,
|
||||
case AT_GID:
|
||||
case AT_EGID:
|
||||
case AT_CLKTCK:
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) \
|
||||
&& !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
case AT_FPUCW: /* missing on android */
|
||||
# endif
|
||||
/* All these are pointerless, so we don't need to do
|
||||
@ -670,7 +672,8 @@ Addr setup_client_stack( void* init_sp,
|
||||
So, keep the AT_BASE on android for now.
|
||||
??? Need to dig in depth about AT_BASE/GDB interaction */
|
||||
# if !defined(VGPV_arm_linux_android) \
|
||||
&& !defined(VGPV_x86_linux_android)
|
||||
&& !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
auxv->a_type = AT_IGNORE;
|
||||
# endif
|
||||
auxv->u.a_val = info->interp_base;
|
||||
|
||||
@ -47,7 +47,8 @@ VexControl VG_(clo_vex_control);
|
||||
Bool VG_(clo_error_limit) = True;
|
||||
Int VG_(clo_error_exitcode) = 0;
|
||||
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
VgVgdb VG_(clo_vgdb) = Vg_VgdbNo; // currently disabled on Android
|
||||
#else
|
||||
VgVgdb VG_(clo_vgdb) = Vg_VgdbYes;
|
||||
|
||||
@ -116,7 +116,7 @@
|
||||
__attribute__ ((__noreturn__))
|
||||
static inline void my_exit ( int x )
|
||||
{
|
||||
# if defined(VGPV_arm_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_mips32_linux_android)
|
||||
__asm__ __volatile__(".word 0xFFFFFFFF");
|
||||
while (1) {}
|
||||
# elif defined(VGPV_x86_linux_android)
|
||||
@ -131,7 +131,8 @@ static inline void my_exit ( int x )
|
||||
/* Same problem with getpagesize. */
|
||||
static inline int my_getpagesize ( void )
|
||||
{
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
return 4096; /* kludge - link failure on Android, for some reason */
|
||||
# else
|
||||
extern int getpagesize (void);
|
||||
@ -939,7 +940,8 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x )
|
||||
MALLOC_USABLE_SIZE(SO_SYN_MALLOC, malloc_usable_size);
|
||||
MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size);
|
||||
MALLOC_USABLE_SIZE(SO_SYN_MALLOC, malloc_size);
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, dlmalloc_usable_size);
|
||||
MALLOC_USABLE_SIZE(SO_SYN_MALLOC, dlmalloc_usable_size);
|
||||
# endif
|
||||
|
||||
@ -6764,7 +6764,8 @@ PRE(sys_ioctl)
|
||||
/* These just take an int by value */
|
||||
break;
|
||||
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
/* ashmem */
|
||||
case VKI_ASHMEM_GET_SIZE:
|
||||
case VKI_ASHMEM_SET_SIZE:
|
||||
@ -6957,7 +6958,8 @@ POST(sys_ioctl)
|
||||
|
||||
/* --- BEGIN special IOCTL handlers for specific Android hardware --- */
|
||||
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
|
||||
# if defined(ANDROID_HARDWARE_nexus_s)
|
||||
|
||||
@ -7875,7 +7877,8 @@ POST(sys_ioctl)
|
||||
}
|
||||
break;
|
||||
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
/* ashmem */
|
||||
case VKI_ASHMEM_GET_SIZE:
|
||||
case VKI_ASHMEM_SET_SIZE:
|
||||
|
||||
@ -467,7 +467,15 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical,
|
||||
#elif defined(VGP_mips32_linux)
|
||||
VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla;
|
||||
canonical->sysno = gst->guest_r2; // v0
|
||||
if (canonical->sysno != __NR_syscall) {
|
||||
if (canonical->sysno == __NR_exit) {
|
||||
canonical->arg1 = gst->guest_r4; // a0
|
||||
canonical->arg2 = 0;
|
||||
canonical->arg3 = 0;
|
||||
canonical->arg4 = 0;
|
||||
canonical->arg5 = 0;
|
||||
canonical->arg6 = 0;
|
||||
canonical->arg8 = 0;
|
||||
} else if (canonical->sysno != __NR_syscall) {
|
||||
canonical->arg1 = gst->guest_r4; // a0
|
||||
canonical->arg2 = gst->guest_r5; // a1
|
||||
canonical->arg3 = gst->guest_r6; // a2
|
||||
|
||||
@ -199,7 +199,8 @@ static Bool is_binary_file(const HChar* f)
|
||||
// will refuse to (eg. scripts lacking a "#!" prefix).
|
||||
static Int do_exec_shell_followup(Int ret, const HChar* exe_name, ExeInfo* info)
|
||||
{
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
const HChar* default_interp_name = "/system/bin/sh";
|
||||
# else
|
||||
const HChar* default_interp_name = "/bin/sh";
|
||||
|
||||
@ -57,7 +57,8 @@ void VG_NOTIFY_ON_LOAD(freeres)( void );
|
||||
void VG_NOTIFY_ON_LOAD(freeres)( void )
|
||||
{
|
||||
# if !defined(__UCLIBC__) \
|
||||
&& !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
&& !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
extern void __libc_freeres(void);
|
||||
__libc_freeres();
|
||||
# endif
|
||||
|
||||
@ -689,7 +689,8 @@ void received_signal (int signum)
|
||||
sigpipe++;
|
||||
} else if (signum == SIGALRM) {
|
||||
sigalrm++;
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
/* Android has no pthread_cancel. As it also does not have
|
||||
an invoker implementation, there is no need for cleanup action.
|
||||
So, we just do nothing. */
|
||||
|
||||
@ -2865,7 +2865,8 @@ struct vki_getcpu_cache {
|
||||
// From kernel/common/include/linux/ashmem.h
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
|
||||
#define VKI_ASHMEM_NAME_LEN 256
|
||||
|
||||
|
||||
@ -144,7 +144,8 @@ Bool is_overlap ( void* dst, const void* src, SizeT dstlen, SizeT srclen )
|
||||
__attribute__ ((__noreturn__))
|
||||
static inline void my_exit ( int x )
|
||||
{
|
||||
# if defined(VGPV_arm_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_mips32_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
__asm__ __volatile__(".word 0xFFFFFFFF");
|
||||
while (1) {}
|
||||
# elif defined(VGPV_x86_linux_android)
|
||||
@ -192,7 +193,8 @@ static inline void my_exit ( int x )
|
||||
STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse2_no_bsf)
|
||||
STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse42)
|
||||
STRRCHR(VG_Z_LD_LINUX_SO_2, rindex)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
STRRCHR(NONE, __dl_strrchr); /* in /system/bin/linker */
|
||||
#endif
|
||||
|
||||
@ -414,7 +416,8 @@ static inline void my_exit ( int x )
|
||||
STRLEN(VG_Z_LIBC_SONAME, __strlen_sse42)
|
||||
STRLEN(VG_Z_LD_LINUX_SO_2, strlen)
|
||||
STRLEN(VG_Z_LD_LINUX_X86_64_SO_2, strlen)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
STRLEN(NONE, __dl_strlen); /* in /system/bin/linker */
|
||||
# endif
|
||||
|
||||
@ -527,7 +530,8 @@ static inline void my_exit ( int x )
|
||||
|
||||
#if defined(VGO_linux)
|
||||
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
STRLCPY(VG_Z_LIBC_SONAME, strlcpy);
|
||||
#endif
|
||||
|
||||
@ -599,7 +603,8 @@ static inline void my_exit ( int x )
|
||||
}
|
||||
|
||||
#if defined(VGO_linux)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
|
||||
STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
|
||||
# endif
|
||||
@ -636,7 +641,8 @@ static inline void my_exit ( int x )
|
||||
}
|
||||
|
||||
#if defined(VGO_linux)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
|
||||
STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp)
|
||||
# endif
|
||||
@ -748,7 +754,8 @@ static inline void my_exit ( int x )
|
||||
STRCMP(VG_Z_LIBC_SONAME, __strcmp_sse42)
|
||||
STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp)
|
||||
STRCMP(VG_Z_LD64_SO_1, strcmp)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
|
||||
# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
|
||||
|| defined(VGPV_mips32_linux_android)
|
||||
STRCMP(NONE, __dl_strcmp); /* in /system/bin/linker */
|
||||
# endif
|
||||
|
||||
@ -1612,7 +1619,8 @@ static inline void my_exit ( int x )
|
||||
}
|
||||
|
||||
#if defined(VGO_linux)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
|
||||
# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) \
|
||||
&& !defined(VGPV_mips32_linux_android)
|
||||
STRCASESTR(VG_Z_LIBC_SONAME, strcasestr)
|
||||
# endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user