]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
301265 - add x86 support to Android build
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 5 Aug 2012 00:08:25 +0000 (00:08 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 5 Aug 2012 00:08:25 +0000 (00:08 +0000)
Patch by Dragos Tatulea.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12835

20 files changed:
Makefile.all.am
NEWS
README.android
auxprogs/Makefile.am
configure.in
coregrind/Makefile.am
coregrind/launcher-linux.c
coregrind/m_coredump/coredump-elf.c
coregrind/m_debuginfo/readelf.c
coregrind/m_debuginfo/readstabs.c
coregrind/m_debuglog.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_options.c
coregrind/m_replacemalloc/vg_replace_malloc.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_ume/main.c
coregrind/vg_preloaded.c
coregrind/vgdb.c
include/vki/vki-linux.h
memcheck/mc_replace_strmem.c

index bcca5ff60acb4cb90881dd939d00f564158722aa..66bd414feb94fd1b1605f6a7a17e834b2694829c 100644 (file)
@@ -198,6 +198,13 @@ endif
 PRELOAD_LDFLAGS_COMMON_LINUX  = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
 PRELOAD_LDFLAGS_COMMON_DARWIN = -dynamic -dynamiclib -all_load
 
+if VGCONF_PLATVARIANT_IS_ANDROID
+# The Android toolchain includes all kinds of stdlib helpers present in
+# bionic which is bad because we are not linking with it and the Android
+# linker will panic.
+PRELOAD_LDFLAGS_COMMON_LINUX += -nostdlib
+endif
+
 PRELOAD_LDFLAGS_X86_LINUX    = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
 PRELOAD_LDFLAGS_AMD64_LINUX  = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
 PRELOAD_LDFLAGS_PPC32_LINUX  = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
diff --git a/NEWS b/NEWS
index 136afc93ff76fed9ea50d1afafb9ab3cfd5b8959..be48dea0dc05e6e69abfce0d17d9860feebe68b5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ xxx Don't forget to update VALGRIND_MAJOR/MINOR before release
   Memcheck, massif, lackey, callgrind and none are tools that have been
   tested and are known to work well. See README.mips for more details.
 
+* Preliminary support for x86 platform running Android.
+
 * ==================== TOOL CHANGES ====================
 
 * Massif
@@ -261,6 +263,7 @@ n-i-bz  Fix assert in gdbserver for watchpoints watching the same address
 300414  FCOM and FCOMP unimplemented for amd64 guest
 301204  infinite loop in canonicaliseSymtab with ifunc symbol
 301229  dup of 203877, see above.
+301265  add x86 support to Android build 
 301984  configure script doesn't detect certain versions of clang
 302205  Fix compiler warnings for POWER VEX code and POWER test cases
 302287  Unhandled movbe instruction on Atom processors
index 397a01d51ad4439c40e9b25ddea872e7e8ad9df6..fd06c59a73429e5b667b2773d27fad30b25a0b58 100644 (file)
@@ -3,13 +3,18 @@ How to cross-compile for Android.  These notes were last updated on
 17 Feb 2012, for Valgrind SVN revision 12390/2257.
 
 This is known to work at least for :
+ARM:
+####
   Android 4.0.3 running on a (rooted, AOSP build) Nexus S.
   Android 4.0.3 running on Motorola Xoom.
-  Android 4.0.3 running on android emulator.
+  Android 4.0.3 running on android arm emulator.
   Android 4.1   running on android emulator.
-
 Android 2.3.4 on Nexus S worked at some time in the past.
 
+x86:
+####
+  Android 4.0.3 running on android x86 emulator.
+
 On android, GDBserver might insert breaks at wrong addresses.
 Feedback on this welcome.
 
@@ -43,7 +48,7 @@ export NDKROOT=/path/to/android-ndk-r6
 # So choose one of the below:
 #
 export HWKIND=nexus_s         # Samsung Nexus S; also Xoom (for now)
-export HWKIND=pandaboard      # Pandaboard running Linaro Android
+export HWKIND=generic         # A generic Android device. eg, Pandaboard
 export HWKIND=emulator        # Android emulator
 
 # Then cd to the root of your Valgrind source tree.
@@ -57,10 +62,18 @@ cd /path/to/valgrind/source/tree
 
 # Set up toolchain paths.
 #
+For ARM
+#######
 export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
 export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
 export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
 
+For x86
+#######
+export AR=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ar
+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
+
 
 # Do configuration stuff.  Don't mess with the --prefix in the
 # configure command below, even if you think it's wrong.
@@ -70,6 +83,7 @@ export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
 
 ./autogen.sh
 
+# for ARM
 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" \
    CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
    ./configure --prefix=/data/local/Inst \
@@ -78,11 +92,21 @@ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HW
 # note: on android emulator, android-14 platform was also tested and works.
 # It is not clear what this platform nr really is.
 
+# for x86
+CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -DANDROID_HARDWARE_$HWKIND" \
+   CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -fno-pic" \
+   ./configure --prefix=/data/local/Inst \
+   --host=i686-android-linux --target=i686-android-linux \
+   --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:
-#
+# For ARM:
 #          Platform variant: android
 #     Primary -DVGPV string: -DVGPV_arm_linux_android=1
+# For x86:
+#          Platform variant: android
+#     Primary -DVGPV string: -DVGPV_x86_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
index c336b277c666cd822a5d1c1ef5de1e55d444960a..074d8f6b178436abfb4488f656c1b113009b8fd0 100644 (file)
@@ -31,6 +31,9 @@ valgrind_listener_CPPFLAGS  = $(AM_CPPFLAGS_PRI) -I$(top_srcdir)/coregrind
 valgrind_listener_CFLAGS    = $(AM_CFLAGS_PRI)
 valgrind_listener_CCASFLAGS = $(AM_CCASFLAGS_PRI)
 valgrind_listener_LDFLAGS   = $(AM_CFLAGS_PRI)
+if VGCONF_PLATVARIANT_IS_ANDROID
+valgrind_listener_CFLAGS    += -static
+endif
 if VGCONF_PLATFORMS_INCLUDE_X86_DARWIN
 valgrind_listener_LDFLAGS   += -Wl,-read_only_relocs -Wl,suppress
 endif
index 2ba2b009182fbd9d7f457097c8fb8aeac6fd74af..ed39ca48b6d8b41a92713c17f6bc15f240f48926 100644 (file)
@@ -944,10 +944,10 @@ 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 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.
+# 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.
 #
 # In almost all cases, the <variant> bit is "vanilla".  But for Android
 # it is "android" instead.
@@ -960,15 +960,14 @@ DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
 #
 #   -DVGP_arm_linux -DVGPV_arm_linux_android
 #
-# The setup of the platform variant is pushed relatively far down this
-# file in order that we can inspect any of the variables set above.
+# Same for x86. The setup of the platform variant is pushed relatively far
+# down this file in order that we can inspect any of the variables set above.
 
 # In the normal case ..
 VGCONF_PLATVARIANT="vanilla"
 
-# Android on ARM ?
-if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
-        -a "$GLIBC_VERSION" = "bionic";
+# Android ?
+if test "$GLIBC_VERSION" = "bionic";
 then
    VGCONF_PLATVARIANT="android"
 fi
index 0d44da6fdeffba1ce9e723332ab6027ddfd0697a..01015a70dc3cac6ed43813a30d547dd3956b89b8 100644 (file)
@@ -53,17 +53,19 @@ if VGCONF_PLATFORMS_INCLUDE_X86_DARWIN
 valgrind_LDFLAGS   += -Wl,-read_only_relocs -Wl,suppress
 endif
 # On Android we must ask for non-executable stack, not sure why.
-if VGCONF_PLATFORMS_INCLUDE_ARM_LINUX
 if VGCONF_PLATVARIANT_IS_ANDROID
+valgrind_CFLAGS += -static
 valgrind_LDFLAGS   += -Wl,-z,noexecstack
 endif
-endif
 
 vgdb_SOURCES = vgdb.c
 vgdb_CPPFLAGS  = $(AM_CPPFLAGS_PRI)
 vgdb_CFLAGS    = $(AM_CFLAGS_PRI)
 vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI)
 vgdb_LDFLAGS   = $(AM_CFLAGS_PRI)
