LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [5/5][POWERPC] boot: generate lds file from lds.S
@ 2006-06-29 13:28 Milton Miller
  0 siblings, 0 replies; 2+ messages in thread
From: Milton Miller @ 2006-06-29 13:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras

The zImage.kexec and zImage.kexec64 linker files are almost identical to
the base elf file.   Use the lds.S -> ld rule to share the source.

Tell the linker the fils is in $(obj) not $(srctree)/$(src)
zImage.coff.lds is different, it links the initrd and kernel in .data
rather than as a seperate section and without alignment, keep it seperate
for now.

Signed-off-by: Milton Miller <miltonm@bga.com>

Index: kernel/arch/powerpc/boot/Makefile
===================================================================
--- kernel.orig/arch/powerpc/boot/Makefile	2006-06-29 06:15:29.367203511 -0500
+++ kernel/arch/powerpc/boot/Makefile	2006-06-29 06:16:37.166736808 -0500
@@ -83,7 +83,7 @@ quiet_cmd_bootas = BOOTAS  $@
       cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
 
 quiet_cmd_bootld = BOOTLD  $@
-      cmd_bootld = $(CROSS32LD) -T $(srctree)/$(src)/$(3) -o $@ $(2)
+      cmd_bootld = $(CROSS32LD) -T $(obj)/$(3) -o $@ $(2)
 
 $(patsubst %.c,%.o, $(filter %.c, $(src-mult))): %.o: %.c FORCE
 	$(call if_changed_dep,bootcc)
@@ -106,6 +106,7 @@ hostprogs-y		:= addnote addRamDisk hack-
 targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \
 	   zImage.coff zImage.initrd.coff miboot.image miboot.initrd.image \
 	   zImage.kexec zImage.kexec.3264 zImage.kexec64 \
+	   zImage.lds zImage.kexec.lds zImage.kexec64.lds zImage.coff.lds \
 	   $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
 	   $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
 	   $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
@@ -159,12 +160,26 @@ $(call obj-sec, $(required) $(initrd)): 
 	$(call cmd,bootcc)
 	$(call cmd,addsection)
 
+lds-fl := -P -C -Upowerpc
+CPPFLAGS_zImage.coff.lds	:= $(lds-fl)
+CPPFLAGS_zImage.lds		:= $(lds-fl) -D__entry__=_zimage_start
+CPPFLAGS_zImage.lds			+= -D__base__="4*1024*1024"
+CPPFLAGS_zImage.kexec.lds	:= $(lds-fl) -D__entry__=master -D__base__=0
+CPPFLAGS_zImage.kexec64.lds	:= $(lds-fl) -D__entry__=_master64 -D__base__=0
+
+$(addprefix $(obj)/, zImage.lds zImage.kexec.lds zImage.kexec64.lds): \
+		$(srctree)/$(src)/zImage.lds.S FORCE
+	$(call if_changed_dep,cpp_lds_S)
+
+$(obj)/zImage.coff.lds:  $(srctree)/$(src)/$zImage.coff.lds.S FORCE
+	$(call if_changed_dep,cpp_lds_S)
+
 $(obj)/zImage.vmode $(obj)/zImage.coff: obj-boot += $(call obj-sec, $(required))
-$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds
+$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(obj)/zImage.lds
 	$(call cmd,bootld,$(obj-boot),zImage.lds)
 
 $(obj)/zImage.initrd.vmode $(obj)/zImage.initrd.coff: obj-boot += $(call obj-sec, $(required) $(initrd))
-$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds
+$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(obj)/zImage.lds
 	$(call cmd,bootld,$(obj-boot),zImage.lds)
 
 # For 32-bit powermacs, build the COFF and miboot images
@@ -187,13 +202,13 @@ kexecimg-$(CONFIG_KEXEC)-y              
 $(obj)/zImage.kexec: $(filter-out $(obj)/zImage.kexec, $(kexecimg-y-y))
 
 $(obj)/zImage.kexec: obj-kexec += $(call obj-sec, $(required))
