Clean up linker architecture macros.
We don't need our own architecture macros; the standard ones will do.
This patch also fixes some __x86_64__ tests to be USE_RELA tests instead,
because they're not actually x86_64-specific.
I've cleaned up architecture-specific code slightly so where possible
all the code corresponding to a particular architecture is together.
This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be
an error rather than falling through into DT_DEBUG! There was another #ifdef
bug where we'd only report unexpected DT_ entries on MIPS.
Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
diff --git a/linker/linker.h b/linker/linker.h
index c5202c9..4ba354d 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -97,6 +97,11 @@
typedef void (*linker_function_t)();
+// Android uses REL for 32-bit but only uses RELA for 64-bit.
+#if defined(__LP64__)
+#define USE_RELA 1
+#endif
+
struct soinfo {
public:
char name[SOINFO_NAME_LEN];
@@ -128,15 +133,19 @@
unsigned* bucket;
unsigned* chain;
-#if defined(ANDROID_X86_64_LINKER)
- Elf_Rela *plt_rela;
+#if !defined(__LP64__)
+ // This is only used by 32-bit MIPS, but needs to be here for
+ // all 32-bit architectures to preserve binary compatibility.
+ unsigned* plt_got;
+#endif
+
+#if defined(USE_RELA)
+ Elf_Rela* plt_rela;
size_t plt_rela_count;
- Elf_Rela *rela;
+ Elf_Rela* rela;
size_t rela_count;
#else
- unsigned* plt_got;
-
Elf_Rel* plt_rel;
size_t plt_rel_count;
@@ -155,11 +164,11 @@
linker_function_t init_func;
linker_function_t fini_func;
-#if defined(ANDROID_ARM_LINKER)
+#if defined(__arm__)
// ARM EABI section used for stack unwinding.
unsigned* ARM_exidx;
size_t ARM_exidx_count;
-#elif defined(ANDROID_MIPS_LINKER)
+#elif defined(__mips__)
unsigned mips_symtabno;
unsigned mips_local_gotno;
unsigned mips_gotsym;