From: uazo <uazo@users.noreply.github.com>
Date: Thu, 3 Feb 2022 19:48:49 +0000
Subject: Samsung Note 9 SDK27 crazylinker workaround

Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
 .../base/library_loader/LibraryLoader.java    | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
--- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
+++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
@@ -517,8 +517,29 @@ public class LibraryLoader {
     // Note: This cannot be done in the build configuration, as otherwise chrome_public_apk cannot
     // both be used as the basis to ship on L, and the default APK used by developers on 10+.
     private boolean forceSystemLinker() {
-        return mUseChromiumLinker && !mUseModernLinker
+        boolean result = false;
+        String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.US);
+        if (manufacturer.equals("samsung")
+                && Build.MODEL != null
+                && Build.MODEL.equals("SM-N960F")) {
+            // Samsung Galaxy Note 9 (on Android 8.1) - Model SM-N960F
+            // crashes on startup (base::MessagePumpForUI::MessagePumpForUI) due to
+            // some odd RELRO incompatibility in the device ROM.
+            // This workaround disables relocation sharing but allows device to start up.
+            // See also:
+            // * https://bugs.chromium.org/p/chromium/issues/detail?id=980304
+            // * https://groups.google.com/a/chromium.org/g/chromium-dev/c/iAb7QUiNPLw
+            result = true;
+        } else {
+            result = mUseChromiumLinker && !mUseModernLinker
                 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+        }
+        if (result) {
+            Log.d(TAG,
+                    "Forcing system linker, relocations will not be shared. "
+                            + "This negatively impacts memory usage.");
+        }
+        return result;
     }
 
     // Whether a Linker subclass is used for loading. Even if returns |true|, the Linker can
--
2.25.1
