linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: Use Makefile.postlink to insert relocations into vmlinux
@ 2016-11-10 10:02 Matt Redfearn
  2016-12-02 19:06 ` Steven J. Hill
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Redfearn @ 2016-11-10 10:02 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, Matt Redfearn, linux-kernel

When relocatable support for MIPS was merged, there was no support for
an architecture to add a postlink step for vmlinux. This meant that only
invoking a target within the boot directory, such as uImage, caused the
relocations to be inserted into vmlinux. Building just the vmlinux
target would result in a relocatable kernel with no relocation
information present.

Commit fbe6e37dab97 ("kbuild: add arch specific post-link Makefile")
recified this situation, so MIPS can now define a postlink step to add
relocation information into vmlinux, and remove the additional steps
tacked onto boot targets.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 arch/mips/Makefile          | 12 ------------
 arch/mips/Makefile.postlink | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 12 deletions(-)
 create mode 100644 arch/mips/Makefile.postlink

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 1a6bac7b076f..fb7664c31259 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -327,10 +327,6 @@ rom.bin rom.sw: vmlinux
 		$(bootvars-y) $@
 endif
 
-CMD_RELOCS = arch/mips/boot/tools/relocs
-quiet_cmd_relocs = RELOCS  $<
-      cmd_relocs = $(CMD_RELOCS) $<
-
 #
 # Some machines like the Indy need 32-bit ELF binaries for booting purposes.
 # Other need ECOFF, so we build a 32-bit ELF binary for them which we then
@@ -339,11 +335,6 @@ quiet_cmd_relocs = RELOCS  $<
 quiet_cmd_32 = OBJCOPY $@
 	cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
 vmlinux.32: vmlinux
-ifeq ($(CONFIG_RELOCATABLE)$(CONFIG_64BIT),yy)
-# Currently, objcopy fails to handle the relocations in the elf64
-# So the relocs tool must be run here to remove them first
-	$(call cmd,relocs)
-endif
 	$(call cmd,32)
 
 #
@@ -359,9 +350,6 @@ all:	$(all-y)
 
 # boot
 $(boot-y): $(vmlinux-32) FORCE
-ifeq ($(CONFIG_RELOCATABLE)$(CONFIG_32BIT),yy)
-	$(call cmd,relocs)
-endif
 	$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \
 		$(bootvars-y) arch/mips/boot/$@
 
diff --git a/arch/mips/Makefile.postlink b/arch/mips/Makefile.postlink
new file mode 100644
index 000000000000..b0ddf0701a31
--- /dev/null
+++ b/arch/mips/Makefile.postlink
@@ -0,0 +1,35 @@
+# ===========================================================================
+# Post-link MIPS pass
+# ===========================================================================
+#
+# 1. Insert relocations into vmlinux
+
+PHONY := __archpost
+__archpost:
+
+include include/config/auto.conf
+include scripts/Kbuild.include
+
+CMD_RELOCS = arch/mips/boot/tools/relocs
+quiet_cmd_relocs = RELOCS $@
+      cmd_relocs = $(CMD_RELOCS) $@
+
+# `@true` prevents complaint when there is nothing to be done
+
+vmlinux: FORCE
+	@true
+ifeq ($(CONFIG_RELOCATABLE),y)
+	$(call if_changed,relocs)
+endif
+
+%.ko: FORCE
+	@true
+
+clean:
+	@true
+
+PHONY += FORCE clean
+
+FORCE:
+
+.PHONY: $(PHONY)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: Use Makefile.postlink to insert relocations into vmlinux
  2016-11-10 10:02 [PATCH] MIPS: Use Makefile.postlink to insert relocations into vmlinux Matt Redfearn
@ 2016-12-02 19:06 ` Steven J. Hill
  0 siblings, 0 replies; 2+ messages in thread
From: Steven J. Hill @ 2016-12-02 19:06 UTC (permalink / raw)
  To: Matt Redfearn, Ralf Baechle; +Cc: linux-mips, linux-kernel

On 11/10/2016 04:02 AM, Matt Redfearn wrote:
> When relocatable support for MIPS was merged, there was no support for
> an architecture to add a postlink step for vmlinux. This meant that only
> invoking a target within the boot directory, such as uImage, caused the
> relocations to be inserted into vmlinux. Building just the vmlinux
> target would result in a relocatable kernel with no relocation
> information present.
> 
> Commit fbe6e37dab97 ("kbuild: add arch specific post-link Makefile")
> recified this situation, so MIPS can now define a postlink step to add
> relocation information into vmlinux, and remove the additional steps
> tacked onto boot targets.
> 
> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
>
Tested on OCTEON III with relocatable kernel.

Tested-by: Steven J. Hill <steven.hill@cavium.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-02 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 10:02 [PATCH] MIPS: Use Makefile.postlink to insert relocations into vmlinux Matt Redfearn
2016-12-02 19:06 ` Steven J. Hill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).