[RFC PATCH 4/7] MIPS: Generate relocation table when CONFIG_RELOCATABLE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When CONFIG_RELOCATABLE is enabled (added in later patch)
add --emit-relocs to vmlinux LDFLAGS so that the elf
contains relocation information.

Run the previously added relocation tool to append the
relocation table to the binary image.

Space for the table is reserved in the linker script
by a previous commit

Signed-off-by: Matt Redfearn <matt.redfearn@xxxxxxxxxx>
---
 arch/mips/Makefile      |  4 ++++
 arch/mips/boot/Makefile | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 9371ea0adb88..fd28b0965c42 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -96,6 +96,10 @@ LDFLAGS_vmlinux			+= -G 0 -static -n -nostdlib
 KBUILD_AFLAGS_MODULE		+= -mlong-calls
 KBUILD_CFLAGS_MODULE		+= -mlong-calls
 
+ifeq ($(CONFIG_RELOCATABLE),y)
+LDFLAGS_vmlinux			+= --emit-relocs
+endif
+
 #
 # pass -msoft-float to GAS if it supports it.  However on newer binutils
 # (specifically newer than 2.24.51.20140728) we then also need to explicitly
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index fb5bfaec55ac..127705bb43a8 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -36,10 +36,29 @@ $(obj)/vmlinux.ecoff: $(obj)/elf2ecoff $(VMLINUX) FORCE
 	$(call if_changed,ecoff)
 
 targets += vmlinux.bin
+ifneq ($(CONFIG_RELOCATABLE),y)
 quiet_cmd_bin = OBJCOPY $@
       cmd_bin = $(OBJCOPY) -O binary $(strip-flags) $(VMLINUX) $@
 $(obj)/vmlinux.bin: $(VMLINUX) FORCE
 	$(call if_changed,bin)
+else
+# For relocatable kernel, Generate a relocation table that is appended to the image
+
+CMD_RELOCS = arch/mips/boot/tools/relocs
+quiet_cmd_relocs = RELOCS  $@
+      cmd_relocs = $(CMD_RELOCS) $< > $@
+$(obj)/vmlinux.relocs: $(VMLINUX) FORCE
+	$(call if_changed,relocs)
+
+OBJCOPYFLAGS_vmlinux.img := -O binary $(strip-flags)
+$(obj)/vmlinux.img: $(VMLINUX) FORCE
+	$(call if_changed,objcopy)
+
+quiet_cmd_bin = BIN     $@
+      cmd_bin = cat $^ > $@
+$(obj)/vmlinux.bin: $(obj)/vmlinux.img $(obj)/vmlinux.relocs
+	$(call if_changed,bin)
+endif
 
 targets += vmlinux.srec
 quiet_cmd_srec = OBJCOPY $@
-- 
2.1.4





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux