Make all the ELF relocation constants available.
BSD thinks you should only get the relocation constants for your target
architecture, but it's often useful to have them all available at once.
Rearrange the headers to enable that.
Also update the (modified) NetBSD files to CVS HEAD.
Also remove the unused BSDism R_TYPE.
Bug: N/A
Test: builds
Change-Id: Iad5ef29192a732696e2b36af35144a9ca116aa46
diff --git a/libc/arch-x86_64/include/machine/elf_machdep.h b/libc/arch-x86_64/include/machine/elf_machdep.h
deleted file mode 100644
index dedbd41..0000000
--- a/libc/arch-x86_64/include/machine/elf_machdep.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $NetBSD: elf_machdep.h,v 1.4 2010/03/18 08:28:33 cegger Exp $ */
-
-#ifndef _X86_64_ELF_MACHDEP_H_
-#define _X86_64_ELF_MACHDEP_H_
-
-/* x86-64 relocations */
-
-#define R_X86_64_NONE 0
-#define R_X86_64_64 1
-#define R_X86_64_PC32 2
-#define R_X86_64_GOT32 3
-#define R_X86_64_PLT32 4
-#define R_X86_64_COPY 5
-#define R_X86_64_GLOB_DAT 6
-#define R_X86_64_JUMP_SLOT 7
-#define R_X86_64_RELATIVE 8
-#define R_X86_64_GOTPCREL 9
-#define R_X86_64_32 10
-#define R_X86_64_32S 11
-#define R_X86_64_16 12
-#define R_X86_64_PC16 13
-#define R_X86_64_8 14
-#define R_X86_64_PC8 15
-
-/* TLS relocations */
-#define R_X86_64_DTPMOD64 16
-#define R_X86_64_DTPOFF64 17
-#define R_X86_64_TPOFF64 18
-#define R_X86_64_TLSGD 19
-#define R_X86_64_TLSLD 20
-#define R_X86_64_DTPOFF32 21
-#define R_X86_64_GOTTPOFF 22
-#define R_X86_64_TPOFF32 23
-
-#define R_X86_64_IRELATIVE 37
-
-#define R_TYPE(name) __CONCAT(R_X86_64_,name)
-
-#endif
diff --git a/libc/arch-arm/include/machine/elf_machdep.h b/libc/include/bits/elf_arm.h
similarity index 80%
rename from libc/arch-arm/include/machine/elf_machdep.h
rename to libc/include/bits/elf_arm.h
index f7ee43f..320feaf 100644
--- a/libc/arch-arm/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_arm.h
@@ -1,8 +1,11 @@
-/* $NetBSD: elf_machdep.h,v 1.10 2012/08/05 04:12:46 matt Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.17 2014/02/25 19:20:09 matt Exp $ */
#ifndef _ARM_ELF_MACHDEP_H_
#define _ARM_ELF_MACHDEP_H_
+/* Android-added. */
+#define R_ARM_IRELATIVE 160
+
/* Processor specific flags for the ELF header e_flags field. */
#define EF_ARM_RELEXEC 0x00000001
#define EF_ARM_HASENTRY 0x00000002
@@ -17,6 +20,7 @@
#define EF_ARM_NEW_ABI 0x00000080
#define EF_ARM_OLD_ABI 0x00000100
#define EF_ARM_SOFT_FLOAT 0x00000200
+#define EF_ARM_BE8 0x00800000
#define EF_ARM_EABIMASK 0xff000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000
@@ -58,13 +62,29 @@
#define R_ARM_GOTPC 25
#define R_ARM_GOT32 26
#define R_ARM_PLT32 27
-
+#define R_ARM_CALL 28
+#define R_ARM_JUMP24 29
+#define R_ARM_THM_JUMP24 30
+#define R_ARM_BASE_ABS 31
#define R_ARM_ALU_PCREL_7_0 32
#define R_ARM_ALU_PCREL_15_8 33
#define R_ARM_ALU_PCREL_23_15 34
#define R_ARM_ALU_SBREL_11_0 35
#define R_ARM_ALU_SBREL_19_12 36
-#define R_ARM_ALU_SBREL_27_20 37
+#define R_ARM_ALU_SBREL_27_20 37 // depcreated
+#define R_ARM_TARGET1 38
+#define R_ARM_SBREL31 39 // deprecated
+#define R_ARM_V4BX 40
+#define R_ARM_TARGET2 41
+#define R_ARM_PREL31 42
+#define R_ARM_MOVW_ABS_NC 43
+#define R_ARM_MOVT_ABS 44
+#define R_ARM_MOVW_PREL_NC 45
+#define R_ARM_MOVT_PREL 46
+#define R_ARM_THM_MOVW_ABS_NC 47
+#define R_ARM_THM_MOVT_ABS 48
+#define R_ARM_THM_MOVW_PREL_NC 49
+#define R_ARM_THM_MOVT_PREL 50
/* 96-111 are reserved to G++. */
#define R_ARM_GNU_VTENTRY 100
@@ -84,8 +104,6 @@
/* 112-127 are reserved for private experiments. */
-#define R_ARM_IRELATIVE 160
-
#define R_ARM_RXPC25 249
#define R_ARM_RSBREL32 250
#define R_ARM_THM_RPC22 251
@@ -94,13 +112,14 @@
#define R_ARM_RPC24 254
#define R_ARM_RBASE 255
-#define R_TYPE(name) __CONCAT(R_ARM_,name)
-
/* Processor specific program header flags */
#define PF_ARM_SB 0x10000000
#define PF_ARM_PI 0x20000000
#define PF_ARM_ENTRY 0x80000000
+/* Processor specific program header types */
+#define PT_ARM_EXIDX (PT_LOPROC + 1)
+
/* Processor specific section header flags */
#define SHF_ENTRYSECT 0x10000000
#define SHF_COMDEF 0x80000000
diff --git a/libc/arch-arm64/include/machine/elf_machdep.h b/libc/include/bits/elf_arm64.h
similarity index 97%
rename from libc/arch-arm64/include/machine/elf_machdep.h
rename to libc/include/bits/elf_arm64.h
index 9f10b99..acd9c70 100644
--- a/libc/arch-arm64/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_arm64.h
@@ -87,6 +87,4 @@
#define R_AARCH64_TLS_DTPREL32 1031
#define R_AARCH64_IRELATIVE 1032
-#define R_TYPE(name) __CONCAT(R_AARCH64_,name)
-
#endif /* _AARCH64_ELF_MACHDEP_H_ */
diff --git a/libc/arch-mips/include/machine/elf_machdep.h b/libc/include/bits/elf_mips.h
similarity index 98%
rename from libc/arch-mips/include/machine/elf_machdep.h
rename to libc/include/bits/elf_mips.h
index 59e0974..e29c481 100644
--- a/libc/arch-mips/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_mips.h
@@ -71,8 +71,6 @@
#define R_MIPS_max 51
-#define R_TYPE(name) __CONCAT(R_MIPS_,name)
-
#define R_MIPS16_min 100
#define R_MIPS16_26 100
#define R_MIPS16_GPREL 101
diff --git a/libc/arch-x86/include/machine/elf_machdep.h b/libc/include/bits/elf_x86.h
similarity index 84%
rename from libc/arch-x86/include/machine/elf_machdep.h
rename to libc/include/bits/elf_x86.h
index 5324ebc..dfbaba0 100644
--- a/libc/arch-x86/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_x86.h
@@ -1,4 +1,4 @@
-/* $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.12 2016/02/02 20:16:59 christos Exp $ */
#ifndef _X86_ELF_MACHDEP_H_
#define _X86_ELF_MACHDEP_H_
@@ -15,6 +15,7 @@
#define R_386_RELATIVE 8
#define R_386_GOTOFF 9
#define R_386_GOTPC 10
+#define R_386_32PLT 11
/* TLS relocations */
#define R_386_TLS_TPOFF 14
@@ -45,11 +46,15 @@
#define R_386_TLS_DTPMOD32 35
#define R_386_TLS_DTPOFF32 36
#define R_386_TLS_TPOFF32 37
+
+#define R_386_SIZE32 38
+
+/* More TLS relocations */
#define R_386_TLS_GOTDESC 39
#define R_386_TLS_DESC_CALL 40
#define R_386_TLS_DESC 41
-#define R_386_IRELATIVE 42
-#define R_TYPE(name) __CONCAT(R_386_,name)
+#define R_386_IRELATIVE 42
+#define R_386_GOT32X 43
#endif
diff --git a/libc/include/bits/elf_x86_64.h b/libc/include/bits/elf_x86_64.h
new file mode 100644
index 0000000..30062af
--- /dev/null
+++ b/libc/include/bits/elf_x86_64.h
@@ -0,0 +1,55 @@
+/* $NetBSD: elf_machdep.h,v 1.5 2016/02/02 20:13:59 christos Exp $ */
+
+#ifndef _X86_64_ELF_MACHDEP_H_
+#define _X86_64_ELF_MACHDEP_H_
+
+/* x86-64 relocations */
+
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JUMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+
+/* TLS relocations */
+#define R_X86_64_DTPMOD64 16
+#define R_X86_64_DTPOFF64 17
+#define R_X86_64_TPOFF64 18
+#define R_X86_64_TLSGD 19
+#define R_X86_64_TLSLD 20
+#define R_X86_64_DTPOFF32 21
+#define R_X86_64_GOTTPOFF 22
+#define R_X86_64_TPOFF32 23
+
+#define R_X86_64_PC64 24
+#define R_X86_64_GOTOFF64 25
+#define R_X86_64_GOTPC32 26
+#define R_X86_64_GOT64 27
+#define R_X86_64_GOTPCREL64 28
+#define R_X86_64_GOTPC64 29
+#define R_X86_64_GOTPLT64 30
+#define R_X86_64_PLTOFF64 31
+#define R_X86_64_SIZE32 32
+#define R_X86_64_SIZE64 33
+#define R_X86_64_GOTPC32_TLSDESC 34
+#define R_X86_64_TLSDESC_CALL 35
+#define R_X86_64_TLSDESC 36
+#define R_X86_64_IRELATIVE 37
+#define R_X86_64_RELATIVE64 38
+#define R_X86_64_PC32_BND 39
+#define R_X86_64_PLT32_BND 40
+#define R_X86_64_GOTPCRELX 41
+#define R_X86_64_REX_GOTPCRELX 42
+
+#endif
diff --git a/libc/include/elf.h b/libc/include/elf.h
index 28f3c3b..c36bc8d 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -32,9 +32,13 @@
#include <sys/cdefs.h>
#include <bits/auxvec.h>
+#include <bits/elf_arm.h>
+#include <bits/elf_arm64.h>
+#include <bits/elf_mips.h>
+#include <bits/elf_x86.h>
+#include <bits/elf_x86_64.h>
#include <linux/elf.h>
#include <linux/elf-em.h>
-#include <machine/elf_machdep.h>
#define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff))
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff))
@@ -178,7 +182,6 @@
#define ELFOSABI_SYSV 0 /* Synonym for ELFOSABI_NONE used by valgrind. */
-#define PT_ARM_EXIDX (PT_LOPROC + 1)
#define PT_GNU_RELRO 0x6474e552
#define STB_LOOS 10