-$(obj)/zImage.kexec: $(obj-kexec) $(srctree)/$(src)/zImage.kexec.lds \
+$(obj)/zImage.kexec: $(obj-kexec) $(obj)/zImage.kexec.lds \
 		$(call obj-sec, $(required)) FORCE
 	$(call if_changed,bootld,$(obj-kexec) $(call obj-sec, $(required)) \
 			,zImage.kexec.lds)
 
 $(obj)/zImage.kexec.3264: obj-kexec += $(call obj-sec, $(required))
-$(obj)/zImage.kexec.3264: $(obj-kexec) $(srctree)/$(src)/zImage.kexec64.lds \
+$(obj)/zImage.kexec.3264: $(obj-kexec) $(obj)/zImage.kexec64.lds \
 		$(call obj-sec, $(required)) FORCE
 	$(call if_changed,bootld,$(obj-kexec) $(call obj-sec, $(required)) \
 			,zImage.kexec64.lds)
@@ -213,12 +228,12 @@ $(obj)/zImage.initrd: $(obj)/zImage.init
 	$(call cmd,addnote)
 
 $(obj)/zImage.coff: $(call obj-sec, $(required)) $(obj-boot) \
-			$(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
+			$(obj)/zImage.coff.lds $(obj)/hack-coff
 	$(call cmd,bootld,$(obj-boot),zImage.coff.lds)
 	$(call cmd,gencoff)
 
 $(obj)/zImage.initrd.coff: $(call obj-sec, $(required) $(initrd)) $(obj-boot) \
-			   $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
+			   $(obj)/zImage.coff.lds $(obj)/hack-coff
 	$(call cmd,bootld,$(obj-boot),zImage.coff.lds)
 	$(call cmd,gencoff)
 
Index: kernel/arch/powerpc/boot/zImage.coff.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.coff.lds	2006-06-29 06:15:29.185232311 -0500
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_start)
-SECTIONS
-{
-  . = (5*1024*1024);
-  _start = .;
-  .text      :
-  {
-    *(.text)
-    *(.fixup)
-  }
-  _etext = .;
-  . = ALIGN(4096);
-  .data    :
-  {
-    *(.rodata*)
-    *(.data*)
-    *(.sdata*)
-    __got2_start = .;
-    *(.got2)
-    __got2_end = .;
-
-    _vmlinux_start =  .;
-    *(.kernel:vmlinux.strip)
-    _vmlinux_end =  .;
-
-    _initrd_start =  .;
-    *(.kernel:initrd)
-    _initrd_end =  .;
-  }
-
-  . = ALIGN(4096);
-  _edata  =  .;
-  __bss_start = .;
-  .bss       :
-  {
-   *(.sbss)
-   *(.bss)
-  }
-  _end = . ;
-
-  /DISCARD/ :
-  {
-    *(.comment)
-  }
-}
Index: kernel/arch/powerpc/boot/zImage.coff.lds.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.coff.lds.S	2006-06-29 06:16:26.525823380 -0500
@@ -0,0 +1,46 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(_start)
+SECTIONS
+{
+  . = (5*1024*1024);
+  _start = .;
+  .text      :
+  {
+    *(.text)
+    *(.fixup)
+  }
+  _etext = .;
+  . = ALIGN(4096);
+  .data    :
+  {
+    *(.rodata*)
+    *(.data*)
+    *(.sdata*)
+    __got2_start = .;
+    *(.got2)
+    __got2_end = .;
+
+    _vmlinux_start =  .;
+    *(.kernel:vmlinux.strip)
+    _vmlinux_end =  .;
+
+    _initrd_start =  .;
+    *(.kernel:initrd)
+    _initrd_end =  .;
+  }
+
+  . = ALIGN(4096);
+  _edata  =  .;
+  __bss_start = .;
+  .bss       :
+  {
+   *(.sbss)
+   *(.bss)
+  }
+  _end = . ;
+
+  /DISCARD/ :
+  {
+    *(.comment)
+  }
+}
Index: kernel/arch/powerpc/boot/zImage.kexec.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.kexec.lds	2006-06-29 06:15:29.238223924 -0500
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,51 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(master)
-SECTIONS
-{
-  . = 0;
-  _start = .;
-  .text      :
-  {
-    *(.text)
-    *(.fixup)
-  }
-  _etext = .;
-  . = ALIGN(4096);
-  .data    :
-  {
-    *(.rodata*)
-    *(.data*)
-    *(.sdata*)
-    __got2_start = .;
-    *(.got2)
-    __got2_end = .;
-  }
-
-  . = ALIGN(4096);
-  _vmlinux_start =  .;
-  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
-  _vmlinux_end =  .;
-
-  . = ALIGN(4096);
-  _initrd_start =  .;
-  .kernel:initrd : { *(.kernel:initrd) }
-  _initrd_end =  .;
-
-  . = ALIGN(4096);
-  _edata  =  .;
-
-  . = ALIGN(4096);
-  __stack_start =  .;
-  .stack : { *(.stack) }
-  __stack_end =  .;
-
-  . = ALIGN(4096);
-  __bss_start = .;
-  .bss       :
-  {
-   *(.sbss)
-   *(.bss)
-  }
-  . = ALIGN(4096);
-  _end = . ;
-}
Index: kernel/arch/powerpc/boot/zImage.kexec64.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.kexec64.lds	2006-06-29 06:15:29.266219493 -0500
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_master64)
-SECTIONS
-{
-  . = 0;
-  _start = .;
-  .text      :
-  {
-    *(.text)
-    *(.fixup)
-  }
-  _etext = .;
-  . = ALIGN(4096);
-  .data    :
-  {
-    *(.rodata*)
-    *(.data*)
-    *(.sdata*)
-    __got2_start = .;
-    *(.got2)
-    __got2_end = .;
-  }
-
-  . = ALIGN(4096);
-  _vmlinux_start =  .;
-  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
-  _vmlinux_end =  .;
-
-  . = ALIGN(4096);
-  _initrd_start =  .;
-  .kernel:initrd : { *(.kernel:initrd) }
-  _initrd_end =  .;
-
-  . = ALIGN(4096);
-  _edata  =  .;
-
-  . = ALIGN(4096);
-  __stack_start =  .;
-  .stack : { *(.stack) }
-  __stack_end =  .;
-
-  . = ALIGN(4096);
-  __bss_start = .;
-  .bss       :
-  {
-   *(.sbss)
-   *(.bss)
-  }
-  . = ALIGN(4096);
-  _end = . ;
-}
-
Index: kernel/arch/powerpc/boot/zImage.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.lds	2006-06-29 06:15:29.295214904 -0500
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_zimage_start)
-SECTIONS
-{
-  . = (4*1024*1024);
-  _start = .;
-  .text      :
-  {
-    *(.text)
-    *(.fixup)
-  }
-  _etext = .;
-  . = ALIGN(4096);
-  .data    :
-  {
-    *(.rodata*)
-    *(.data*)
-    *(.sdata*)
-    __got2_start = .;
-    *(.got2)
-    __got2_end = .;
-  }
-
-  . = ALIGN(4096);
-  _vmlinux_start =  .;
-  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
-  _vmlinux_end =  .;
-
-  . = ALIGN(4096);
-  _initrd_start =  .;
-  .kernel:initrd : { *(.kernel:initrd) }
-  _initrd_end =  .;
-
-  . = ALIGN(4096);
-  _edata  =  .;
-
-  . = ALIGN(4096);
-  __bss_start = .;
-  .bss       :
-  {
-   *(.sbss)
-   *(.bss)
-  }
-  . = ALIGN(4096);
-  _end = . ;
-}
Index: kernel/arch/powerpc/boot/zImage.lds.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.lds.S	2006-06-29 06:16:26.529822747 -0500
@@ -0,0 +1,51 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(__entry__)
+SECTIONS
+{
+  . = __base__;
+  _start = .;
+  .text      :
+  {
+    *(.text)
+    *(.fixup)
+  }
+  _etext = .;
+  . = ALIGN(4096);
+  .data    :
+  {
+    *(.rodata*)
+    *(.data*)
+    *(.sdata*)
+    __got2_start = .;
+    *(.got2)
+    __got2_end = .;
+  }
+
+  . = ALIGN(4096);
+  _vmlinux_start =  .;
+  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
+  _vmlinux_end =  .;
+
+  . = ALIGN(4096);
+  _initrd_start =  .;
+  .kernel:initrd : { *(.kernel:initrd) }
+  _initrd_end =  .;
+
+  . = ALIGN(4096);
+  _edata  =  .;
+
+  . = ALIGN(4096);
+  __stack_start =  .;
+  .stack : { *(.stack) }
+  __stack_end =  .;
+
+  . = ALIGN(4096);
+  __bss_start = .;
+  .bss       :
+  {
+   *(.sbss)
+   *(.bss)
+  }
+  . = ALIGN(4096);
+  _end = . ;
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [0/5][POWERPC] boot: create zImage.kexec #2
@ 2006-07-01 23:46 Milton Miller
  2006-07-01 23:47 ` [5/5][POWERPC] boot: generate lds file from lds.S Milton Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Sam Ravnborg

What follows is a series of 5 patches that take the existing zImge code
from the arch/powerpc/boot directory and add an alternative image that
will boot with a device tree struct but not with a prom interface
callback.

It searches the flat device tree (read-only) to find the
memory size, reserved ranges, and  rtas.  Messages are sent through
rtas to eiher the new for cell put-term-char or display-character
interfaces.


Status:  I changed more of the makefile to if_changed_dep.  I updated
the rules to not do if_changed and cmd when changing the same file.

Patches 4 and 5 have been rediffed and __ENTRY__ and __BASE__ are now
caps instead of lowercase in patch 5.

Unfornately I could not get my test and build machines talking due
to network problems, and thereefore was unable to regression test
the output.  Therefore the state is still 'it worked before I moved
code among the files' and 'display-character untested'.

Without [KBUILD] allow any PHONY in if_changed_dep it causes all
the files in boot to be built each time, unless we do some alternative,
either make COPYHEADERS a real dummy that we touch if it doesn't
exist, or just say rebuild all sources when any .h in the kernel
tree changes and collapse the dependency.

Its this fragment:

+$(obj-boot):  COPYHEADERS
+COPYHEADERS:	$(addprefix $(obj)/,$(linuxheader) $(zlibheader))
+PHONY	+= COPYHEADERS




 [1/5][POWERPC] boot: prepare for zImage.kexec
	I tried to keep the changes to main.c and prom.h minimal.  

 [2/5][POWERPC] boot: Add kexec callable zImage wrapper
	The actual code and crt0 for this method.

 [3/5][POWERPC] boot: use more Kbuild rules
	I had a bit of trouble with rebuilds.  This trys to get some
	rules more right.  

	It also renames zliblinuxheader to linuxheader as the next
	patch will add stringify.h to the list, and renames
	OBJCOPYFLAGS to allow usage of the $(objcopy) rule.

 [4/5][POWERPC] boot: Makefile and linker scripts for zImage.kexec
	Delta to above and inker scripts for the existing link.
	zImage.kexec is 32 bit, there is also altnernate link that
	pretends to be 64 bit which allows kexec-tools to load it
	without writing ompat code.

 [5/5][POWERPC] boot: generate lds file from lds.S
	An alterative file ploferations, generate the lds from .S using
	the Kbuild rule.  If you like this patch then I can avoid creating
	two files that are immediately removed.
milton

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

end of thread, other threads:[~2006-07-01 23:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-29 13:28 [5/5][POWERPC] boot: generate lds file from lds.S Milton Miller
  -- strict thread matches above, loose matches on Subject: below --
2006-07-01 23:46 [0/5][POWERPC] boot: create zImage.kexec #2 Milton Miller
2006-07-01 23:47 ` [5/5][POWERPC] boot: generate lds file from lds.S Milton Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox