From patchwork Tue Mar 6 12:06:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 882040 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 3zwbL56Pw5z9sZj for ; Tue, 6 Mar 2018 23:14:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8E7EFC21E7F; Tue, 6 Mar 2018 12:09:55 +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 4B9BCC21F24; Tue, 6 Mar 2018 12:07:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 94E70C21F1C; Tue, 6 Mar 2018 12:06:55 +0000 (UTC) Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by lists.denx.de (Postfix) with ESMTPS id F1163C21F6A for ; Tue, 6 Mar 2018 12:06:51 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 3zwb9H4Dv8z9ttwP; Tue, 6 Mar 2018 13:06:43 +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 ypn3WWTCMmxN; Tue, 6 Mar 2018 13:06:43 +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 3zwb9H3nRCz9ttCq; Tue, 6 Mar 2018 13:06:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 931AF8B7FC; Tue, 6 Mar 2018 13:06:51 +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 v4WHae85Ha1w; Tue, 6 Mar 2018 13:06:51 +0100 (CET) Received: from po15720vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.5]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6CAE98B7E1; Tue, 6 Mar 2018 13:06:51 +0100 (CET) Received: by po15720vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 3BD426F0E5; Tue, 6 Mar 2018 13:06:51 +0100 (CET) Message-Id: <962989c79b4fef29f4b6cb59980d30bc4d95a3ce.1520334961.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy To: Tom Rini Date: Tue, 6 Mar 2018 13:06:51 +0100 (CET) Cc: Thomas Petazzoni , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 14/15] 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 */