+if VGCONF_PLATVARIANT_IS_ANDROID
+vgdb_CFLAGS    += -static
+endif
 if !VGCONF_PLATVARIANT_IS_ANDROID
 vgdb_LDADD     = -lpthread
 endif
index a9ad1e39cf58e202c93c92b655a91fa09a16abbf..45fcf2620b6c42f939477a08b6155d770429826a 100644 (file)
@@ -210,7 +210,7 @@ static const char *select_platform(const char *clientname)
                platform = "amd64-linux";
             }
          } else if (header[EI_DATA] == ELFDATA2MSB) {
-#           if !defined(VGPV_arm_linux_android)
+#           if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
             if (ehdr->e_machine == EM_PPC64 &&
                 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
                  ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
index ddfe2ba7134c523c416d25a96fc25a1c9a96786b..8a329a6400786a00e35bc3b4be299eef48327813 100644 (file)
@@ -136,7 +136,7 @@ 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)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
 /* Android's libc doesn't provide a definition for this.  Hence: */
 typedef
    struct {
@@ -159,7 +159,7 @@ static UInt note_size(const struct note *n)
                             + VG_ROUNDUP(n->note.n_descsz, 4);
 }
 
-#if !defined(VGPV_arm_linux_android)
+#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
 static void add_note(struct note **list, const Char *name, UInt type,
                      const void *data, UInt datasz)
 {
@@ -181,7 +181,7 @@ static void add_note(struct note **list, const Char *name, UInt type,
    VG_(memcpy)(n->name, name, namelen);
    VG_(memcpy)(n->name+VG_ROUNDUP(namelen,4), data, datasz);
 }
-#endif /* !defined(VGPV_arm_linux_android) */
+#endif /* !defined(VGPV_*_linux_android) */
 
 static void write_note(Int fd, const struct note *n)
 {
@@ -476,7 +476,7 @@ static void fill_fpu(const ThreadState *tst, vki_elf_fpregset_t *fpu)
 #endif
 }
 
-#if defined(VGP_x86_linux)
+#if defined(VGP_x86_linux) && !defined(VGPV_x86_linux_android)
 static void fill_xfpu(const ThreadState *tst, vki_elf_fpxregset_t *xfpu)
 {
    ThreadArchState* arch = (ThreadArchState*)&tst->arch;
@@ -589,26 +589,28 @@ void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, UInt max_size)
         continue;
 
 #     if defined(VGP_x86_linux)
+#     if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
       {
          vki_elf_fpxregset_t xfpu;
          fill_xfpu(&VG_(threads)[i], &xfpu);
          add_note(&notelist, "LINUX", NT_PRXFPREG, &xfpu, sizeof(xfpu));
       }
+#     endif
 #     endif
 
       fill_fpu(&VG_(threads)[i], &fpu);
-#     if !defined(VGPV_arm_linux_android)
+#     if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
       add_note(&notelist, "CORE", NT_FPREGSET, &fpu, sizeof(fpu));
 #     endif
 
       fill_prstatus(&VG_(threads)[i], &prstatus, si);
-#     if !defined(VGPV_arm_linux_android)
+#     if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
       add_note(&notelist, "CORE", NT_PRSTATUS, &prstatus, sizeof(prstatus));
 #     endif
    }
 
    fill_prpsinfo(&VG_(threads)[tid], &prpsinfo);
-#  if !defined(VGPV_arm_linux_android)
+#  if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
    add_note(&notelist, "CORE", NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
 #  endif
 
index dc0b21ccb55d4dd612687ec8cf3f0ea853466cdd..998e0fe81f3b7bf37bd9a32aa483441ab6146b2d 100644 (file)
@@ -385,7 +385,7 @@ Bool get_elf_symbol_info (
       in /system/bin/linker:  __dl_strcmp __dl_strlen
    */
    if (sym->st_size == 0) {
-#     if defined(VGPV_arm_linux_android)
+#     if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
       *sym_size_out = 2048;
 #     else
       TRACE_SYMTAB("    ignore -- size=0: %s\n", sym_name);
@@ -1120,7 +1120,7 @@ Bool find_ad_hoc_debug_image( struct _DebugInfo* di,
 {
    vg_assert(*dimage == 0 && *n_dimage == 0);
 
-#  if !defined(VGPV_arm_linux_android)
+#  if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
    return False; /* we don't know narfink */
 
 #  else /* android specific hacks; look away now. */
@@ -2659,7 +2659,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
 #     if !defined(VGP_amd64_linux) \
          && !defined(VGP_s390x_linux) \
          && !defined(VGP_ppc64_linux) \
-         && !defined(VGPV_arm_linux_android)
+         && !defined(VGPV_arm_linux_android) \
+         && !defined(VGPV_x86_linux_android)
       if (stab_img && stabstr_img) {
          ML_(read_debuginfo_stabs) ( di, stab_img, stab_sz, 
                                          stabstr_img, stabstr_sz );
index e62721b14d7aeb94709fa251637d29e70c8e9fda..d1d7440c42916fbae76b1ba182551cc2b81e0267 100644 (file)
@@ -35,8 +35,9 @@
 */
 
 /* "on Linux (except android), or on Darwin" */
-#if (defined(VGO_linux) && !defined(VGPV_arm_linux_android)) \
-    || defined(VGO_darwin)
+#if (defined(VGO_linux) && \
+    !(defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)) \
+    || defined(VGO_darwin))
 
 #include "pub_core_basics.h"
 #include "pub_core_debuginfo.h"
@@ -388,7 +389,7 @@ void ML_(read_debuginfo_stabs) ( DebugInfo* di,
    }
 }
 
-#endif /* (defined(VGO_linux) && !defined(VGPV_arm_linux_android)) \
+#endif /* (defined(VGO_linux) && !defined(VGPV_*_linux_android)) \
           || defined(VGO_darwin) */
 
 /*--------------------------------------------------------------------*/
index 8e1c032742db0ff4919aeab1a927fed60f878bd3..88c3a64cda39c83cc01eae9f5dcd870529b7783c 100644 (file)
@@ -76,12 +76,14 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n )
    Int result;
 
    __asm__ volatile (
+      "pushl %%ebx\n"
       "movl  $"VG_STRINGIFY(__NR_write)", %%eax\n" /* %eax = __NR_write */
       "movl  $2, %%ebx\n"       /* %ebx = stderr */
       "int   $0x80\n"           /* write(stderr, buf, n) */
+      "popl %%ebx\n"
       : /*wr*/    "=a" (result)
       : /*rd*/    "c" (buf), "d" (n)
-      : /*trash*/ "ebx", "edi", "memory", "cc"
+      : /*trash*/ "edi", "memory", "cc"
    );
 
    return result >= 0 ? result : -1;
index dd68d6b0615299d67372d56004638ba74e6ad2e5..132bdd77af1fd16eed280b51e7518b5498e37185 100644 (file)
@@ -643,7 +643,7 @@ Addr setup_client_stack( void*  init_sp,
          case AT_GID:
          case AT_EGID:
          case AT_CLKTCK:
-#        if !defined(VGPV_arm_linux_android)
+#        if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
          case AT_FPUCW: /* missing on android */
 #        endif
             /* All these are pointerless, so we don't need to do
index 4c3282fc985962efc281371e9337bc23327385b6..a19b4f7905bf8cc42c89ea6be8b1acac2503a5f7 100644 (file)
@@ -47,7 +47,7 @@ VexControl VG_(clo_vex_control);
 Bool   VG_(clo_error_limit)    = True;
 Int    VG_(clo_error_exitcode) = 0;
 
-#if defined(VGPV_arm_linux_android)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
 VgVgdb VG_(clo_vgdb)           = Vg_VgdbNo; // currently disabled on Android
 #else
 VgVgdb VG_(clo_vgdb)           = Vg_VgdbYes;
index bec413aa485cb60938207f05d140c62b03c6c3ab..17d9a96148572bfc5725d45ee1ed7e5a123cfc25 100644 (file)
@@ -119,6 +119,9 @@ static inline void my_exit ( int x )
 #  if defined(VGPV_arm_linux_android)
    __asm__ __volatile__(".word 0xFFFFFFFF");
    while (1) {}
+#  elif defined(VGPV_x86_linux_android)
+   __asm__ __volatile__("ud2");
+   while (1) {}
 #  else
    extern __attribute__ ((__noreturn__)) void _exit(int status);
    _exit(x);
@@ -128,7 +131,7 @@ static inline void my_exit ( int x )
 /* Same problem with getpagesize. */
 static inline int my_getpagesize ( void )
 {
-#  if defined(VGPV_arm_linux_android)
+#  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
    return 4096; /* kludge - link failure on Android, for some reason */
 #  else
    extern int getpagesize (void);
@@ -904,7 +907,7 @@ static void init(void);
  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)
+# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
   MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, dlmalloc_usable_size);
   MALLOC_USABLE_SIZE(SO_SYN_MALLOC,    dlmalloc_usable_size);
 # endif
index 64cacbe17eb102ccb32a99f63be88cb171365c11..eafbed4e4949769d159672e349256c142cd7b91d 100644 (file)
@@ -223,13 +223,15 @@ static void run_a_thread_NORETURN ( Word tidW )
          assembler. */
 #if defined(VGP_x86_linux)
       asm volatile (
+         "pushl %%ebx\n"
          "movl %1, %0\n"       /* set tst->status = VgTs_Empty */
          "movl %2, %%eax\n"    /* set %eax = __NR_exit */
          "movl %3, %%ebx\n"    /* set %ebx = tst->os_state.exitcode */
          "int  $0x80\n"        /* exit(tst->os_state.exitcode) */
+        "popl %%ebx\n"
          : "=m" (tst->status)
          : "n" (VgTs_Empty), "n" (__NR_exit), "m" (tst->os_state.exitcode)
-         : "eax", "ebx"
+         : "eax"
       );
 #elif defined(VGP_amd64_linux)
       asm volatile (
@@ -5379,7 +5381,7 @@ PRE(sys_ioctl)
       /* These just take an int by value */
       break;
 
-#  if defined(VGPV_arm_linux_android)
+#  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
    /* ashmem */
    case VKI_ASHMEM_GET_SIZE:
    case VKI_ASHMEM_SET_SIZE:
@@ -5445,7 +5447,7 @@ PRE(sys_ioctl)
            PRE_FIELD_WRITE("ioctl(BINDER_VERSION)", bv->protocol_version);
        }
        break;
-#  endif /* defined(VGPV_arm_linux_android) */
+#  endif /* defined(VGPV_*_linux_android) */
 
    case VKI_HCIINQUIRY:
       if (ARG3) {
@@ -5505,7 +5507,7 @@ POST(sys_ioctl)
 
    /* --- BEGIN special IOCTL handlers for specific Android hardware --- */
 
-#  if defined(VGPV_arm_linux_android)
+#  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
 
 #  if defined(ANDROID_HARDWARE_nexus_s)
 
@@ -5567,18 +5569,11 @@ POST(sys_ioctl)
    /* END Nexus S specific ioctls */
 
 
-#  elif defined(ANDROID_HARDWARE_pandaboard)
+#  elif defined(ANDROID_HARDWARE_generic) || defined(ANDROID_HARDWARE_emulator)
 
-   /* BEGIN Pandaboard specific ioctls */
+   /* BEGIN generic/emulator specific ioctls */
    /* currently none are known */
-   /* END Pandaboard specific ioctls */
-
-
-#  elif defined(ANDROID_HARDWARE_emulator)
-
-   /* BEGIN emulator specific ioctls */
-   /* currently none are known */
-   /* END emulator specific ioctls */
+   /* END generic/emulator specific ioctls */
 
 
 #  else /* no ANDROID_HARDWARE_anything defined */
@@ -5589,7 +5584,8 @@ POST(sys_ioctl)
 #   warning "building for.  Currently known values are"
 #   warning ""
 #   warning "   ANDROID_HARDWARE_nexus_s       Samsung Nexus S"
-#   warning "   ANDROID_HARDWARE_pandaboard    Pandaboard running Linaro Android"
+#   warning "   ANDROID_HARDWARE_generic       Generic device (eg, Pandaboard)"
+#   warning "   ANDROID_HARDWARE_emulator      x86 or arm emulator"
 #   warning ""
 #   warning "Make sure you exactly follow the steps in README.android."
 #   warning ""
@@ -5597,7 +5593,7 @@ POST(sys_ioctl)
 
 #  endif /* cases for ANDROID_HARDWARE_blah */
 
-#  endif /* defined(VGPV_arm_linux_android) */
+#  endif /* defined(VGPV_*_linux_android) */
 
    /* --- END special IOCTL handlers for specific Android hardware --- */
 
@@ -6408,7 +6404,7 @@ POST(sys_ioctl)
       }
       break;
 
-#  if defined(VGPV_arm_linux_android)
+#  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
    /* ashmem */
    case VKI_ASHMEM_GET_SIZE:
    case VKI_ASHMEM_SET_SIZE:
@@ -6449,7 +6445,7 @@ POST(sys_ioctl)
            POST_FIELD_WRITE(bv->protocol_version);
        }
        break;
-#  endif /* defined(VGPV_arm_linux_android) */
+#  endif /* defined(VGPV_*_linux_android) */
 
    case VKI_HCIINQUIRY:
       if (ARG3) {
index 12501826973daa11ef12cb6e995088d5f5950c89..6eca0a79884240dcbc5863c56921ec7dfbe43d8e 100644 (file)
@@ -199,7 +199,7 @@ static Bool is_binary_file(Char* f)
 // will refuse to (eg. scripts lacking a "#!" prefix).
 static Int do_exec_shell_followup(Int ret, HChar* exe_name, ExeInfo* info)
 {
-#  if defined(VGPV_arm_linux_android)
+#  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
    Char*  default_interp_name = "/system/bin/sh";
 #  else
    Char*  default_interp_name = "/bin/sh";
index 03038acb73d73287389ca95731644aabc35f73a1..1973291bd213e0b2934f2eef333390628733d865 100644 (file)
@@ -56,7 +56,8 @@
 void VG_NOTIFY_ON_LOAD(freeres)( void );
 void VG_NOTIFY_ON_LOAD(freeres)( void )
 {
-#  if !defined(__UCLIBC__) && !defined(VGPV_arm_linux_android)
+#  if !defined(__UCLIBC__) \
+   && !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
    extern void __libc_freeres(void);
    __libc_freeres();
 #  endif
@@ -89,27 +90,6 @@ void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void)
     return (void*)result;
 }
 
-#if defined(ANDROID_HARDWARE_emulator)
-/* When running on android emulator, we get the following error when doing
-     ./valgrind date
-
-   link_image[1921]:   494 could not load needed library
-   '/data/local/Inst/lib/valgrind/vgpreload_core-arm-linux.so' for 'date'
-   (reloc_library[1285]:   494 cannot locate '__cxa_finalize'...
-   )CANNOT LINK EXECUTABLE
-
-   This problem is bypassed by adding the below function.
-   Do not ask me to explain neither the problem nor the solution.
-*/
-extern void __cxa_finalize(void);
-void __cxa_finalize(void)
-{
-   // ??? what should we do here ? Silently do nothing looks not sane.
-   // So, try to crash:
-   *(volatile int *)0 = 'x';
-}
-#endif
-
 #elif defined(VGO_darwin)
 
 #include "config.h" /* VERSION */
index 8a4f58a14d70dd7a0bb6a3eaeb2aa8761985c102..9ed59a58042a2bd55fb299d5e4cc9587d85a30af 100644 (file)
@@ -94,7 +94,7 @@ I_die_here : (PTRACEINVOKER) architecture missing in vgdb.c
 #undef PTRACEINVOKER
 #endif
 
-#if defined(VGPV_arm_linux_android)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
 #undef PTRACEINVOKER
 #endif
 
@@ -1634,7 +1634,7 @@ void received_signal (int signum)
       sigpipe++;
    } else if (signum == SIGALRM) {
       sigalrm++;
-#if defined(VGPV_arm_linux_android)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
       /* Android has no pthread_cancel. As it also does not have
          PTRACE_INVOKER, there is no need for cleanup action.
          So, we just do nothing. */
index 0a54db0ff39586575b16af5b2a217dfc84656358..ccf0635e282683d2edf2f93de23664e628e4df56 100644 (file)
@@ -2844,7 +2844,7 @@ struct vki_getcpu_cache {
 // From kernel/common/include/linux/ashmem.h
 //----------------------------------------------------------------------
 
-#if defined(VGPV_arm_linux_android)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
 
 #define VKI_ASHMEM_NAME_LEN 256
 
@@ -2899,7 +2899,7 @@ struct vki_binder_version {
 #define VKI_BINDER_THREAD_EXIT _VKI_IOW('b', 8, int)
 #define VKI_BINDER_VERSION _VKI_IOWR('b', 9, struct vki_binder_version)
 
-#endif /* defined(VGPV_arm_linux_android) */
+#endif /* defined(VGPV_*_linux_android) */
 
 //----------------------------------------------------------------------
 // From linux-3.0.4/include/net/bluetooth/bluetooth.h
index 649c7e95af660757e859bf2de547c43ad3802d7b..485ec499ae46ec5acbc7bd9ab6764213342ed8f0 100644 (file)
@@ -142,6 +142,9 @@ static inline void my_exit ( int x )
 #  if defined(VGPV_arm_linux_android)
    __asm__ __volatile__(".word 0xFFFFFFFF");
    while (1) {}
+#  elif defined(VGPV_x86_linux_android)
+   __asm__ __volatile__("ud2");
+   while (1) {}
 #  else
    extern __attribute__ ((__noreturn__)) void _exit(int status);
    _exit(x);
@@ -179,6 +182,9 @@ static inline void my_exit ( int x )
  STRRCHR(VG_Z_LIBC_SONAME,   rindex)
  STRRCHR(VG_Z_LIBC_SONAME,   __GI_strrchr)
  STRRCHR(VG_Z_LD_LINUX_SO_2, rindex)
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
+  STRRCHR(NONE, __dl_strrchr); /* in /system/bin/linker */
+#endif
 
 #elif defined(VGO_darwin)
  //STRRCHR(VG_Z_LIBC_SONAME,   strrchr)
@@ -391,7 +397,7 @@ static inline void my_exit ( int x )
 #if defined(VGO_linux)
  STRLEN(VG_Z_LIBC_SONAME,          strlen)
  STRLEN(VG_Z_LIBC_SONAME,          __GI_strlen)
-# if defined(VGPV_arm_linux_android)
+# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
   STRLEN(NONE, __dl_strlen); /* in /system/bin/linker */
 # endif
 
@@ -502,6 +508,10 @@ static inline void my_exit ( int x )
 
 #if defined(VGO_linux)
 
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
+ STRLCPY(VG_Z_LIBC_SONAME, strlcpy);
+#endif
+
 #elif defined(VGO_darwin)
  //STRLCPY(VG_Z_LIBC_SONAME, strlcpy)
  //STRLCPY(VG_Z_DYLD,        strlcpy)
@@ -568,7 +578,7 @@ static inline void my_exit ( int x )
    }
 
 #if defined(VGO_linux)
-# if !defined(VGPV_arm_linux_android)
+# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
   STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
   STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
 # endif
@@ -605,7 +615,7 @@ static inline void my_exit ( int x )
    }
 
 #if defined(VGO_linux)
-# if !defined(VGPV_arm_linux_android)
+# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
   STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
   STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp)
 # endif
@@ -715,7 +725,7 @@ static inline void my_exit ( int x )
  STRCMP(VG_Z_LIBC_SONAME,          __GI_strcmp)
  STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp)
  STRCMP(VG_Z_LD64_SO_1,            strcmp)
-# if defined(VGPV_arm_linux_android)
+# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
   STRCMP(NONE, __dl_strcmp); /* in /system/bin/linker */
 # endif
 
@@ -1524,7 +1534,7 @@ static inline void my_exit ( int x )
    }
 
 #if defined(VGO_linux)
-# if !defined(VGPV_arm_linux_android)
+# if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android)
   STRCASESTR(VG_Z_LIBC_SONAME,      strcasestr)
 # endif