From patchwork Mon Jan 3 19:46:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 77338 X-Patchwork-Delegate: graeme.russ@gmail.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 BB29FB6F14 for ; Tue, 4 Jan 2011 06:53:30 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DE3E528422; Mon, 3 Jan 2011 20:51:00 +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 bb-6jmVkEVRw; Mon, 3 Jan 2011 20:51:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C5D9E28423; Mon, 3 Jan 2011 20:50:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B65DE28423 for ; Mon, 3 Jan 2011 20:50:14 +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 kycHyG599JQF for ; Mon, 3 Jan 2011 20:50:02 +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-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTP id 87E8528316 for ; Mon, 3 Jan 2011 20:49:15 +0100 (CET) Received: by mail-fx0-f44.google.com with SMTP id 9so12889169fxm.3 for ; Mon, 03 Jan 2011 11:49:15 -0800 (PST) Received: by 10.223.72.202 with SMTP id n10mr7429596faj.74.1294084154994; Mon, 03 Jan 2011 11:49:14 -0800 (PST) Received: from helios.localdomain6 (d122-104-38-246.sbr6.nsw.optusnet.com.au [122.104.38.246]) by mx.google.com with ESMTPS id a6sm3124092fak.1.2011.01.03.11.49.11 (version=SSLv3 cipher=RC4-MD5); Mon, 03 Jan 2011 11:49:14 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Tue, 4 Jan 2011 06:46:51 +1100 Message-Id: <1294084016-2674-32-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.1.422.g049e9 In-Reply-To: <1294084016-2674-1-git-send-email-graeme.russ@gmail.com> References: <1294084016-2674-1-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [RFC][PATCH 31/36] x86 - Fix incorrect usage of relocation offset X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 -- x86 has always used relocation offset in the opposite sense to the ELF standard - Fix this --- arch/i386/cpu/start.S | 2 +- arch/i386/lib/board.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) -- 1.7.1.422.g049e9 diff --git a/arch/i386/cpu/start.S b/arch/i386/cpu/start.S index fd018bf..0031389 100644 --- a/arch/i386/cpu/start.S +++ b/arch/i386/cpu/start.S @@ -120,7 +120,7 @@ relocate_code: /* Setup call address of in-RAM copy of board_init_r() */ movl $board_init_r, %ebp - subl (GD_RELOC_OFF * 4)(%edx), %ebp + addl (GD_RELOC_OFF * 4)(%edx), %ebp /* Setup parameters to board_init_r() */ movl %edx, %eax diff --git a/arch/i386/lib/board.c b/arch/i386/lib/board.c index 2b06900..c77c206 100644 --- a/arch/i386/lib/board.c +++ b/arch/i386/lib/board.c @@ -216,7 +216,7 @@ void board_init_f (ulong boot_flags) addr_sp = dest_addr; dest_addr -= CONFIG_SYS_STACK_SIZE; dest_addr -= (bss_end - text_start); - rel_offset = text_start - dest_addr; + rel_offset = dest_addr - text_start; /* First stage CPU initialization */ if (cpu_init_f() != 0) @@ -235,8 +235,8 @@ void board_init_f (ulong boot_flags) *dst_addr++ = *src_addr++; /* Clear BSS */ - dst_addr = (ulong *)(bss_start - rel_offset); - end_addr = (ulong *)(bss_end - rel_offset); + dst_addr = (ulong *)(bss_start + rel_offset); + end_addr = (ulong *)(bss_end + rel_offset); while (dst_addr < end_addr) *dst_addr++ = 0x00000000; @@ -247,8 +247,8 @@ void board_init_f (ulong boot_flags) do { if (re_src->r_offset >= CONFIG_SYS_TEXT_BASE) - if (*(Elf32_Addr *)(re_src->r_offset - rel_offset) >= CONFIG_SYS_TEXT_BASE) - *(Elf32_Addr *)(re_src->r_offset - rel_offset) -= rel_offset; + if (*(Elf32_Addr *)(re_src->r_offset + rel_offset) >= CONFIG_SYS_TEXT_BASE) + *(Elf32_Addr *)(re_src->r_offset + rel_offset) += rel_offset; } while (re_src++ < re_end); gd->reloc_off = rel_offset;