Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / public / android / java / src / org / chromium / content / app / ChildProcessService.java
index 16c5702..e18924d 100644 (file)
@@ -17,6 +17,7 @@ import android.util.Log;
 import android.view.Surface;
 
 import org.chromium.base.CalledByNative;
+import org.chromium.base.CommandLine;
 import org.chromium.base.JNINamespace;
 import org.chromium.base.library_loader.LibraryLoader;
 import org.chromium.base.library_loader.Linker;
@@ -129,7 +130,7 @@ public class ChildProcessService extends Service {
             public void run()  {
                 try {
                     boolean useLinker = Linker.isUsed();
-
+                    boolean requestedSharedRelro = false;
                     if (useLinker) {
                         synchronized (mMainThread) {
                             while (!mIsBound) {
@@ -137,26 +138,46 @@ public class ChildProcessService extends Service {
                             }
                         }
                         if (mLinkerParams != null) {
-                            if (mLinkerParams.mWaitForSharedRelro)
+                            if (mLinkerParams.mWaitForSharedRelro) {
+                                requestedSharedRelro = true;
                                 Linker.initServiceProcess(mLinkerParams.mBaseLoadAddress);
-                            else
+                            } else {
                                 Linker.disableSharedRelros();
-
+                            }
                             Linker.setTestRunnerClassName(mLinkerParams.mTestRunnerClassName);
                         }
                     }
+                    boolean isLoaded = false;
+                    synchronized (mMainThread) {
+                        while (mCommandLineParams == null) {
+                            mMainThread.wait();
+                        }
+                    }
+                    CommandLine.init(mCommandLineParams);
                     try {
                         LibraryLoader.loadNow(getApplicationContext(), false);
+                        isLoaded = true;
                     } catch (ProcessInitException e) {
-                        Log.e(TAG, "Failed to load native library, exiting child process", e);
-                        System.exit(-1);
+                        if (requestedSharedRelro) {
+                            Log.w(TAG, "Failed to load native library with shared RELRO, " +
+                                  "retrying without");
+                        } else {
+                            Log.e(TAG, "Failed to load native library", e);
+                        }
                     }
-                    synchronized (mMainThread) {
-                        while (mCommandLineParams == null) {
-                            mMainThread.wait();
+                    if (!isLoaded && requestedSharedRelro) {
+                        Linker.disableSharedRelros();
+                        try {
+                            LibraryLoader.loadNow(getApplicationContext(), false);
+                            isLoaded = true;
+                        } catch (ProcessInitException e) {
+                            Log.e(TAG, "Failed to load native library on retry", e);
                         }
                     }
-                    LibraryLoader.initialize(mCommandLineParams);
+                    if (!isLoaded) {
+                        System.exit(-1);
+                    }
+                    LibraryLoader.initialize();
                     synchronized (mMainThread) {
                         mLibraryInitialized = true;
                         mMainThread.notifyAll();