Add run-time hash check for libRS.so
Change-Id: I327215cdf74bc0e969c45efb0ff83c3fd0165f1d
diff --git a/lib/ExecutionEngine/Compiler.cpp b/lib/ExecutionEngine/Compiler.cpp
index 207d9bf..4afbbb4 100644
--- a/lib/ExecutionEngine/Compiler.cpp
+++ b/lib/ExecutionEngine/Compiler.cpp
@@ -248,6 +248,8 @@
#if USE_CACHE
// Read in SHA1 checksum of libbcc and libRS.
readSHA1(sha1LibBCC_SHA1, sizeof(sha1LibBCC_SHA1), pathLibBCC_SHA1);
+
+ calcFileSHA1(sha1LibRS, pathLibRS);
#endif
GlobalInitialized = true;
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index 661c1b3..72d826c 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -225,8 +225,7 @@
}
int Script::internalLoadCache() {
- // Temporarly disable the cache.
- if (1 || getBooleanProp("debug.bcc.nocache")) {
+ if (getBooleanProp("debug.bcc.nocache")) {
// Android system environment property disable the cache mechanism by
// setting "debug.bcc.nocache". So we will not load the cache file any
// way.
@@ -274,6 +273,7 @@
// Dependencies
reader.addDependency(BCC_FILE_RESOURCE, pathLibBCC_SHA1, sha1LibBCC_SHA1);
+ reader.addDependency(BCC_FILE_RESOURCE, pathLibRS, sha1LibRS);
for (size_t i = 0; i < 2; ++i) {
if (mSourceList[i]) {
@@ -410,6 +410,7 @@
#ifdef TARGET_BUILD
// Dependencies
writer.addDependency(BCC_FILE_RESOURCE, pathLibBCC_SHA1, sha1LibBCC_SHA1);
+ writer.addDependency(BCC_FILE_RESOURCE, pathLibRS, sha1LibRS);
#endif
for (size_t i = 0; i < 2; ++i) {
diff --git a/lib/ExecutionEngine/Sha1Helper.cpp b/lib/ExecutionEngine/Sha1Helper.cpp
index 4e9ee07..b30c7a5 100644
--- a/lib/ExecutionEngine/Sha1Helper.cpp
+++ b/lib/ExecutionEngine/Sha1Helper.cpp
@@ -32,6 +32,9 @@
unsigned char sha1LibBCC_SHA1[20];
char const *pathLibBCC_SHA1 = "/system/lib/libbcc.so.sha1";
+unsigned char sha1LibRS[20];
+char const *pathLibRS = "/system/lib/libRS.so";
+
void calcSHA1(unsigned char *result, char const *data, size_t size) {
SHA1_CTX hashContext;
diff --git a/lib/ExecutionEngine/Sha1Helper.h b/lib/ExecutionEngine/Sha1Helper.h
index 08e0cda..fe13b7a 100644
--- a/lib/ExecutionEngine/Sha1Helper.h
+++ b/lib/ExecutionEngine/Sha1Helper.h
@@ -25,6 +25,9 @@
extern unsigned char sha1LibBCC_SHA1[20];
extern char const *pathLibBCC_SHA1;
+ extern unsigned char sha1LibRS[20];
+ extern char const *pathLibRS;
+
void calcSHA1(unsigned char *result, char const *data, size_t size);
void calcFileSHA1(unsigned char *result, char const *filename);