From patchwork Tue Feb 12 17:27:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 219917 X-Patchwork-Delegate: trini@ti.com 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 847D02C0089 for ; Wed, 13 Feb 2013 04:27:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CC8D74A0AE; Tue, 12 Feb 2013 18:27:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 PUq3gBPT+P3p; Tue, 12 Feb 2013 18:27:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 097144A04E; Tue, 12 Feb 2013 18:27:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B19A44A04E for ; Tue, 12 Feb 2013 18:27:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 GjRmSjkTNg2U for ; Tue, 12 Feb 2013 18:27:37 +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 smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by theia.denx.de (Postfix) with ESMTP id 968D84A04C for ; Tue, 12 Feb 2013 18:27:34 +0100 (CET) Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2eb9:20:3895:ff37:2bb6:708a]) (Authenticated sender: albert.aribaud) by smtp1-g21.free.fr (Postfix) with ESMTPSA id 5EA76940165; Tue, 12 Feb 2013 18:27:30 +0100 (CET) From: Albert ARIBAUD To: u-boot@lists.denx.de Date: Tue, 12 Feb 2013 18:27:27 +0100 Message-Id: <1360690047-26599-1-git-send-email-albert.u.boot@aribaud.net> X-Mailer: git-send-email 1.7.10.4 Subject: [U-Boot] [RFC] [PATCH] Avoid R_ARM_ABS32 for bss start and end references X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch is intended to be patch 2/2 of my first patch to remove R_ARM_ABS32 relocation types from ARM builds. With this change, the type of ARM references to __bss_start and __bss_end__ is changed from R_ARM_ABS32 to R_ARM_RELATIVE. It should have no functional impact, as it only affects the resolution of references to __bss_start and __bss_end__ before relocation, and no code should ever perform such references... so far. References performed after relocation are unchanged by this patch. This patch SHOULD NOT BE applied in any official U-boot tree! It is submitted as an RFC and a request to test. This patch can only work on ARM; it will not work on any ARM target that uses another linker script than arch/arm/cpu/u-boot.lds, and it will not work on any non-ARM target. HOWEVER, if you can test it on one of these targets, then please do so by manually patching the appropriate linker script the same way arch/arm/cpu/u-boot.lds is patched here. If you are keen on testing but don't know how to patch your linker script, just let me know which target you intend to test on, and which linker script you need patched, and I'll do a v2 / v3... of this RFC. The goal here is to help me ensure the patch works well on enough targets that I can safely start the tedious work of patching all 150+ linker scripts. Tested-by: Luka Perkov --- arch/arm/cpu/u-boot.lds | 12 +++++++++--- lib/Makefile | 1 + lib/bss.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 lib/bss.c diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds index e6b202b..e1bc8e7 100644 --- a/arch/arm/cpu/u-boot.lds +++ b/arch/arm/cpu/u-boot.lds @@ -81,11 +81,17 @@ SECTIONS *(.mmutable) } - .bss __rel_dyn_start (OVERLAY) : { - __bss_start = .; + .bss_start __rel_dyn_start (OVERLAY) : { + KEEP(*(.__bss_start)); + } + + .bss __bss_start (OVERLAY) : { *(.bss*) . = ALIGN(4); - __bss_end__ = .; + ___bssend___ = .; + } + .bss_end ___bssend___ (OVERLAY) : { + KEEP(*(.__bss_end__)); } /DISCARD/ : { *(.dynstr*) } diff --git a/lib/Makefile b/lib/Makefile index 86ca1a6..73ee160 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libgeneric.o +COBJS-y += bss.o ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_ADDR_MAP) += addr_map.o COBJS-$(CONFIG_BCH) += bch.o diff --git a/lib/bss.c b/lib/bss.c new file mode 100644 index 0000000..5678f30 --- /dev/null +++ b/lib/bss.c @@ -0,0 +1,35 @@ +/* + * Copyright 2013 Albert ARIBAUD + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/** + * These two symbols are declared in a C file so that the linker + * uses R_ARM_RELATIVE relocation, rather than the R_ARM_ABS32 one + * it would use if the symbols were defined in the linker file. + * Using only R_ARM_RELATIVE relocation ensures that references to + * the symbols are correct after as well as before relocation. + * + * As the symbols do not require any content, and as we cannot define + * them as 'void', we go for the next best thing, 'struct {}'. + */ + +struct {} __bss_start __attribute__((used,section(".__bss_start"))); +struct {} __bss_end__ __attribute__((used,section(".__bss_end__")));