From patchwork Tue Nov 10 01:14:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Chou X-Patchwork-Id: 542093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6EF531402D4 for ; Tue, 10 Nov 2015 12:14:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2DB314B8F6; Tue, 10 Nov 2015 02:14:16 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6Y2EFWmZbriy; Tue, 10 Nov 2015 02:14:16 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 998214B8CF; Tue, 10 Nov 2015 02:14:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 88BC64B8EC for ; Tue, 10 Nov 2015 02:14:11 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K_pjis-jH8cm for ; Tue, 10 Nov 2015 02:14:11 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from www.wytron.com.tw (220-134-43-68.HINET-IP.hinet.net [220.134.43.68]) by theia.denx.de (Postfix) with ESMTP id 8FA124B8F6 for ; Tue, 10 Nov 2015 02:14:05 +0100 (CET) Received: from [127.0.0.1] (unknown [192.168.1.250]) by www.wytron.com.tw (Postfix) with ESMTP id 7E4F5D002E8; Tue, 10 Nov 2015 09:14:02 +0800 (CST) To: Albert ARIBAUD , u-boot@lists.denx.de References: <1447114831-18627-1-git-send-email-albert.u.boot@aribaud.net> From: Thomas Chou Message-ID: <564144D9.3010108@wytron.com.tw> Date: Tue, 10 Nov 2015 09:14:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1447114831-18627-1-git-send-email-albert.u.boot@aribaud.net> Subject: Re: [U-Boot] [PATCH] Fix board init code to use a valid C runtime environment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Hi Albert, On 2015年11月10日 08:20, Albert ARIBAUD wrote: > board_init_f_mem() alters the C runtime environment's > stack it ls actually already using. This is not a valid > C runtime environment and may conflict with the C compiler's > expectations. > > Split board_init_f_mem into C functions which do not > alter their own stack and therefore function in a valid C > runtime environment. > > NOTE: this has not been tested with all architectures. > > Signed-off-by: Albert ARIBAUD > --- > arch/arc/lib/start.S | 20 +++++++++++++--- > arch/arm/lib/crt0.S | 10 ++++++-- > arch/arm/lib/crt0_64.S | 12 +++++++--- > arch/microblaze/cpu/start.S | 4 ++-- > arch/nios2/cpu/start.S | 17 ++++++++++++-- > arch/powerpc/cpu/ppc4xx/start.S | 18 ++++++++++---- > arch/x86/cpu/start.S | 10 ++++++-- > arch/x86/lib/fsp/fsp_common.c | 2 +- > common/init/board_init.c | 33 +++++++++++++++----------- > include/common.h | 52 +++++++++++++++++++++++++---------------- > 10 files changed, 126 insertions(+), 52 deletions(-) > Apply the patch. $ git am "/work/tmp/[U-Boot] [PATCH] Fix board init code to use a valid C runtime environment.eml" Applying: Fix board init code to use a valid C runtime environment /work/nios2-linux/u-boot/.git/rebase-apply/patch:91: trailing whitespace. /work/nios2-linux/u-boot/.git/rebase-apply/patch:292: trailing whitespace. * /work/nios2-linux/u-boot/.git/rebase-apply/patch:309: trailing whitespace. * /work/nios2-linux/u-boot/.git/rebase-apply/patch:325: trailing whitespace. * /work/nios2-linux/u-boot/.git/rebase-apply/patch:337: trailing whitespace. * warning: 5 lines add whitespace errors. Make. LD arch/nios2/lib/built-in.o CC common/init/board_init.o common/init/board_init.c:61:6: error: conflicting types for 'board_init_f_malloc' void board_init_f_malloc(ulong malloc_base) ^ In file included from common/init/board_init.c:10:0: include/common.h:265:7: note: previous declaration of 'board_init_f_malloc' was here ulong board_init_f_malloc(ulong malloc_base); ^ scripts/Makefile.build:277: recipe for target 'common/init/board_init.o' failed make[2]: *** [common/init/board_init.o] Error 1 scripts/Makefile.build:422: recipe for target 'common/init' failed make[1]: *** [common/init] Error 2 Makefile:1205: recipe for target 'common' failed make: *** [common] Error 2 Fix common.h. Make and run, but failed to boot. I will gdb and tell you the trace later. Best regards, Thomas diff --git a/include/common.h b/include/common.h index dbc2808..7eb3ba8 100644 --- a/include/common.h +++ b/include/common.h @@ -262,7 +262,7 @@ ulong board_init_f_malloc_size(void); * * @malloc_base: the base of the malloc arena */ -ulong board_init_f_malloc(ulong malloc_base); +void board_init_f_malloc(ulong malloc_base); /** * arch_setup_gd() - Set up the global_data pointer Make again. LDS u-boot.lds LD u-boot arch/nios2/cpu/start.o: In function `_reloc': /work/nios2-linux/u-boot/arch/nios2/cpu/start.S:111: undefined reference to `board_init_gd_size' /work/nios2-linux/u-boot/arch/nios2/cpu/start.S:120: undefined reference to `board_init_malloc_size' Makefile:1187: recipe for target 'u-boot' failed make: *** [u-boot] Error 1 Fix start.S. diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S index 4d5f0b0..c163ce1 100644 --- a/arch/nios2/cpu/start.S +++ b/arch/nios2/cpu/start.S @@ -108,7 +108,7 @@ _reloc: /* Allocate and zero GD, update SP */ movhi r2, %hi(board_init_f_gd_size@h) - ori r2, r2, %lo(board_init_gd_size@h) + ori r2, r2, %lo(board_init_f_gd_size@h) callr r2 sub sp, sp, r4 mov r4, sp @@ -117,7 +117,7 @@ _reloc: callr r2 /* Allocate malloc arena, update SP */ movhi r2, %hi(board_init_f_malloc_size@h) - ori r2, r2, %lo(board_init_malloc_size@h) + ori r2, r2, %lo(board_init_f_malloc_size@h) callr r2 sub sp, sp, r4 mov r4, sp