linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@fr.ibm.com>
To: benh@kernel.crashing.org
Cc: "Cédric Le Goater" <clg@fr.ibm.com>, linuxppc-dev@lists.ozlabs.org
Subject: [RFC PATCH 16/18] powerpc/boot: add support for 64bit big endian wrapper
Date: Fri,  7 Feb 2014 16:59:29 +0100	[thread overview]
Message-ID: <1391788771-16405-17-git-send-email-clg@fr.ibm.com> (raw)
In-Reply-To: <1391788771-16405-1-git-send-email-clg@fr.ibm.com>

The boot wrapper is now compiled using -m64 for 64bit kernels.

The linker script is generated using the kernel preprocessor flags
to make use of the CONFIG_PPC64 definitions and the wrapper script is
modified to take into account the new elf64ppc format.

zImage is compiled as a position independent executable (-pie) which
makes it loadable at any address by the firmware. This is subject to
comment as I am not sure what are the requirement for the different
boot loaders.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---

There is probably a better way to compile in 64bit than what this 
patch is proposing. Suggestions ?

 arch/powerpc/boot/Makefile     |    9 ++++++++-
 arch/powerpc/boot/wrapper      |   14 +++++++++++++-
 arch/powerpc/boot/zImage.lds.S |   25 ++++++++++++++++++++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 4c4ec163a7a1..bedbd46273e4 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -24,6 +24,9 @@ BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
 		 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
 		 -mbig-endian
+ifdef CONFIG_PPC64
+BOOTCFLAGS	+= -m64
+endif
 BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
 
 ifdef CONFIG_DEBUG_INFO
@@ -139,7 +142,11 @@ $(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc
 $(obj)/empty.c:
 	@touch $@
 
-$(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S
+$(obj)/zImage.lds: $(obj)/%: $(srctree)/$(src)/%.S
+	$(CROSS32CC) $(cpp_flags) -E -Wp,-MD,$(depfile) -P -Upowerpc \
+		-D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
+
+$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
 	@cp $< $@
 
 clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index cd0101f1d457..6eca1b4ecfa4 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -40,6 +40,7 @@ cacheit=
 binary=
 gzip=.gz
 pie=
+format=
 
 # cross-compilation prefix
 CROSS=
@@ -136,6 +137,13 @@ if [ -z "$kernel" ]; then
     kernel=vmlinux
 fi
 
+elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
+case "$elfformat" in
+    elf64-powerpc)	format=elf64ppc	;;
+    elf32-powerpc)	format=elf32ppc	;;
+esac
+
+
 platformo=$object/"$platform".o
 lds=$object/zImage.lds
 ext=strip
@@ -154,6 +162,10 @@ of)
 pseries)
     platformo="$object/pseries-head.o $object/of.o $object/epapr.o"
     link_address='0x4000000'
+    if [ "$format" != "elf32ppc" ]; then
+	link_address=
+	pie=-pie
+    fi
     make_space=n
     ;;
 maple)
@@ -375,7 +387,7 @@ if [ "$platform" != "miboot" ]; then
     if [ -n "$link_address" ] ; then
         text_start="-Ttext $link_address"
     fi
-    ${CROSS}ld -m elf32ppc -T $lds $text_start $pie -o "$ofile" \
+    ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \
 	$platformo $tmp $object/wrapper.a
     rm $tmp
 fi
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index 2bd8731f1365..afecab0aff5c 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -1,4 +1,10 @@
+#include <asm-generic/vmlinux.lds.h>
+
+#ifdef CONFIG_PPC64
+OUTPUT_ARCH(powerpc:common64)
+#else
 OUTPUT_ARCH(powerpc:common)
+#endif
 ENTRY(_zimage_start)
 EXTERN(_zimage_start)
 SECTIONS
@@ -16,7 +22,9 @@ SECTIONS
     *(.rodata*)
     *(.data*)
     *(.sdata*)
+#ifdef CONFIG_PPC32
     *(.got2)
