OSDN Git Service

am ff38bd30: am b32addbf: Merge "Don\'t crash if the dmtracedump -d file doesn\'t...
authorElliott Hughes <enh@google.com>
Wed, 6 Mar 2013 16:54:00 +0000 (16:54 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 6 Mar 2013 16:54:00 +0000 (16:54 +0000)
* commit 'ff38bd30c42ecf85eab3d07efdb18b5c77cadb5a':
  Don't crash if the dmtracedump -d file doesn't exist.

dx/junit-tests/Android.mk
vm/Android.mk
vm/Init.cpp
vm/compiler/codegen/arm/Thumb2/Factory.cpp

index 3f2c611..ee5e31b 100644 (file)
@@ -4,6 +4,5 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 LOCAL_JAVA_LIBRARIES := dx junit
-LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE:= dx-tests
 include $(BUILD_HOST_JAVA_LIBRARY)
index 0af62e8..c9b510b 100644 (file)
@@ -65,6 +65,8 @@ include $(BUILD_SHARED_LIBRARY)
 include $(LOCAL_PATH)/ReconfigureDvm.mk
 LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
                 -DWITH_JIT_TUNING $(target_smp_flag)
+# TODO: split out the asflags.
+LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
 LOCAL_MODULE := libdvm_assert
 include $(BUILD_SHARED_LIBRARY)
 
index 11d884e..9169a5d 100644 (file)
@@ -28,6 +28,9 @@
 #include <linux/fs.h>
 #include <cutils/fs.h>
 #include <unistd.h>
+#ifdef HAVE_ANDROID_OS
+#include <sys/prctl.h>
+#endif
 
 #include "Dalvik.h"
 #include "test/Test.h"
@@ -1629,6 +1632,33 @@ static bool registerSystemNatives(JNIEnv* pEnv)
     return true;
 }
 
+/*
+ * Copied and modified slightly from system/core/toolbox/mount.c
+ */
+static std::string getMountsDevDir(const char *arg)
+{
+    char mount_dev[256];
+    char mount_dir[256];
+    int match;
+
+    FILE *fp = fopen("/proc/self/mounts", "r");
+    if (fp == NULL) {
+        ALOGE("Could not open /proc/self/mounts: %s", strerror(errno));
+        return "";
+    }
+
+    while ((match = fscanf(fp, "%255s %255s %*s %*s %*d %*d\n", mount_dev, mount_dir)) != EOF) {
+        mount_dev[255] = 0;
+        mount_dir[255] = 0;
+        if (match == 2 && (strcmp(arg, mount_dir) == 0)) {
+            fclose(fp);
+            return mount_dev;
+        }
+    }
+
+    fclose(fp);
+    return "";
+}
 
 /*
  * Do zygote-mode-only initialization.
@@ -1664,6 +1694,40 @@ static bool initZygote()
         }
     }
 
+    // Mark /system as NOSUID | NODEV
+    const char* android_root = getenv("ANDROID_ROOT");
+
+    if (android_root == NULL) {
+        SLOGE("environment variable ANDROID_ROOT does not exist?!?!");
+        return -1;
+    }
+
+    std::string mountDev(getMountsDevDir(android_root));
+    if (mountDev.empty()) {
+        SLOGE("Unable to find mount point for %s", android_root);
+        return -1;
+    }
+
+    if (mount(mountDev.c_str(), android_root, "none",
+            MS_REMOUNT | MS_NOSUID | MS_NODEV | MS_RDONLY | MS_BIND, NULL) == -1) {
+        SLOGE("Remount of %s failed: %s", android_root, strerror(errno));
+        return -1;
+    }
+
+#ifdef HAVE_ANDROID_OS
+    if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
+        if (errno == EINVAL) {
+            SLOGW("PR_SET_NO_NEW_PRIVS failed. "
+                  "Is your kernel compiled correctly?: %s", strerror(errno));
+            // Don't return -1 here, since it's expected that not all
+            // kernels will support this option.
+        } else {
+            SLOGW("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno));
+            return -1;
+        }
+    }
+#endif
+
     return true;
 }
 
index c3c3712..b9265e8 100644 (file)
@@ -727,7 +727,8 @@ static ArmLIR *loadConstantValueWide(CompilationUnit *cUnit, int rDestLo,
             loadPcRel->operands[1] = r15pc;
             setupResourceMasks(loadPcRel);
             setMemRefType(loadPcRel, true, kLiteral);
-            loadPcRel->aliasInfo = dataTarget->operands[0];
+            // TODO: rework literal load disambiguation to more cleanly handle 64-bit loads
+            loadPcRel->aliasInfo = (uintptr_t)dataTarget;
             dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel);
             res =  loadPcRel;
         }