am 3a50fe88: am 3a22361a: Validate ELF file segment lengths against file length when loading

* commit '3a50fe88c4a2ace9892a4ff3579cc9ca39ef8c30':
  Validate ELF file segment lengths against file length when loading
diff --git a/build/Android.common.mk b/build/Android.common.mk
index ac1be1e..dd0ba4d 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -82,7 +82,8 @@
 endif
 
 LLVM_ROOT_PATH := external/llvm
-include $(LLVM_ROOT_PATH)/llvm.mk
+# Don't fail a dalvik minimal host build.
+-include $(LLVM_ROOT_PATH)/llvm.mk
 
 # Clang build.
 # ART_TARGET_CLANG := true
diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index 13cd978..0676968 100644
--- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -109,8 +109,10 @@
    * be removed from a future version.
    */
   char native_thread_state;
-  int utime, stime, task_cpu;
-  GetTaskStats(t->GetTid(), native_thread_state, utime, stime, task_cpu);
+  int utime;
+  int stime;
+  int task_cpu;
+  GetTaskStats(t->GetTid(), &native_thread_state, &utime, &stime, &task_cpu);
 
   std::vector<uint8_t>& bytes = *reinterpret_cast<std::vector<uint8_t>*>(context);
   JDWP::Append4BE(bytes, t->GetThinLockId());
diff --git a/runtime/stack.h b/runtime/stack.h
index 8ecf8f0..7c87f45 100644
--- a/runtime/stack.h
+++ b/runtime/stack.h
@@ -138,13 +138,17 @@
   int64_t GetVRegLong(size_t i) const {
     DCHECK_LT(i, NumberOfVRegs());
     const uint32_t* vreg = &vregs_[i];
-    return *reinterpret_cast<const int64_t*>(vreg);
+    // Alignment attribute required for GCC 4.8
+    typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
+    return *reinterpret_cast<unaligned_int64*>(vreg);
   }
 
   double GetVRegDouble(size_t i) const {
     DCHECK_LT(i, NumberOfVRegs());
     const uint32_t* vreg = &vregs_[i];
-    return *reinterpret_cast<const double*>(vreg);
+    // Alignment attribute required for GCC 4.8
+    typedef const double unaligned_double __attribute__ ((aligned (4)));
+    return *reinterpret_cast<unaligned_double*>(vreg);
   }
 
   mirror::Object* GetVRegReference(size_t i) const {
@@ -177,13 +181,17 @@
   void SetVRegLong(size_t i, int64_t val) {
     DCHECK_LT(i, NumberOfVRegs());
     uint32_t* vreg = &vregs_[i];
-    *reinterpret_cast<int64_t*>(vreg) = val;
+    // Alignment attribute required for GCC 4.8
+    typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
+    *reinterpret_cast<unaligned_int64*>(vreg) = val;
   }
 
   void SetVRegDouble(size_t i, double val) {
     DCHECK_LT(i, NumberOfVRegs());
     uint32_t* vreg = &vregs_[i];
-    *reinterpret_cast<double*>(vreg) = val;
+    // Alignment attribute required for GCC 4.8
+    typedef double unaligned_double __attribute__ ((aligned (4)));
+    *reinterpret_cast<unaligned_double*>(vreg) = val;
   }
 
   void SetVRegReference(size_t i, mirror::Object* val) {
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 23cafe8..e8326ea 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -417,7 +417,7 @@
 void Thread::InitStackHwm() {
   void* stack_base;
   size_t stack_size;
-  GetThreadStack(pthread_self_, stack_base, stack_size);
+  GetThreadStack(pthread_self_, &stack_base, &stack_size);
 
   // TODO: include this in the thread dumps; potentially useful in SIGQUIT output?
   VLOG(threads) << StringPrintf("Native stack is at %p (%s)", stack_base, PrettySize(stack_size).c_str());
@@ -757,7 +757,7 @@
   int utime = 0;
   int stime = 0;
   int task_cpu = 0;
-  GetTaskStats(tid, native_thread_state, utime, stime, task_cpu);
+  GetTaskStats(tid, &native_thread_state, &utime, &stime, &task_cpu);
 
   os << "  | state=" << native_thread_state
      << " schedstat=( " << scheduler_stats << " )"
diff --git a/runtime/utils.cc b/runtime/utils.cc
index 8e810a7..ac5cae2 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -79,23 +79,23 @@
   return result;
 }
 
-void GetThreadStack(pthread_t thread, void*& stack_base, size_t& stack_size) {
+void GetThreadStack(pthread_t thread, void** stack_base, size_t* stack_size) {
 #if defined(__APPLE__)
-  stack_size = pthread_get_stacksize_np(thread);
+  *stack_size = pthread_get_stacksize_np(thread);
   void* stack_addr = pthread_get_stackaddr_np(thread);
 
   // Check whether stack_addr is the base or end of the stack.
   // (On Mac OS 10.7, it's the end.)
   int stack_variable;
   if (stack_addr > &stack_variable) {
-    stack_base = reinterpret_cast<byte*>(stack_addr) - stack_size;
+    *stack_base = reinterpret_cast<byte*>(stack_addr) - *stack_size;
   } else {
-    stack_base = stack_addr;
+    *stack_base = stack_addr;
   }
 #else
   pthread_attr_t attributes;
   CHECK_PTHREAD_CALL(pthread_getattr_np, (thread, &attributes), __FUNCTION__);
-  CHECK_PTHREAD_CALL(pthread_attr_getstack, (&attributes, &stack_base, &stack_size), __FUNCTION__);
+  CHECK_PTHREAD_CALL(pthread_attr_getstack, (&attributes, stack_base, stack_size), __FUNCTION__);
   CHECK_PTHREAD_CALL(pthread_attr_destroy, (&attributes), __FUNCTION__);
 #endif
 }
@@ -955,8 +955,8 @@
 #endif
 }
 
-void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu) {
-  utime = stime = task_cpu = 0;
+void GetTaskStats(pid_t tid, char* state, int* utime, int* stime, int* task_cpu) {
+  *utime = *stime = *task_cpu = 0;
   std::string stats;
   if (!ReadFileToString(StringPrintf("/proc/self/task/%d/stat", tid), &stats)) {
     return;
@@ -966,10 +966,10 @@
   // Extract the three fields we care about.
   std::vector<std::string> fields;
   Split(stats, ' ', fields);
-  state = fields[0][0];
-  utime = strtoull(fields[11].c_str(), NULL, 10);
-  stime = strtoull(fields[12].c_str(), NULL, 10);
-  task_cpu = strtoull(fields[36].c_str(), NULL, 10);
+  *state = fields[0][0];
+  *utime = strtoull(fields[11].c_str(), NULL, 10);
+  *stime = strtoull(fields[12].c_str(), NULL, 10);
+  *task_cpu = strtoull(fields[36].c_str(), NULL, 10);
 }
 
 std::string GetSchedulerGroupName(pid_t tid) {
diff --git a/runtime/utils.h b/runtime/utils.h
index 812a581..975f08b 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -323,10 +323,10 @@
 std::string GetThreadName(pid_t tid);
 
 // Returns details of the given thread's stack.
-void GetThreadStack(pthread_t thread, void*& stack_base, size_t& stack_size);
+void GetThreadStack(pthread_t thread, void** stack_base, size_t* stack_size);
 
 // Reads data from "/proc/self/task/${tid}/stat".
-void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu);
+void GetTaskStats(pid_t tid, char* state, int* utime, int* stime, int* task_cpu);
 
 // Returns the name of the scheduler group for the given thread the current process, or the empty string.
 std::string GetSchedulerGroupName(pid_t tid);