Merge "Mandate optimized __memset_chk for arm and arm64."
diff --git a/libdl/libdl.arm.map b/libdl/libdl.arm.map
index b9e494a..aa6907a 100644
--- a/libdl/libdl.arm.map
+++ b/libdl/libdl.arm.map
@@ -21,7 +21,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.arm64.map b/libdl/libdl.arm64.map
index a8c98da..c767fb1 100644
--- a/libdl/libdl.arm64.map
+++ b/libdl/libdl.arm64.map
@@ -20,7 +20,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.map.txt b/libdl/libdl.map.txt
index 55a03cb..67ff64e 100644
--- a/libdl/libdl.map.txt
+++ b/libdl/libdl.map.txt
@@ -35,7 +35,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.mips.map b/libdl/libdl.mips.map
index a8c98da..c767fb1 100644
--- a/libdl/libdl.mips.map
+++ b/libdl/libdl.mips.map
@@ -20,7 +20,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.mips64.map b/libdl/libdl.mips64.map
index a8c98da..c767fb1 100644
--- a/libdl/libdl.mips64.map
+++ b/libdl/libdl.mips64.map
@@ -20,7 +20,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.x86.map b/libdl/libdl.x86.map
index a8c98da..c767fb1 100644
--- a/libdl/libdl.x86.map
+++ b/libdl/libdl.x86.map
@@ -20,7 +20,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/libdl/libdl.x86_64.map b/libdl/libdl.x86_64.map
index a8c98da..c767fb1 100644
--- a/libdl/libdl.x86_64.map
+++ b/libdl/libdl.x86_64.map
@@ -20,7 +20,7 @@
     dlvsym;
 } LIBC;
 
-LIBC_PRIVATE {
+LIBC_PLATFORM {
   global:
     android_get_application_target_sdk_version;
     android_set_application_target_sdk_version;
diff --git a/linker/linker.cpp b/linker/linker.cpp
index a43630b..c07b21d 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -210,8 +210,8 @@
 }
 
 static void notify_gdb_of_load(soinfo* info) {
-  if (info->is_main_executable()) {
-    // GDB already knows about the main executable
+  if (info->is_linker() || info->is_main_executable()) {
+    // gdb already knows about the linker and the main executable.
     return;
   }
 
@@ -222,15 +222,13 @@
   map->l_name = const_cast<char*>(info->get_realpath());
   map->l_ld = info->dynamic;
 
+  CHECK(map->l_name != nullptr);
+  CHECK(map->l_name[0] != '\0');
+
   notify_gdb_of_load(map);
 }
 
 static void notify_gdb_of_unload(soinfo* info) {
-  if (info->is_main_executable()) {
-    // GDB already knows about the main executable
-    return;
-  }
-
   notify_gdb_of_unload(&(info->link_map_head));
 }
 
@@ -3184,6 +3182,10 @@
   return (flags_ & FLAG_EXE) != 0;
 }
 
+bool soinfo::is_linker() const {
+  return (flags_ & FLAG_LINKER) != 0;
+}
+
 void soinfo::set_linked() {
   flags_ |= FLAG_LINKED;
 }
@@ -3947,10 +3949,12 @@
   si->set_main_executable();
   link_map* map = &(si->link_map_head);
 
+  // Register the main executable and the linker upfront to have
+  // gdb aware of them before loading the rest of the dependency
+  // tree.
   map->l_addr = 0;
   map->l_name = args.argv[0];
   insert_link_map_into_debug_map(map);
-
   init_linker_info_for_gdb(linker_base);
 
   // Extract information passed from the kernel.
diff --git a/linker/linker.h b/linker/linker.h
index c793b6e..d364021 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -312,6 +312,7 @@
   }
 
   bool is_linked() const;
+  bool is_linker() const;
   bool is_main_executable() const;
 
   void set_linked();