Use insert_link_map_into_debug_map for executable

Use insert_link_map_into_debug_map to insert the main
executable's link_map to r_debug

Bug: http://b/27533895
Change-Id: I0eacb3f030ea3eb16ed50ad2011d604beece2d03
(cherry picked from commit f3064e4bc7f4dee351bc2eb9272db3e9792dc683)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 0df9feb..4b8e1b1 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -281,21 +281,21 @@
 static r_debug _r_debug =
     {1, nullptr, reinterpret_cast<uintptr_t>(&rtld_db_dlactivity), r_debug::RT_CONSISTENT, 0};
 
-static link_map* r_debug_tail = 0;
+static link_map* r_debug_tail = nullptr;
 
 static void insert_link_map_into_debug_map(link_map* map) {
   // Stick the new library at the end of the list.
   // gdb tends to care more about libc than it does
   // about leaf libraries, and ordering it this way
   // reduces the back-and-forth over the wire.
-  if (r_debug_tail) {
+  if (r_debug_tail != nullptr) {
     r_debug_tail->l_next = map;
     map->l_prev = r_debug_tail;
-    map->l_next = 0;
+    map->l_next = nullptr;
   } else {
     _r_debug.r_map = map;
-    map->l_prev = 0;
-    map->l_next = 0;
+    map->l_prev = nullptr;
+    map->l_next = nullptr;
   }
   r_debug_tail = map;
 }
@@ -4120,11 +4120,7 @@
 
   map->l_addr = 0;
   map->l_name = args.argv[0];
-  map->l_prev = nullptr;
-  map->l_next = nullptr;
-
-  _r_debug.r_map = map;
-  r_debug_tail = map;
+  insert_link_map_into_debug_map(map);
 
   init_linker_info_for_gdb(linker_base);