From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sullivan.realtime.net (sullivan.realtime.net [205.238.132.76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTP id E888F67BE7 for ; Thu, 29 Jun 2006 23:45:02 +1000 (EST) Date: Thu, 29 Jun 2006 08:28:48 -0500 (CDT) Message-Id: <200606291328.k5TDSmrx098184@sullivan.realtime.net> From: Milton Miller Subject: [5/5][POWERPC] boot: generate lds file from lds.S To: Cc: Paul Mackerras List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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 = . ; +}