Skip to content

Commit 6520fe5

Browse files
author
H. Peter Anvin
committed
x86, realmode: 16-bit real-mode code support for relocs tool
A new option is added to the relocs tool called '--realmode'. This option causes the generation of 16-bit segment relocations and 32-bit linear relocations for the real-mode code. When the real-mode code is moved to the low-memory during kernel initialization, these relocation entries can be used to relocate the code properly. In the assembly code 16-bit segment relocations must be relative to the 'real_mode_seg' absolute symbol. Linear relocations must be relative to a symbol prefixed with 'pa_'. 16-bit segment relocation is used to load cs:ip in 16-bit code. Linear relocations are used in the 32-bit code for relocatable data references. They are declared in the linker script of the real-mode code. The relocs tool is moved to arch/x86/tools/relocs.c, and added new target archscripts that can be used to build scripts needed building an architecture. be compiled before building the arch/x86 tree. [ hpa: accelerating this because it detects invalid absolute relocations, a serious bug in binutils 2.22.52.0.x which currently produces bad kernels. ] Signed-off-by: H. Peter Anvin <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Jarkko Sakkinen <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]> Cc: <[email protected]>
1 parent 36be505 commit 6520fe5

File tree

7 files changed

+196
-65
lines changed

7 files changed

+196
-65
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ asm-generic:
442442

443443
no-dot-config-targets := clean mrproper distclean \
444444
cscope gtags TAGS tags help %docs check% coccicheck \
445-
include/linux/version.h headers_% archheaders \
445+
include/linux/version.h headers_% archheaders archscripts \
446446
kernelversion %src-pkg
447447

448448
config-targets := 0
@@ -979,7 +979,7 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
979979
include/config/auto.conf
980980
$(cmd_crmodverdir)
981981

982-
archprepare: archheaders prepare1 scripts_basic
982+
archprepare: archheaders archscripts prepare1 scripts_basic
983983

984984
prepare0: archprepare FORCE
985985
$(Q)$(MAKE) $(build)=.
@@ -1049,8 +1049,11 @@ hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
10491049
PHONY += archheaders
10501050
archheaders:
10511051

1052+
PHONY += archscripts
1053+
archscripts:
1054+
10521055
PHONY += __headers
1053-
__headers: include/linux/version.h scripts_basic asm-generic archheaders FORCE
1056+
__headers: include/linux/version.h scripts_basic asm-generic archheaders archscripts FORCE
10541057
$(Q)$(MAKE) $(build)=scripts build_unifdef
10551058

10561059
PHONY += headers_install_all

arch/x86/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
134134
KBUILD_CFLAGS += $(mflags-y)
135135
KBUILD_AFLAGS += $(mflags-y)
136136

137+
archscripts:
138+
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
139+
137140
###
138141
# Syscall table generation
139142

arch/x86/boot/compressed/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
4040
$(obj)/vmlinux.bin: vmlinux FORCE
4141
$(call if_changed,objcopy)
4242

43+
targets += vmlinux.bin.all vmlinux.relocs
4344

44-
targets += vmlinux.bin.all vmlinux.relocs relocs
45-
hostprogs-$(CONFIG_X86_NEED_RELOCS) += relocs
46-
45+
CMD_RELOCS = arch/x86/tools/relocs
4746
quiet_cmd_relocs = RELOCS $@
48-
cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
49-
$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
47+
cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
48+
$(obj)/vmlinux.relocs: vmlinux FORCE
5049
$(call if_changed,relocs)
5150

5251
vmlinux.bin.all-y := $(obj)/vmlinux.bin

arch/x86/tools/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
relocs

arch/x86/tools/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ HOSTCFLAGS_insn_sanity.o := -Wall -I$(objtree)/arch/x86/lib/ -I$(srctree)/arch/x
3636
$(obj)/test_get_len.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
3737

3838
$(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+
40+
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
41+
hostprogs-y += relocs
42+
relocs: $(obj)/relocs

0 commit comments

Comments
 (0)