From patchwork Wed May 14 22:05:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darwin Rambo X-Patchwork-Id: 30208 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6327C20446 for ; Wed, 14 May 2014 22:07:53 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id mc6sf103068lab.10 for ; Wed, 14 May 2014 15:07:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=hCYc/U7wSMy/o9KeF41b0vwHiDDoN9AMIljkrmbshNM=; b=PJFmG0C3TF/bc7w4b/UzOGNTLmtuLEXLvJRfhRHTVQc5PEt8JDjm3eSJbZ8I5Us25o 30RL5/wDZTybyGkvirfxsJJA33oafDxkfpFADXZLJ1i+RglHax/NSzgySZX5CRtP7fD4 BfuDkLMJcW+1RJ4SIaRpWtOTP0RHL2S6KuFldqnQD7x4yoUrqBXkN4cTYzQdOb/Ayfco oU5boBzZGXQoe/roFVGgkLYq4EUODPCDKTMkcMcsESaAYPL1KEUvcArs2xKEolR2Ut1D dv+TQep7pmLe7GSaVQHgghxUK97WAvSpYdOycB2tGeMmEiDKv6PzPm9WAxFAmQJBjOLJ pZvA== X-Gm-Message-State: ALoCoQl8kdhOHSMowr4EokdgQbmMfIGGFfCmSYA+Ty/hFEPLmQ28fWTFfQJ4YIZuiQdBqkciAKsS X-Received: by 10.112.219.42 with SMTP id pl10mr76100lbc.22.1400105271725; Wed, 14 May 2014 15:07:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.203 with SMTP id h69ls2671707qgh.56.gmail; Wed, 14 May 2014 15:07:51 -0700 (PDT) X-Received: by 10.58.186.207 with SMTP id fm15mr5021750vec.4.1400105271543; Wed, 14 May 2014 15:07:51 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id y16si555234vcl.142.2014.05.14.15.07.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 15:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lc6so3313180vcb.16 for ; Wed, 14 May 2014 15:07:51 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr5022637vcb.28.1400105270782; Wed, 14 May 2014 15:07:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp274537vcb; Wed, 14 May 2014 15:07:50 -0700 (PDT) X-Received: by 10.14.22.69 with SMTP id s45mr8561564ees.56.1400105269842; Wed, 14 May 2014 15:07:49 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id n46si2625651eeo.67.2014.05.14.15.07.49 for ; Wed, 14 May 2014 15:07:49 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D7D814BE63; Thu, 15 May 2014 00:07:48 +0200 (CEST) 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 Co7CV-8XjZ4T; Thu, 15 May 2014 00:07:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 73DF64BE80; Thu, 15 May 2014 00:07:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6A2A4BE80 for ; Thu, 15 May 2014 00:07:41 +0200 (CEST) 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 iaPMu6mp0LXK for ; Thu, 15 May 2014 00:07:36 +0200 (CEST) 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-gw1-out.broadcom.com (mail-gw1-out.broadcom.com [216.31.210.62]) by theia.denx.de (Postfix) with ESMTP id 8FC204BE63 for ; Thu, 15 May 2014 00:07:30 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.97,1054,1389772800"; d="scan'208";a="29757955" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 14 May 2014 16:26:07 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 14 May 2014 15:07:29 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Wed, 14 May 2014 15:07:29 -0700 Received: from mail.broadcom.com (dhcp-rmna-vpn-11.ric.broadcom.com [10.136.253.11]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id AA6509FF60; Wed, 14 May 2014 15:05:55 -0700 (PDT) From: Darwin Rambo To: Date: Wed, 14 May 2014 15:05:45 -0700 Message-ID: <1400105145-6628-1-git-send-email-drambo@broadcom.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Cc: Darwin Rambo Subject: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: drambo@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 If an earlier loader stage requires an image header and a specific offset, then u-boot's base address (CONFIG_SYS_TEXT_BASE) may be advanced beyond an aligned address. In this case the relocation will not be done correctly for some sections such as vectors and rodata string tables, which will show an incorrect offset after the symbols are fixed up. Advance the relocation address by the image offset so that the gd->reloc_off used will result in relocating these sections to their correct addresses. This change is done under CONFIG_ARM64 conditional compilation because it has only been tested there and may not be appropriate for other architectures. Signed-off-by: Darwin Rambo Reviewed-by: Steve Rae --- arch/arm/lib/board.c | 13 +++++++++++++ common/board_f.c | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 9b473b5..df520cc 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -449,6 +449,19 @@ void board_init_f(ulong bootflag) dram_init_banksize(); display_dram_config(); /* and display it */ +#ifdef CONFIG_ARM64 + /* + * Fix relocation if u-boot is not on an aligned address. + */ + { + int offset = CONFIG_SYS_TEXT_BASE % 4096; + if (offset) { + addr += offset; + debug("Relocation Addr bumped to 0x%08lx\n", addr); + } + } +#endif + gd->relocaddr = addr; gd->start_addr_sp = addr_sp; gd->reloc_off = addr - (ulong)&_start; diff --git a/common/board_f.c b/common/board_f.c index 4ea4cb2..1035d6f 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -728,6 +728,16 @@ static int reloc_fdt(void) static int setup_reloc(void) { +#ifdef CONFIG_ARM64 + /* + * Fix relocation if u-boot is not on an aligned address. + */ + int offset = CONFIG_SYS_TEXT_BASE % 4096; + if (offset) { + gd->relocaddr += offset; + debug("Relocation Addr bumped to 0x%08lx\n", gd->relocaddr); + } +#endif gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE; memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));