From patchwork Fri Mar 16 16:20:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 886978 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c-s.fr Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 402rVv0dCjz9sNq for ; Sat, 17 Mar 2018 03:28:39 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CD4D0C21E3B; Fri, 16 Mar 2018 16:24:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0377BC21E79; Fri, 16 Mar 2018 16:22:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 79CE7C21E0D; Fri, 16 Mar 2018 16:20:58 +0000 (UTC) Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by lists.denx.de (Postfix) with ESMTPS id ADA86C21E0F for ; Fri, 16 Mar 2018 16:20:54 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 402rKp2j1Kz9tvPl; Fri, 16 Mar 2018 17:20:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id NW_zi6vnWXGc; Fri, 16 Mar 2018 17:20:46 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 402rKp276nz9tvNg; Fri, 16 Mar 2018 17:20:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2FC438BBB3; Fri, 16 Mar 2018 17:20:54 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 6ebi0ZiI3_LQ; Fri, 16 Mar 2018 17:20:54 +0100 (CET) Received: from po15720vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.30]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E646D8BBB1; Fri, 16 Mar 2018 17:20:53 +0100 (CET) Received: by po15720vm.idsi0.si.c-s.fr (Postfix, from userid 0) id BA7F06F128; Fri, 16 Mar 2018 17:20:53 +0100 (CET) Message-Id: In-Reply-To: References: From: Christophe Leroy To: Tom Rini , Wolfgang Denk Date: Fri, 16 Mar 2018 17:20:53 +0100 (CET) Cc: Thomas Petazzoni , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 12/16] common: env_embedded: allow fine placement of environment object X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Commit 7653942b10e9e ("common/env_embedded.c: drop support for CONFIG_SYS_USE_PPCENV") dropped the .ppcenv section which was used in linking scripts to allow fine placement of embedded environment sections. This implies that GCC randomly places objects from env/embedded.o and environment is not guaranteed to be located at the correct address: 04003df8 g F .text 00000038 mii_init 04004000 g O .text 00000004 env_size 04004004 g O .text 00002000 environment 04006004 g F .text 00000040 .hidden __lshrdi3 This patch restores this capability by allocating each object marked with __UBOOT_ENV_SECTION__ into a different section. Hence 'environment' will be alone in .text.environment, allowing a fine placement in u-boot.lds with: . = DEFINED(env_offset) ? env_offset : .; env/embedded.o (.text.environment) Fixes: 7653942b10e9e ("common/env_embedded.c: drop support for CONFIG_SYS_USE_PPCENV") Cc: Thomas Petazzoni Signed-off-by: Christophe Leroy --- env/embedded.c | 8 ++++---- include/env_default.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/env/embedded.c b/env/embedded.c index 43694db70fe..9b0a6a3c3da 100644 --- a/env/embedded.c +++ b/env/embedded.c @@ -35,11 +35,11 @@ * a seperate section. */ #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ -# define __UBOOT_ENV_SECTION__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ +# define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/ #else /* Environment is embedded in U-Boot's .text section */ /* XXX - This only works with GNU C */ -# define __UBOOT_ENV_SECTION__ __attribute__ ((section(".text"))) +# define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name))) #endif /* @@ -70,7 +70,7 @@ #include #ifdef CONFIG_ENV_ADDR_REDUND -env_t redundand_environment __UBOOT_ENV_SECTION__ = { +env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = { 0, /* CRC Sum: invalid */ 0, /* Flags: invalid */ { @@ -87,7 +87,7 @@ env_t redundand_environment __UBOOT_ENV_SECTION__ = { * .data/.sdata section. * */ -unsigned long env_size __UBOOT_ENV_SECTION__ = sizeof(env_t); +unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t); /* * Add in absolutes. diff --git a/include/env_default.h b/include/env_default.h index b574345af25..dd741315ba4 100644 --- a/include/env_default.h +++ b/include/env_default.h @@ -11,7 +11,7 @@ #include #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED -env_t environment __UBOOT_ENV_SECTION__ = { +env_t environment __UBOOT_ENV_SECTION__(environment) = { ENV_CRC, /* CRC Sum */ #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT 1, /* Flags: valid */