Fix <link.h>.

Also move some of the stuff that should be in <link.h> out of the
private "linker.h", to make it clearer that these are public API
known to gdb that we can't change.

Bug: 12554197
Change-Id: I830e1260d3d8b833ed99bc1518f1c6b6102be8af
diff --git a/libc/include/link.h b/libc/include/link.h
index 341fbf1..cb8e139 100644
--- a/libc/include/link.h
+++ b/libc/include/link.h
@@ -33,7 +33,11 @@
 
 __BEGIN_DECLS
 
-#define ElfW(type) Elf_##type
+#if __LP64__
+#define ElfW(type) Elf64_ ## type
+#else
+#define ElfW(type) Elf32_ ## type
+#endif
 
 struct dl_phdr_info {
   ElfW(Addr) dlpi_addr;
@@ -42,13 +46,35 @@
   ElfW(Half) dlpi_phnum;
 };
 
-int dl_iterate_phdr(int (*cb)(struct dl_phdr_info*, size_t, void*), void*);
+int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
 
 #ifdef __arm__
 typedef long unsigned int* _Unwind_Ptr;
-_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount);
+_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr, int*);
 #endif
 
+/* Used by the dynamic linker to communicate with the debugger. */
+struct link_map {
+  ElfW(Addr) l_addr;
+  char* l_name;
+  ElfW(Dyn)* l_ld;
+  struct link_map* l_next;
+  struct link_map* l_prev;
+};
+
+/* Used by the dynamic linker to communicate with the debugger. */
+struct r_debug {
+  int32_t r_version;
+  struct link_map* r_map;
+  ElfW(Addr) r_brk;
+  enum {
+    RT_CONSISTENT,
+    RT_ADD,
+    RT_DELETE
+  } r_state;
+  ElfW(Addr) r_ldbase;
+};
+
 __END_DECLS
 
 #endif /* _LINK_H_ */