From patchwork Tue Jun 17 14:29:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 4366681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A9299F1C4 for ; Tue, 17 Jun 2014 14:32:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7679C202B4 for ; Tue, 17 Jun 2014 14:32:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B50D2025B for ; Tue, 17 Jun 2014 14:32:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwuOW-00025U-R6; Tue, 17 Jun 2014 14:29:52 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwuOQ-000202-FK for linux-arm-kernel@lists.infradead.org; Tue, 17 Jun 2014 14:29:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=AeeR7w3E78hFNPAY734ikOg6j0RXlwNQU7wRzQk0mck=; b=HST4AN39TWcrwDgN7nxS7FBt7vxKDXZJmW3/N0NTnCtbC4y30xfyrxPdn/AiHMnF1m3tjrLoxdjp77bzgZltmGsJa0HIFHNfenHAHb5wQxIkv3wxbJqZ/uhG4wOaVL6S6B5nRp/jGepaKYEqH6olXRQucCilj99uHaagAeMyuIw=; Received: from n2100.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:39700) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1WwuNz-0004x9-KV; Tue, 17 Jun 2014 15:29:19 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1WwuNy-0000Mr-9U; Tue, 17 Jun 2014 15:29:18 +0100 Date: Tue, 17 Jun 2014 15:29:17 +0100 From: Russell King - ARM Linux To: Taras Kondratiuk Subject: Re: [PATCH] ARM: zImage: ensure header in LE format for BE8 kernels Message-ID: <20140617142917.GA31861@n2100.arm.linux.org.uk> References: <1397147232-28516-1-git-send-email-taras.kondratiuk@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1397147232-28516-1-git-send-email-taras.kondratiuk@linaro.org> User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140617_072946_948192_2EC56F38 X-CRM114-Status: GOOD ( 23.27 ) X-Spam-Score: -1.1 (-) Cc: Victor Kamensky , Nico Pitre , linux-kernel@vger.kernel.org, Ben Dooks , linaro-networking@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Apr 10, 2014 at 07:27:12PM +0300, Taras Kondratiuk wrote: > diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile > index 68c9183..8a80906 100644 > --- a/arch/arm/boot/compressed/Makefile > +++ b/arch/arm/boot/compressed/Makefile > @@ -114,7 +114,7 @@ targets := vmlinux vmlinux.lds \ > # Make sure files are removed during clean > extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \ > lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \ > - hyp-stub.S > + hyp-stub.S vmlinux.lds.S > > ifeq ($(CONFIG_FUNCTION_TRACER),y) > ORIG_CFLAGS := $(KBUILD_CFLAGS) > @@ -199,7 +199,7 @@ CFLAGS_font.o := -Dstatic= > $(obj)/font.c: $(FONTC) > $(call cmd,shipped) > > -$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) > +$(obj)/vmlinux.lds.S: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) > @sed "$(SEDFLAGS)" < $< > $@ Given that we're now passing the linker script through GCC for C preprocessing, it seems to me that we don't need to do the sed trick anymore - we can pass TEXTADDR and ZBSSADDR into GCC via definitions instead, so I've committed this patch after this one. No changes to the vmlinux.lds.* file, it's just a pure rename. Ack? From: Russell King Subject: [PATCH] ARM: Simplify generation of compressed vmlinux.lds file As we are now using the C preprocessor, we do not need to use sed to edit constants in this file, and then pass the resulting file through the C preprocessor. Instead, rely solely on the C preprocessor to rewrite TEXT_START and BSS_ADDR. Signed-off-by: Russell King Acked-by: Nicolas Pitre --- arch/arm/boot/compressed/.gitignore | 1 - arch/arm/boot/compressed/Makefile | 5 +- arch/arm/boot/compressed/vmlinux.lds.S | 90 +++++++++++++++++++++++++++++++++ arch/arm/boot/compressed/vmlinux.lds.in | 90 --------------------------------- 4 files changed, 91 insertions(+), 95 deletions(-) create mode 100644 arch/arm/boot/compressed/vmlinux.lds.S delete mode 100644 arch/arm/boot/compressed/vmlinux.lds.in diff --git a/arch/arm/boot/compressed/.gitignore b/arch/arm/boot/compressed/.gitignore index 6a26e7bcb714..0714e0334e33 100644 --- a/arch/arm/boot/compressed/.gitignore +++ b/arch/arm/boot/compressed/.gitignore @@ -10,7 +10,6 @@ piggy.xzkern piggy.lz4 vmlinux vmlinux.lds -vmlinux.lds.S # borrowed libfdt files fdt.c diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 8a8090694d89..46055d5e9414 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -81,7 +81,7 @@ ZTEXTADDR := 0 ZBSSADDR := ALIGN(8) endif -SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/ +CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" suffix_$(CONFIG_KERNEL_GZIP) = gzip suffix_$(CONFIG_KERNEL_LZO) = lzo @@ -199,8 +199,5 @@ CFLAGS_font.o := -Dstatic= $(obj)/font.c: $(FONTC) $(call cmd,shipped) -$(obj)/vmlinux.lds.S: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) - @sed "$(SEDFLAGS)" < $< > $@ - $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S $(call cmd,shipped) diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S new file mode 100644 index 000000000000..60162231c7ea --- /dev/null +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -0,0 +1,90 @@ +/* + * linux/arch/arm/boot/compressed/vmlinux.lds.in + * + * Copyright (C) 2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifdef CONFIG_CPU_ENDIAN_BE8 +#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ + (((x) >> 8) & 0x0000ff00) | \ + (((x) << 8) & 0x00ff0000) | \ + (((x) << 24) & 0xff000000) ) +#else +#define ZIMAGE_MAGIC(x) (x) +#endif + +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + /DISCARD/ : { + *(.ARM.exidx*) + *(.ARM.extab*) + /* + * Discard any r/w data - this produces a link error if we have any, + * which is required for PIC decompression. Local data generates + * GOTOFF relocations, which prevents it being relocated independently + * of the text/got segments. + */ + *(.data) + } + + . = TEXT_START; + _text = .; + + .text : { + _start = .; + *(.start) + *(.text) + *(.text.*) + *(.fixup) + *(.gnu.warning) + *(.glue_7t) + *(.glue_7) + } + .rodata : { + *(.rodata) + *(.rodata.*) + } + .piggydata : { + *(.piggydata) + } + + . = ALIGN(4); + _etext = .; + + .got.plt : { *(.got.plt) } + _got_start = .; + .got : { *(.got) } + _got_end = .; + + /* ensure the zImage file size is always a multiple of 64 bits */ + /* (without a dummy byte, ld just ignores the empty section) */ + .pad : { BYTE(0); . = ALIGN(8); } + _edata = .; + + _magic_sig = ZIMAGE_MAGIC(0x016f2818); + _magic_start = ZIMAGE_MAGIC(_start); + _magic_end = ZIMAGE_MAGIC(_edata); + + . = BSS_START; + __bss_start = .; + .bss : { *(.bss) } + _end = .; + + . = ALIGN(8); /* the stack must be 64-bit aligned */ + .stack : { *(.stack) } + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } +} + diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in deleted file mode 100644 index 60162231c7ea..000000000000 --- a/arch/arm/boot/compressed/vmlinux.lds.in +++ /dev/null @@ -1,90 +0,0 @@ -/* - * linux/arch/arm/boot/compressed/vmlinux.lds.in - * - * Copyright (C) 2000 Russell King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifdef CONFIG_CPU_ENDIAN_BE8 -#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ - (((x) >> 8) & 0x0000ff00) | \ - (((x) << 8) & 0x00ff0000) | \ - (((x) << 24) & 0xff000000) ) -#else -#define ZIMAGE_MAGIC(x) (x) -#endif - -OUTPUT_ARCH(arm) -ENTRY(_start) -SECTIONS -{ - /DISCARD/ : { - *(.ARM.exidx*) - *(.ARM.extab*) - /* - * Discard any r/w data - this produces a link error if we have any, - * which is required for PIC decompression. Local data generates - * GOTOFF relocations, which prevents it being relocated independently - * of the text/got segments. - */ - *(.data) - } - - . = TEXT_START; - _text = .; - - .text : { - _start = .; - *(.start) - *(.text) - *(.text.*) - *(.fixup) - *(.gnu.warning) - *(.glue_7t) - *(.glue_7) - } - .rodata : { - *(.rodata) - *(.rodata.*) - } - .piggydata : { - *(.piggydata) - } - - . = ALIGN(4); - _etext = .; - - .got.plt : { *(.got.plt) } - _got_start = .; - .got : { *(.got) } - _got_end = .; - - /* ensure the zImage file size is always a multiple of 64 bits */ - /* (without a dummy byte, ld just ignores the empty section) */ - .pad : { BYTE(0); . = ALIGN(8); } - _edata = .; - - _magic_sig = ZIMAGE_MAGIC(0x016f2818); - _magic_start = ZIMAGE_MAGIC(_start); - _magic_end = ZIMAGE_MAGIC(_edata); - - . = BSS_START; - __bss_start = .; - .bss : { *(.bss) } - _end = .; - - . = ALIGN(8); /* the stack must be 64-bit aligned */ - .stack : { *(.stack) } - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } -} -