summaryrefslogtreecommitdiffstats
path: root/arch/mips/boot/tools/relocs_32.c
diff options
context:
space:
mode:
authorMatt Redfearn2016-03-31 11:05:32 +0200
committerRalf Baechle2016-05-13 14:02:01 +0200
commit766c580356ecca88b32c47b8128bec7d6d014533 (patch)
treec28f4c6d7d4b1fcb6d77cc7d7222cc1bb34ef594 /arch/mips/boot/tools/relocs_32.c
parentsecomp: Constify mode1 syscall whitelist (diff)
downloadkernel-qcow2-linux-766c580356ecca88b32c47b8128bec7d6d014533.tar.gz
kernel-qcow2-linux-766c580356ecca88b32c47b8128bec7d6d014533.tar.xz
kernel-qcow2-linux-766c580356ecca88b32c47b8128bec7d6d014533.zip
MIPS: tools: Add relocs tool
This tool is based on the x86/boot/tools/relocs tool. It parses the relocations present in the vmlinux elf file, building a table of relocations that will be necessary to run the kernel from an address other than its link address. This table is inserted into the vmlinux elf, in the .data.relocs section. The table is subsequently used by the code in arch/mips/kernel/relocate.c (added later) to relocate the kernel. The tool, by default, also marks all relocation sections as 0 length. This is due to objcopy currently being unable to handle copying the relocations between 64 and 32 bit elf files as is done when building a 64 bit kernel. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Cc: linux-mips@linux-mips.org Cc: kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/12981/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/boot/tools/relocs_32.c')
-rw-r--r--arch/mips/boot/tools/relocs_32.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/mips/boot/tools/relocs_32.c b/arch/mips/boot/tools/relocs_32.c
new file mode 100644
index 000000000000..915bdc07f5ed
--- /dev/null
+++ b/arch/mips/boot/tools/relocs_32.c
@@ -0,0 +1,17 @@
+#include "relocs.h"
+
+#define ELF_BITS 32
+
+#define ELF_MACHINE EM_MIPS
+#define ELF_MACHINE_NAME "MIPS"
+#define SHT_REL_TYPE SHT_REL
+#define Elf_Rel ElfW(Rel)
+
+#define ELF_CLASS ELFCLASS32
+#define ELF_R_SYM(val) ELF32_R_SYM(val)
+#define ELF_R_TYPE(val) ELF32_R_TYPE(val)
+#define ELF_ST_TYPE(o) ELF32_ST_TYPE(o)
+#define ELF_ST_BIND(o) ELF32_ST_BIND(o)
+#define ELF_ST_VISIBILITY(o) ELF32_ST_VISIBILITY(o)
+
+#include "relocs.c"