From: Mohan Kumar M <mohan@in.ibm.com>
To: ppcdev <linuxppc-dev@ozlabs.org>
Cc: paulus@samba.org
Subject: [RFC PATCH 2/4] Build files needed for relocation support
Date: Fri, 30 May 2008 00:45:03 +0530 [thread overview]
Message-ID: <20080529191503.GB15762@in.ibm.com> (raw)
In-Reply-To: <20080529190809.GA15388@in.ibm.com>
Build files needed for relocation
This patch builds vmlinux file with relocation sections and contents so
that relocs user space program can extract the required relocation
offsets. This packs final relocatable vmlinux kernel as following:
earlier part of relocation apply code, vmlinux, rest of relocation apply
code.
File make.reloc is used to build the relocatable kernel "vmlinux.reloc".
TODO:
I have not yet integrated building relocatable kernel with kernel
Makefile. I need help to integrate this into kernel build process.
Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
---
Index: linux-2.6.26-rc3/arch/powerpc/Kconfig
===================================================================
--- linux-2.6.26-rc3.orig/arch/powerpc/Kconfig
+++ linux-2.6.26-rc3/arch/powerpc/Kconfig
@@ -317,6 +317,15 @@ config CRASH_DUMP
Don't change this unless you know what you are doing.
+config RELOCATABLE_PPC64
+ bool "Build a relocatable kernel (EXPERIMENTAL)"
+ depends on PPC_MULTIPLATFORM && PPC64 && CRASH_DUMP && EXPERIMENTAL
+ help
+ Build a kernel suitable for use as regular kernel and kdump capture
+ kernel.
+
+ Don't change this unless you know what you are doing.
+
config PHYP_DUMP
bool "Hypervisor-assisted dump (EXPERIMENTAL)"
depends on PPC_PSERIES && EXPERIMENTAL
@@ -656,7 +665,7 @@ config LOWMEM_SIZE
default "0x30000000"
config RELOCATABLE
- bool "Build a relocatable kernel (EXPERIMENTAL)"
+ bool "Build relocatable kernel (EXPERIMENTAL)"
depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE
help
This builds a kernel image that is capable of running at the
@@ -776,11 +785,11 @@ config PAGE_OFFSET
default "0xc000000000000000"
config KERNEL_START
hex
- default "0xc000000002000000" if CRASH_DUMP
+ default "0xc000000002000000" if CRASH_DUMP && !RELOCATABLE_PPC64
default "0xc000000000000000"
config PHYSICAL_START
hex
- default "0x02000000" if CRASH_DUMP
+ default "0x02000000" if CRASH_DUMP && !RELOCATABLE_PPC64
default "0x00000000"
endif
Index: linux-2.6.26-rc3/arch/powerpc/Makefile
===================================================================
--- linux-2.6.26-rc3.orig/arch/powerpc/Makefile
+++ linux-2.6.26-rc3/arch/powerpc/Makefile
@@ -69,7 +69,7 @@ override CC += -m$(CONFIG_WORD_SIZE)
override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
endif
-LDFLAGS_vmlinux := -Bstatic
+LDFLAGS_vmlinux := --emit-relocs
CFLAGS-$(CONFIG_PPC64) := -mminimal-toc -mtraceback=none -mcall-aixdesc
CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
Index: linux-2.6.26-rc3/arch/powerpc/vmlinux.reloc.lds.S
===================================================================
--- /dev/null
+++ linux-2.6.26-rc3/arch/powerpc/vmlinux.reloc.lds.S
@@ -0,0 +1,29 @@
+#include <asm/page.h>
+#include <asm-generic/vmlinux.lds.h>
+
+ENTRY(start_wrap)
+
+OUTPUT_ARCH(powerpc:common)
+/* OUTPUT_ARCH(elf64ppc) */
+SECTIONS
+{
+ . = KERNELBASE;
+
+/*
+ * Text, read only data and other permanent read-only sections
+ */
+ /* Text and gots */
+ .text : {
+ _head = .;
+ *(.text.head)
+ _ehead = .;
+
+ _text = .;
+ *(.vmlinux)
+ _etext = .;
+
+ _reloc = .;
+ *(.text.reloc)
+ _ereloc = .;
+ }
+}
Index: linux-2.6.26-rc3/arch/powerpc/vmlinux.reloc.scr
===================================================================
--- /dev/null
+++ linux-2.6.26-rc3/arch/powerpc/vmlinux.reloc.scr
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ .vmlinux : {
+ input_len = .;
+ *(.data)
+ output_len = . - 8;
+ }
+}
Index: linux-2.6.26-rc3/make.reloc
===================================================================
--- /dev/null
+++ linux-2.6.26-rc3/make.reloc
@@ -0,0 +1,35 @@
+#Makefile for building vmlinux with relocatable information and code.
+
+all: vmlinux.reloc
+
+obj := arch/powerpc
+
+AS = as
+LD = ld
+CC = gcc
+CPP = $(CC) -E
+
+
+$(obj)/relocs : $(obj)/relocs.c
+ $(CC) $(obj)/relocs.c -o $(obj)/relocs
+
+$(obj)/vmlinux.reloc.bin : vmlinux $(obj)/relocs
+ $(obj)/relocs vmlinux > $(obj)/vmlinux.reloc.bin 2>/dev/null
+
+$(obj)/vmlinux.bin: vmlinux
+ objcopy -O binary -R .note -R .comment -S vmlinux $(obj)/vmlinux.bin
+
+$(obj)/vmlinux.bin.all : $(obj)/vmlinux.bin $(obj)/vmlinux.reloc.bin
+ cat $(obj)/vmlinux.bin $(obj)/vmlinux.reloc.bin > $(obj)/vmlinux.bin.all
+
+$(obj)/vmlinux.new : $(obj)/vmlinux.reloc.scr $(obj)/vmlinux.bin.all
+ $(LD) -m elf64ppc -r --format binary --oformat elf64-powerpc -T $(obj)/vmlinux.reloc.scr $(obj)/vmlinux.bin.all -o $(obj)/vmlinux.new
+
+$(obj)/kernel/reloc_apply.o : $(obj)/kernel/reloc_apply.S
+ $(CC) -m64 -Wp,-MD,arch/powerpc/kernel/.reloc_apply.o.d -nostdinc -isystem /usr/lib/gcc/powerpc64-suse-linux/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -D__ASSEMBLY__ -Wa,-maltivec -c -o arch/powerpc/kernel/reloc_apply.o arch/powerpc/kernel/reloc_apply.S
+
+$(obj)/vmlinux.reloc.lds : $(obj)/vmlinux.reloc.lds.S
+ $(CC) -m64 -E -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Os -msoft-float -pipe -mminimal-toc -mtraceback=none -mcall-aixdesc -mtune=power4 -mno-altivec -mno-spe -funit-at-a-time -mno-string -Wa,-maltivec -fomit-frame-pointer -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -Wp,-MD,arch/powerpc/.vmlinux.reloc.lds.d -nostdinc -isystem /usr/lib/gcc/powerpc64-suse-linux/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Upowerpc -P -C -Upowerpc -D__ASSEMBLY__ -o arch/powerpc/vmlinux.reloc.lds arch/powerpc/vmlinux.reloc.lds.S
+
+vmlinux.reloc : $(obj)/vmlinux.reloc.lds $(obj)/vmlinux.new $(obj)/kernel/reloc_apply.o
+ $(LD) -m elf64ppc -T $(obj)/vmlinux.reloc.lds $(obj)/vmlinux.new $(obj)/kernel/reloc_apply.o -o vmlinux.reloc
next prev parent reply other threads:[~2008-05-29 19:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-29 19:08 [RFC PATCH 0/4] Relocatable kernel support for PPC64 Mohan Kumar M
2008-05-29 19:13 ` [RFC PATCH 1/4] Extract list of relocation offsets Mohan Kumar M
2008-05-29 19:15 ` Mohan Kumar M [this message]
2008-05-29 19:16 ` [RFC PATCH 3/4] Apply relocation info to vmlinux Mohan Kumar M
2008-05-29 19:18 ` [RFC PATCH 4/4] Relocation support Mohan Kumar M
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080529191503.GB15762@in.ibm.com \
--to=mohan@in.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).