Implement deterministic MTE globals for dlext RELRO sharing

This patch makes MTE globals deterministic for dlext loading that uses
either ANDROID_DLEXT_WRITE_RELRO or ANDROID_DLEXT_USE_RELRO. Without
this patch, every load of a dynamic library ends up with completely
random tags. This of course, kills the page sharing 15/16-th of the
time.

So, instead, for this specific RELRO loading, we use deterministic
global tags. This provides a small amount of protection without
killing the sharing and eating up more ram.

As a nice side effect, this fixes up one of the dlext tests that ensures
that the RELRO pages do get shared.

Bug: 315182011
Test: On both an MTE-enabled and non-MTE-enabled device:
Test: atest libprocinfo_test bionic-unit-tests bionic-unit-tests-static
CtsGwpAsanTestCases gwp_asan_unittest debuggerd_test

Change-Id: Ifbb55372346734d0a68e20c34cb0ae5be895021b
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
index 6b81f5f..64f8aea 100644
--- a/linker/linker_soinfo.h
+++ b/linker/linker_soinfo.h
@@ -254,12 +254,12 @@
   void call_constructors();
   void call_destructors();
   void call_pre_init_constructors();
-  bool prelink_image();
+  bool prelink_image(bool deterministic_memtag_globals = false);
   bool link_image(const SymbolLookupList& lookup_list, soinfo* local_group_root,
                   const android_dlextinfo* extinfo, size_t* relro_fd_offset);
   bool protect_relro();
 
-  void tag_globals();
+  void tag_globals(bool deterministic_memtag_globals);
   ElfW(Addr) apply_memtag_if_mte_globals(ElfW(Addr) sym_addr) const;
 
   void add_child(soinfo* child);