+#endif
   }
   .dynsym : { *(.dynsym) }
   .dynstr : { *(.dynstr) }
@@ -27,7 +35,13 @@ SECTIONS
   }
   .hash : { *(.hash) }
   .interp : { *(.interp) }
-  .rela.dyn : { *(.rela*) }
+  .rela.dyn :
+  {
+#ifdef CONFIG_PPC64
+    __rela_dyn_start = .;
+#endif
+    *(.rela*)
+  }
 
   . = ALIGN(8);
   .kernel:dtb :
@@ -53,6 +67,15 @@ SECTIONS
     _initrd_end =  .;
   }
 
+#ifdef CONFIG_PPC64
+  .got :
+  {
+    __toc_start = .;
+    *(.got)
+    *(.toc)
+  }
+#endif
+
   . = ALIGN(4096);
   .bss       :
   {
-- 
1.7.10.4

  parent reply	other threads:[~2014-02-07 15:59 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 15:59 [RFC PATCH 00/18] powerpc/boot: 64bit little endian wrapper for pseries Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 01/18] powerpc/boot: fix do_div for 64bit wrapper Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 02/18] powerpc/boot: use a common prom_args struct in oflib Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 03/18] powerpc/boot: use prom_arg_t " Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 04/18] powerpc/boot: add byteswapping routines " Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 05/18] powerpc/boot: add PROM_ERROR define " Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 06/18] powerpc/boot: rework of_claim() to make it 64bit friendly Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 07/18] powerpc/boot: define typedef ihandle as u32 Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 08/18] powerpc/boot: fix compile warning in 64bit Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 09/18] powerpc/boot: define byteswapping routines for little endian Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 10/18] powerpc/boot: add 64bit and little endian support to addnote Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 11/18] powerpc/boot: add little endian support to elf utils Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 12/18] powerpc/boot: define a routine to enter prom Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 13/18] powerpc/boot: modify entry point for 64bit Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 14/18] powerpc/boot: modify how we enter kernel on 64bit Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 15/18] powerpc/boot: add a global entry point for pseries Cédric Le Goater
