Skip linkloader, use shared object files

Bug: 18322681

- In rsCpuScript, if property rs.skip.linkloader is set, look for a .so
  file in the cache directory and load it.  If it is not available, use
  bcc to generate relocatable object file and link it to a .so using
  ld.mc.  Use the embedded symbols in .rs.info and follow steps similar
  to the compatibility library to invoke script functions or access
  script variables.
- Add rs* symbols like rsGetAllocation to libRSCpuRef (ala
  libRSSupport).  Do necessary changes to argument types to get mangled
  names correct.
- Make 64-bit version of rsSetObject take two pointers instead of a
  pointer and a large object.  rsIsObject takes a pointer instead of a
  large object.  Otherwise, we get failures in x86_64 due to calling
  convention mismatch.  To match the function names in the shared object
  path, define these functions as 'extern "C"' with their mangled names.
- Add stubbed Math functions from rsCpuRuntimeMath and
  rsCpuRuntimeMathFuncs into libRSCpuRef.so.
- Coalesce separate #ifdef paths in libRSCpuRef.  Function parameters
  for runtime callbacks and bcc plugin are needed in the
  non-compatibilty path, but take default NULL arguments.  This patch
  introduces these parameters into the compatibility path as well, and
  passes default NULL arguments.

Change-Id: I8a853350e39d30b4d852c30e4b5da5a75a2f2820
diff --git a/cpu_ref/rsCpuScript.h b/cpu_ref/rsCpuScript.h
index a8a808b..324ee14 100644
--- a/cpu_ref/rsCpuScript.h
+++ b/cpu_ref/rsCpuScript.h
@@ -50,10 +50,11 @@
         const RsExpandKernelParams *,
         uint32_t x1, uint32_t x2,
         uint32_t outstep);
-#ifdef RS_COMPATIBILITY_LIB
+
     typedef void (* InvokeFunc_t)(void);
     typedef void (* ForEachFunc_t)(void);
     typedef int (* RootFunc_t)(void);
+#ifdef RS_COMPATIBILITY_LIB
     typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
 #endif
 
@@ -107,23 +108,34 @@
     static void * lookupRuntimeStub(void* pContext, char const* name);
 
     virtual Allocation * getAllocationForPointer(const void *ptr) const;
+    bool storeRSInfoFromSO();
 
 #ifndef RS_COMPATIBILITY_LIB
+    bool storeRSInfoFromObj(bcinfo::MetadataExtractor &bitcodeMetadata);
     virtual  void * getRSExecutable() { return mExecutable; }
 #endif
 
 protected:
     RsdCpuReferenceImpl *mCtx;
     const Script *mScript;
+    void *mScriptSO;
 
 #ifndef RS_COMPATIBILITY_LIB
     // Returns the path to the core library we'll use.
     const char* findCoreLib(const bcinfo::MetadataExtractor& bitCodeMetaData, const char* bitcode,
                             size_t bitcodeSize);
-    int (*mRoot)();
-    int (*mRootExpand)();
-    void (*mInit)();
-    void (*mFreeChildren)();
+    RootFunc_t mRoot;
+    RootFunc_t mRootExpand;
+    InvokeFunc_t mInit;
+    InvokeFunc_t mFreeChildren;
+
+    InvokeFunc_t *mInvokeFunctions;
+    ForEachFunc_t *mForEachFunctions;
+    void **mFieldAddress;
+    bool *mFieldIsObject;
+    uint32_t *mForEachSignatures;
+    size_t mExportedVariableCount;
+    size_t mExportedFunctionCount;
 
     std::vector<std::pair<const char *, uint32_t> > mExportedForEachFuncList;
 
@@ -133,7 +145,6 @@
     bcc::SymbolResolverProxy mResolver;
     bcc::RSExecutable *mExecutable;
 #else
-    void *mScriptSO;
     RootFunc_t mRoot;
     RootFunc_t mRootExpand;
     InvokeFunc_t mInit;