aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/boot/compressed/Makefile2
-rw-r--r--arch/x86/realmode/rm/Makefile2
-rw-r--r--arch/x86/tools/.gitignore3
-rw-r--r--arch/x86/tools/Makefile21
-rw-r--r--arch/x86/tools/relocs.c162
-rw-r--r--arch/x86/tools/relocs.h36
-rw-r--r--arch/x86/tools/relocs_32.c17
-rw-r--r--arch/x86/tools/relocs_64.c17
-rw-r--r--arch/x86/tools/relocs_common.c76
9 files changed, 183 insertions, 153 deletions
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 0dac17528099..5ef205c5f37b 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -44,7 +44,7 @@ $(obj)/vmlinux.bin: vmlinux FORCE
44 44
45targets += $(patsubst $(obj)/%,%,$(VMLINUX_OBJS)) vmlinux.bin.all vmlinux.relocs 45targets += $(patsubst $(obj)/%,%,$(VMLINUX_OBJS)) vmlinux.bin.all vmlinux.relocs
46 46
47CMD_RELOCS = arch/x86/tools/relocs_$(BITS) 47CMD_RELOCS = arch/x86/tools/relocs
48quiet_cmd_relocs = RELOCS $@ 48quiet_cmd_relocs = RELOCS $@
49 cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 49 cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
50$(obj)/vmlinux.relocs: vmlinux FORCE 50$(obj)/vmlinux.relocs: vmlinux FORCE
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 2b1e4294b8b9..88692871823f 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -56,7 +56,7 @@ $(obj)/realmode.bin: $(obj)/realmode.elf $(obj)/realmode.relocs
56 $(call if_changed,objcopy) 56 $(call if_changed,objcopy)
57 57
58quiet_cmd_relocs = RELOCS $@ 58quiet_cmd_relocs = RELOCS $@
59 cmd_relocs = arch/x86/tools/relocs_32 --realmode $< > $@ 59 cmd_relocs = arch/x86/tools/relocs --realmode $< > $@
60 60
61targets += realmode.relocs 61targets += realmode.relocs
62$(obj)/realmode.relocs: $(obj)/realmode.elf FORCE 62$(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
diff --git a/arch/x86/tools/.gitignore b/arch/x86/tools/.gitignore
index 2b45d5f063ba..be0ed065249b 100644
--- a/arch/x86/tools/.gitignore
+++ b/arch/x86/tools/.gitignore
@@ -1,2 +1 @@
1relocs_32* relocs
2relocs_64*
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
index a8cb70c6b8a1..e8120346903b 100644
--- a/arch/x86/tools/Makefile
+++ b/arch/x86/tools/Makefile
@@ -37,22 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
37 37
38$(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c 38$(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
39 39
40HOSTCFLAGS_relocs_32.o += -DELF_BITS=32
41HOSTCFLAGS_relocs_64.o += -DELF_BITS=64
42
43quiet_cmd_cp_reloc = GEN $@
44 cmd_cp_reloc = cp $< $@
45
46$(obj)/relocs_%.c: $(srctree)/arch/x86/tools/relocs.c
47 $(call cmd,cp_reloc)
48
49HOST_EXTRACFLAGS += -I$(srctree)/tools/include 40HOST_EXTRACFLAGS += -I$(srctree)/tools/include
50hostprogs-y += relocs_$(BITS) 41hostprogs-y += relocs
51relocs_binaries = relocs_$(BITS) 42relocs-objs := relocs_32.o relocs_64.o relocs_common.o
52ifeq ($(CONFIG_64BIT),y) 43relocs: $(obj)/relocs
53 hostprogs-y += relocs_32
54 relocs_binaries += relocs_32
55endif
56relocs: $(relocs_binaries)
57relocs_32: $(obj)/relocs_32
58relocs_64: $(obj)/relocs_64
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 1f7ff3d11a05..590be1090892 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -1,63 +1,15 @@
1#include <stdio.h> 1/* This is included from relocs_32/64.c */
2#include <stdarg.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <inttypes.h>
6#include <string.h>
7#include <errno.h>
8#include <unistd.h>
9#include <elf.h>
10#include <byteswap.h>
11#define USE_BSD
12#include <endian.h>
13#include <regex.h>
14#include <tools/le_byteshift.h>
15 2
16#define ElfW(type) _ElfW(ELF_BITS, type) 3#define ElfW(type) _ElfW(ELF_BITS, type)
17#define _ElfW(bits, type) __ElfW(bits, type) 4#define _ElfW(bits, type) __ElfW(bits, type)
18#define __ElfW(bits, type) Elf##bits##_##type 5#define __ElfW(bits, type) Elf##bits##_##type
19 6
20#ifndef ELF_BITS
21#define ELF_BITS 32
22#endif
23
24#if (ELF_BITS == 64)
25#define ELF_MACHINE EM_X86_64
26#define ELF_MACHINE_NAME "x86_64"
27#define SHT_REL_TYPE SHT_RELA
28#define Elf_Rel Elf64_Rela
29#else
30#define ELF_MACHINE EM_386
31#define ELF_MACHINE_NAME "i386"
32#define SHT_REL_TYPE SHT_REL
33#define Elf_Rel ElfW(Rel)
34#endif
35
36#if (ELF_BITS == 64)
37#define ELF_CLASS ELFCLASS64
38#define ELF_R_SYM(val) ELF64_R_SYM(val)
39#define ELF_R_TYPE(val) ELF64_R_TYPE(val)
40#define ELF_ST_TYPE(o) ELF64_ST_TYPE(o)
41#define ELF_ST_BIND(o) ELF64_ST_BIND(o)
42#define ELF_ST_VISIBILITY(o) ELF64_ST_VISIBILITY(o)
43#else
44#define ELF_CLASS ELFCLASS32
45#define ELF_R_SYM(val) ELF32_R_SYM(val)
46#define ELF_R_TYPE(val) ELF32_R_TYPE(val)
47#define ELF_ST_TYPE(o) ELF32_ST_TYPE(o)
48#define ELF_ST_BIND(o) ELF32_ST_BIND(o)
49#define ELF_ST_VISIBILITY(o) ELF32_ST_VISIBILITY(o)
50#endif
51
52#define Elf_Addr ElfW(Addr) 7#define Elf_Addr ElfW(Addr)
53#define Elf_Ehdr ElfW(Ehdr) 8#define Elf_Ehdr ElfW(Ehdr)
54#define Elf_Phdr ElfW(Phdr) 9#define Elf_Phdr ElfW(Phdr)
55#define Elf_Shdr ElfW(Shdr) 10#define Elf_Shdr ElfW(Shdr)
56#define Elf_Sym ElfW(Sym) 11#define Elf_Sym ElfW(Sym)
57 12
58static void die(char *fmt, ...);
59
60#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
61static Elf_Ehdr ehdr; 13static Elf_Ehdr ehdr;
62 14
63struct relocs { 15struct relocs {
@@ -79,14 +31,6 @@ struct section {
79}; 31};
80static struct section *secs; 32static struct section *secs;
81 33
82enum symtype {
83 S_ABS,
84 S_REL,
85 S_SEG,
86 S_LIN,
87 S_NSYMTYPES
88};
89
90static const char * const sym_regex_kernel[S_NSYMTYPES] = { 34static const char * const sym_regex_kernel[S_NSYMTYPES] = {
91/* 35/*
92 * Following symbols have been audited. There values are constant and do 36 * Following symbols have been audited. There values are constant and do
@@ -98,7 +42,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
98 "^(xen_irq_disable_direct_reloc$|" 42 "^(xen_irq_disable_direct_reloc$|"
99 "xen_save_fl_direct_reloc$|" 43 "xen_save_fl_direct_reloc$|"
100 "VDSO|" 44 "VDSO|"
101#if (ELF_BITS == 64) 45#if ELF_BITS == 64
102 "__vvar_page|" 46 "__vvar_page|"
103#endif 47#endif
104 "__crc_)", 48 "__crc_)",
@@ -124,7 +68,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
124 "__end_rodata|" 68 "__end_rodata|"
125 "__initramfs_start|" 69 "__initramfs_start|"
126 "(jiffies|jiffies_64)|" 70 "(jiffies|jiffies_64)|"
127#if (ELF_BITS == 64) 71#if ELF_BITS == 64
128 "__per_cpu_load|" 72 "__per_cpu_load|"
129 "init_per_cpu__.*|" 73 "init_per_cpu__.*|"
130 "__end_rodata_hpage_align|" 74 "__end_rodata_hpage_align|"
@@ -189,15 +133,6 @@ static void regex_init(int use_real_mode)
189 } 133 }
190} 134}
191 135
192static void die(char *fmt, ...)
193{
194 va_list ap;
195 va_start(ap, fmt);
196 vfprintf(stderr, fmt, ap);
197 va_end(ap);
198 exit(1);
199}
200
201static const char *sym_type(unsigned type) 136static const char *sym_type(unsigned type)
202{ 137{
203 static const char *type_name[] = { 138 static const char *type_name[] = {
@@ -255,7 +190,7 @@ static const char *rel_type(unsigned type)
255{ 190{
256 static const char *type_name[] = {