2014-02-07 15:59 ` Cédric Le Goater [this message]
2014-02-07 15:59 ` [RFC PATCH 17/18] powerpc/boot: add support for 64bit little endian wrapper Cédric Le Goater
2014-02-07 15:59 ` [RFC PATCH 18/18] powerpc/boot: add PPC64_BOOT_WRAPPER config option Cédric Le Goater
2014-03-20 15:09 ` [PATCH 00/18] powerpc/boot: 64bit little endian wrapper Cédric Le Goater
2014-03-20 17:03   ` Geoff Levand
2014-03-21  8:37     ` Cedric Le Goater
2014-03-21  9:37       ` Cedric Le Goater
2014-03-21 17:28   ` Geoff Levand
2014-03-21 17:40     ` Cedric Le Goater
2014-03-20 15:09 ` [PATCH 01/18] powerpc/boot: fix do_div for 64bit wrapper Cédric Le Goater
2014-03-20 15:09 ` [PATCH 02/18] powerpc/boot: use a common prom_args struct in oflib Cédric Le Goater
2014-03-20 15:09 ` [PATCH 03/18] powerpc/boot: use prom_arg_t " Cédric Le Goater
2014-03-20 15:09 ` [PATCH 04/18] powerpc/boot: add byteswapping routines " Cédric Le Goater
2014-03-20 15:10 ` [PATCH 05/18] powerpc/boot: add PROM_ERROR define " Cédric Le Goater
2014-03-20 15:10 ` [PATCH 06/18] powerpc/boot: rework of_claim() to make it 64bit friendly Cédric Le Goater
2014-03-20 15:10 ` [PATCH 07/18] powerpc/boot: define typedef ihandle as u32 Cédric Le Goater
2014-03-20 15:10 ` [PATCH 08/18] powerpc/boot: fix compile warning in 64bit Cédric Le Goater
2014-03-20 15:10 ` [PATCH 09/18] powerpc/boot: define byteswapping routines for little endian Cédric Le Goater
2014-03-20 15:10 ` [PATCH 10/18] powerpc/boot: add 64bit and little endian support to addnote Cédric Le Goater
2014-03-20 15:10 ` [PATCH 11/18] powerpc/boot: add little endian support to elf utils Cédric Le Goater
2014-03-20 15:10 ` [PATCH 12/18] powerpc/boot: define a routine to enter prom Cédric Le Goater
2014-03-20 15:10 ` [PATCH 13/18] powerpc/boot: modify entry point for 64bit Cédric Le Goater
2014-03-20 15:10 ` [PATCH 14/18] powerpc/boot: modify how we enter kernel on 64bit Cédric Le Goater
2014-03-20 15:10 ` [PATCH 15/18] powerpc/boot: add a global entry point for pseries Cédric Le Goater
2014-03-20 15:10 ` [PATCH 16/18] powerpc/boot: add support for 64bit big endian wrapper Cédric Le Goater
2014-03-20 15:10 ` [PATCH 17/18] powerpc/boot: add support for 64bit little " Cédric Le Goater
2014-03-20 15:10 ` [PATCH 18/18] powerpc/boot: add PPC64_BOOT_WRAPPER config option Cédric Le Goater
2014-03-24  3:42   ` Benjamin Herrenschmidt
2014-03-24  8:38     ` Cedric Le Goater
2014-03-24  9:04       ` Benjamin Herrenschmidt
2014-03-24 10:22         ` [PATCH] powerpc/boot: fix global entry point for pseries Cédric Le Goater
2014-04-14  7:46         ` [PATCH v2 00/15] powerpc/boot: 64bit little endian wrapper Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 01/15] powerpc/boot: fix do_div for 64bit wrapper Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 02/15] powerpc/boot: use a common prom_args struct in oflib Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 03/15] powerpc/boot: use prom_arg_t " Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 04/15] powerpc/boot: add byteswapping routines " Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 05/15] powerpc/boot: add PROM_ERROR define " Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 06/15] powerpc/boot: rework of_claim() to make it 64bit friendly Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 07/15] powerpc/boot: define typedef ihandle as u32 Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 08/15] powerpc/boot: fix compile warning in 64bit Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 09/15] powerpc/boot: define byteswapping routines for little endian Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 10/15] powerpc/boot: add 64bit and little endian support to addnote Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 11/15] powerpc/boot: add little endian support to elf utils Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 12/15] powerpc/boot: define a routine to enter prom Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 13/15] powerpc/boot: modify entry point for 64bit Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 14/15] powerpc/boot: add a global entry point for pseries Cédric Le Goater
2014-04-14  7:47         ` [PATCH v2 15/15] powerpc/boot: add support for 64bit little endian wrapper Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 00/15] powerpc/boot: 64bit little endian wrapper (rebased on v3.15-rc2) Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 01/15] powerpc/boot: fix do_div for 64bit wrapper Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 02/15] powerpc/boot: use a common prom_args struct in oflib Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 03/15] powerpc/boot: use prom_arg_t " Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 04/15] powerpc/boot: add byteswapping routines " Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 05/15] powerpc/boot: add PROM_ERROR define " Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 06/15] powerpc/boot: rework of_claim() to make it 64bit friendly Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 07/15] powerpc/boot: define typedef ihandle as u32 Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 08/15] powerpc/boot: fix compile warning in 64bit Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 09/15] powerpc/boot: define byteswapping routines for little endian Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 10/15] powerpc/boot: add 64bit and little endian support to addnote Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 11/15] powerpc/boot: add little endian support to elf utils Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 12/15] powerpc/boot: define a routine to enter prom Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 13/15] powerpc/boot: modify entry point for 64bit Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 14/15] powerpc/boot: add a global entry point for pseries Cédric Le Goater
2014-04-24  7:23         ` [PATCH v2 15/15] powerpc/boot: add support for 64bit little endian wrapper Cédric Le Goater

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=1391788771-16405-17-git-send-email-clg@fr.ibm.com \
    --to=clg@fr.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.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).