Switch <elf.h> over to linux uapi under the covers.

Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
diff --git a/linker/linker_phdr.h b/linker/linker_phdr.h
index db15ac9..6b72caf 100644
--- a/linker/linker_phdr.h
+++ b/linker/linker_phdr.h
@@ -45,10 +45,10 @@
   bool Load();
 
   size_t phdr_count() { return phdr_num_; }
-  Elf_Addr load_start() { return reinterpret_cast<Elf_Addr>(load_start_); }
+  ElfW(Addr) load_start() { return reinterpret_cast<ElfW(Addr)>(load_start_); }
   size_t load_size() { return load_size_; }
-  Elf_Addr load_bias() { return load_bias_; }
-  const Elf_Phdr* loaded_phdr() { return loaded_phdr_; }
+  ElfW(Addr) load_bias() { return load_bias_; }
+  const ElfW(Phdr)* loaded_phdr() { return loaded_phdr_; }
 
  private:
   bool ReadElfHeader();
@@ -57,46 +57,46 @@
   bool ReserveAddressSpace();
   bool LoadSegments();
   bool FindPhdr();
-  bool CheckPhdr(Elf_Addr);
+  bool CheckPhdr(ElfW(Addr));
 
   const char* name_;
   int fd_;
 
-  Elf_Ehdr header_;
+  ElfW(Ehdr) header_;
   size_t phdr_num_;
 
   void* phdr_mmap_;
-  Elf_Phdr* phdr_table_;
-  Elf_Addr phdr_size_;
+  ElfW(Phdr)* phdr_table_;
+  ElfW(Addr) phdr_size_;
 
   // First page of reserved address space.
   void* load_start_;
   // Size in bytes of reserved address space.
   size_t load_size_;
   // Load bias.
-  Elf_Addr load_bias_;
+  ElfW(Addr) load_bias_;
 
   // Loaded phdr.
-  const Elf_Phdr* loaded_phdr_;
+  const ElfW(Phdr)* loaded_phdr_;
 };
 
-size_t phdr_table_get_load_size(const Elf_Phdr* phdr_table, size_t phdr_count,
-                                Elf_Addr* min_vaddr = NULL, Elf_Addr* max_vaddr = NULL);
+size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+                                ElfW(Addr)* min_vaddr = NULL, ElfW(Addr)* max_vaddr = NULL);
 
-int phdr_table_protect_segments(const Elf_Phdr* phdr_table, size_t phdr_count, Elf_Addr load_bias);
+int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias);
 
-int phdr_table_unprotect_segments(const Elf_Phdr* phdr_table, size_t phdr_count, Elf_Addr load_bias);
+int phdr_table_unprotect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias);
 
-int phdr_table_protect_gnu_relro(const Elf_Phdr* phdr_table, size_t phdr_count, Elf_Addr load_bias);
+int phdr_table_protect_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias);
 
 
 #if defined(__arm__)
-int phdr_table_get_arm_exidx(const Elf_Phdr* phdr_table, size_t phdr_count, Elf_Addr load_bias,
-                             Elf_Addr** arm_exidx, unsigned* arm_exidix_count);
+int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias,
+                             ElfW(Addr)** arm_exidx, unsigned* arm_exidix_count);
 #endif
 
-void phdr_table_get_dynamic_section(const Elf_Phdr* phdr_table, size_t phdr_count,
-                                    Elf_Addr load_bias,
-                                    Elf_Dyn** dynamic, size_t* dynamic_count, Elf_Word* dynamic_flags);
+void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+                                    ElfW(Addr) load_bias,
+                                    ElfW(Dyn)** dynamic, size_t* dynamic_count, ElfW(Word)* dynamic_flags);
 
 #endif /* LINKER_PHDR_H */