Revert "Implement deterministic MTE globals for dlext RELRO sharing"

Revert submission 3236258

Reason for revert: b/374452952

Reverted changes: /q/submissionid:3236258
(cherry picked from https://android-review.googlesource.com/q/commit:2e40a2284f12f0c474539323231893b7b144a67a)
Merged-In: I4e152e0cd65ed0d259c1cbea3fd2feb42291729d
Change-Id: I4e152e0cd65ed0d259c1cbea3fd2feb42291729d
Staged CLs so I don't have to wait for merges before I CP
diff --git a/linker/linker.cpp b/linker/linker.cpp
index ed3f121..517950c 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1698,19 +1698,11 @@
     }
   }
 
-  // The WebView loader uses RELRO sharing in order to promote page sharing of the large RELRO
-  // segment, as it's full of C++ vtables. Because MTE globals, by default, applies random tags to
-  // each global variable, the RELRO segment is polluted and unique for each process. In order to
-  // allow sharing, but still provide some protection, we use deterministic global tagging schemes
-  // for DSOs that are loaded through android_dlopen_ext, such as those loaded by WebView.
-  bool deterministic_memtag_globals =
-      extinfo && extinfo->flags & (ANDROID_DLEXT_WRITE_RELRO | ANDROID_DLEXT_USE_RELRO);
-
   // Step 3: pre-link all DT_NEEDED libraries in breadth first order.
   bool any_memtag_stack = false;
   for (auto&& task : load_tasks) {
     soinfo* si = task->get_soinfo();
-    if (!si->is_linked() && !si->prelink_image(deterministic_memtag_globals)) {
+    if (!si->is_linked() && !si->prelink_image()) {
       return false;
     }
     // si->memtag_stack() needs to be called after si->prelink_image() which populates
@@ -2855,7 +2847,7 @@
 // An empty list of soinfos
 static soinfo_list_t g_empty_list;
 
-bool soinfo::prelink_image(bool deterministic_memtag_globals) {
+bool soinfo::prelink_image() {
   if (flags_ & FLAG_PRELINKED) return true;
   /* Extract dynamic section */
   ElfW(Word) dynamic_flags = 0;
@@ -3352,7 +3344,7 @@
   // pages is unnecessary on non-MTE devices (where we might still run MTE-globals enabled code).
   if (should_tag_memtag_globals() &&
       remap_memtag_globals_segments(phdr, phnum, base) == 0) {
-    tag_globals(deterministic_memtag_globals);
+    tag_globals();
     protect_memtag_globals_ro_segments(phdr, phnum, base);
   }
 
@@ -3471,7 +3463,7 @@
 }
 
 // https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#global-variable-tagging
-void soinfo::tag_globals(bool deterministic_memtag_globals) {
+void soinfo::tag_globals() {
   if (is_linked()) return;
   if (flags_ & FLAG_GLOBALS_TAGGED) return;
   flags_ |= FLAG_GLOBALS_TAGGED;
@@ -3488,7 +3480,6 @@
   // Don't ever generate tag zero, to easily distinguish between tagged and
   // untagged globals in register/tag dumps.
   uint64_t last_tag_mask = 1;
-  uint64_t last_tag = 1;
   constexpr uint64_t kDistanceReservedBits = 3;
 
   while (decoder.has_bytes()) {
@@ -3501,14 +3492,9 @@
 
     addr += distance;
     void* tagged_addr;
-    if (deterministic_memtag_globals) {
-      tagged_addr = reinterpret_cast<void*>(addr | (last_tag++ << 56));
-      if (last_tag > (1 << kTagGranuleSize)) last_tag = 1;
-    } else {
-      tagged_addr = insert_random_tag(reinterpret_cast<void*>(addr), last_tag_mask);
-      uint64_t tag = (reinterpret_cast<uint64_t>(tagged_addr) >> 56) & 0x0f;
-      last_tag_mask = 1 | (1 << tag);
-    }
+    tagged_addr = insert_random_tag(reinterpret_cast<void*>(addr), last_tag_mask);
+    uint64_t tag = (reinterpret_cast<uint64_t>(tagged_addr) >> 56) & 0x0f;
+    last_tag_mask = 1 | (1 << tag);
 
     for (size_t k = 0; k < ngranules; k++) {
       auto* granule = static_cast<uint8_t*>(tagged_addr) + k * kTagGranuleSize;