summaryrefslogtreecommitdiffstats
path: root/libdex
diff options
context:
space:
mode:
Diffstat (limited to 'libdex')
-rw-r--r--libdex/Android.mk7
-rw-r--r--libdex/OptInvocation.cpp32
-rw-r--r--libdex/sha1.cpp4
3 files changed, 38 insertions, 5 deletions
diff --git a/libdex/Android.mk b/libdex/Android.mk
index bb8d03b96..adae003a8 100644
--- a/libdex/Android.mk
+++ b/libdex/Android.mk
@@ -30,7 +30,6 @@ dex_src_files := \
InstrUtils.cpp \
Leb128.cpp \
OptInvocation.cpp \
- sha1.cpp \
SysUtil.cpp \
ZipArchive.cpp
@@ -49,6 +48,10 @@ ifneq ($(SDK_ONLY),true) # SDK_only doesn't need device version
include $(CLEAR_VARS)
#LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1
+ifneq ($(findstring -O3, $(TARGET_GLOBAL_CFLAGS)),)
+# Workaround for https://bugs.launchpad.net/linaro-android/+bug/948255
+LOCAL_CFLAGS += -O2
+endif
LOCAL_SRC_FILES := $(dex_src_files)
LOCAL_C_INCLUDES += $(dex_include_files)
LOCAL_MODULE_TAGS := optional
@@ -64,7 +67,7 @@ endif # !SDK_ONLY
##
##
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(dex_src_files)
+LOCAL_SRC_FILES := $(dex_src_files) sha1.cpp
LOCAL_C_INCLUDES += $(dex_include_files)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libdex
diff --git a/libdex/OptInvocation.cpp b/libdex/OptInvocation.cpp
index bac2f247d..7a25c2954 100644
--- a/libdex/OptInvocation.cpp
+++ b/libdex/OptInvocation.cpp
@@ -32,6 +32,8 @@
#include "OptInvocation.h"
#include "DexFile.h"
+#include <cutils/properties.h>
+
static const char* kCacheDirectoryName = "dalvik-cache";
static const char* kClassesDex = "classes.dex";
@@ -50,7 +52,11 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)
char absoluteFile[sizeof(nameBuf)];
const size_t kBufLen = sizeof(nameBuf) - 1;
const char* dataRoot;
+ const char* dexRoot;
+ const char* cacheRoot;
+ const char* systemRoot;
char* cp;
+ char dexoptDataOnly[PROPERTY_VALUE_MAX];
/*
* Get the absolute path of the Jar or DEX file.
@@ -93,10 +99,34 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)
/* Build the name of the cache directory.
*/
+
+ /* load paths from the system environment */
+ cacheRoot = getenv("ANDROID_CACHE");
dataRoot = getenv("ANDROID_DATA");
+ systemRoot = getenv("ANDROID_ROOT");
+
+ /* make sure we didn't get any NULL values */
+ if (cacheRoot == NULL)
+ cacheRoot = "/cache";
+
if (dataRoot == NULL)
dataRoot = "/data";
- snprintf(nameBuf, kBufLen, "%s/%s", dataRoot, kCacheDirectoryName);
+
+ if (systemRoot == NULL)
+ systemRoot = "/system";
+
+ if (dexRoot == NULL)
+ dexRoot = "/data";
+
+ /* Cache anything stored on /system in cacheRoot, everything else in dataRoot */
+ if (!strncmp(absoluteFile, systemRoot, strlen(systemRoot))) {
+ property_get("dalvik.vm.dexopt-data-only", dexoptDataOnly, "");
+ if (strcmp(dexoptDataOnly, "1") != 0) {
+ dexRoot = cacheRoot;
+ }
+ }
+
+ snprintf(nameBuf, kBufLen, "%s/%s", dexRoot, kCacheDirectoryName);
/* Tack on the file name for the actual cache file path.
*/
diff --git a/libdex/sha1.cpp b/libdex/sha1.cpp
index 15a81cca3..aefa2222e 100644
--- a/libdex/sha1.cpp
+++ b/libdex/sha1.cpp
@@ -142,8 +142,8 @@ union CHAR64LONG16 {
};
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
-static unsigned char workspace[64];
- block = (CHAR64LONG16*)workspace;
+static CHAR64LONG16 workspace;
+ block = &workspace;
memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16*)buffer;