Use ELF notes to set the desired memory tagging level.

Use a note in executables to specify
(none|sync|async) heap tagging level. To be extended with (heap x stack x
globals) in the future. A missing note disables all tagging.

Bug: b/135772972
Test: bionic-unit-tests (in a future change)

Change-Id: Iab145a922c7abe24cdce17323f9e0c1063cc1321
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index aad8f6f..59e8036 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -66,6 +66,8 @@
 
 static void set_bss_vma_name(soinfo* si);
 
+void __libc_init_mte(const void* phdr_start, size_t phdr_count, uintptr_t load_bias);
+
 // These should be preserved static to avoid emitting
 // RELATIVE relocations for the part of the code running
 // before linker links itself.
@@ -403,6 +405,8 @@
                      strerror(errno));
     }
   }
+
+  __libc_init_mte(somain->phdr, somain->phnum, somain->load_bias);
 #endif
 
   // Register the main executable and the linker upfront to have