From patchwork Tue Feb 21 01:32:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 142226 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 CE00AB6F9D for ; Tue, 21 Feb 2012 12:35:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C5EE8280F1; Tue, 21 Feb 2012 02:34: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 UB2sGiDXI0Sg; Tue, 21 Feb 2012 02:34:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B9DC280F8; Tue, 21 Feb 2012 02:33:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 39B11280C6 for ; Tue, 21 Feb 2012 02:33:21 +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 yYzsrdvawCX8 for ; Tue, 21 Feb 2012 02:33:20 +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 mail-gy0-f202.google.com (mail-gy0-f202.google.com [209.85.160.202]) by theia.denx.de (Postfix) with ESMTPS id 42E40280A4 for ; Tue, 21 Feb 2012 02:33:14 +0100 (CET) Received: by ghrr17 with SMTP id r17so745070ghr.3 for ; Mon, 20 Feb 2012 17:33:13 -0800 (PST) Received-SPF: pass (google.com: domain of sjg@google.com designates 10.236.131.138 as permitted sender) client-ip=10.236.131.138; Authentication-Results: mr.google.com; spf=pass (google.com: domain of sjg@google.com designates 10.236.131.138 as permitted sender) smtp.mail=sjg@google.com Received: from mr.google.com ([10.236.131.138]) by 10.236.131.138 with SMTP id m10mr50319565yhi.7.1329787993649 (num_hops = 1); Mon, 20 Feb 2012 17:33:13 -0800 (PST) Received: by 10.236.131.138 with SMTP id m10mr36011541yhi.7.1329787993632; Mon, 20 Feb 2012 17:33:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.131.138 with SMTP id m10mr36011516yhi.7.1329787993569; Mon, 20 Feb 2012 17:33:13 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id e44si12017360yhk.0.2012.02.20.17.33.13 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 20 Feb 2012 17:33:13 -0800 (PST) Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 738731E004D; Mon, 20 Feb 2012 17:33:13 -0800 (PST) Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 548941406CB; Mon, 20 Feb 2012 17:33:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 20 Feb 2012 17:32:54 -0800 Message-Id: <1329787975-6695-13-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1329787975-6695-1-git-send-email-sjg@chromium.org> References: <1329787975-6695-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmb8t+QZwkKgkKusoFUy8df7jslWarQ/WDNKmS27w+HMdeRBVXAACBh5XLl0oL3dpZSyQBBKvpk4RMCVH/+94BgB1v5TbHL39hi3EnhgDhAdvSsITKJiyM7z48GOvHEv+oD1kuIuiOSCSUTDmRG2gzo0hNi7lCXLoteKp/dbTpmBEZmYQs= Cc: Tom Rini Subject: [U-Boot] [PATCH v4 12/13] arm: Move over to generic relocation 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add a function to process a single ELF relocation and switch ARM over to use generic relocation. Signed-off-by: Simon Glass --- Changes in v2: - Use an inline relocation function to reduce code size Changes in v4: - Remove proc.S file from Makefiles - Split out board changes into separate patches arch/arm/config.mk | 3 -- arch/arm/include/asm/reloc.h | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/reloc.h diff --git a/arch/arm/config.mk b/arch/arm/config.mk index f47d4f7..45f9dca 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -81,6 +81,3 @@ endif ifndef CONFIG_NAND_SPL LDFLAGS_u-boot += -pie endif - -# We use legacy relocation for now -CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/arm/include/asm/reloc.h b/arch/arm/include/asm/reloc.h new file mode 100644 index 0000000..3b6491d --- /dev/null +++ b/arch/arm/include/asm/reloc.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * 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 + */ + +#include +#include + +/** + * Process a single ELF relocation entry + * + * @param addr Pointer to address of intruction/data to relocate + * @param info The ELF information word / flags + * @param symtab The ELF relocation symbol table + * @param reloc_off Offset of relocated U-Boot relative to load address + * @return 0 if ok, -1 on error + */ +static inline int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info, + Elf32_Sym *symtab, ulong reloc_off) +{ + int sym; + + switch (ELF32_R_TYPE(info)) { + /* relative fix: increase location by offset */ + case 23: /* TODO: add R_ARM_... defines to elf.h */ + *addr += reloc_off; + break; + + /* absolute fix: set location to (offset) symbol value */ + case 2: + sym = ELF32_R_SYM(info); + *addr = symtab[sym].st_value + reloc_off; + break; + + default: + debug("*** Invalid relocation\n"); + return -1; + } + return 0; +}