From patchwork Tue Nov 23 18:48:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 72720 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 3A2D0B70AF for ; Wed, 24 Nov 2010 05:50:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6D3932826D; Tue, 23 Nov 2010 19:49: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 zRQ1VJxoBgMk; Tue, 23 Nov 2010 19:49:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 80C8B28236; Tue, 23 Nov 2010 19:49:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11D8D281E2 for ; Tue, 23 Nov 2010 19:49:24 +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 04DCdC2OdUvj for ; Tue, 23 Nov 2010 19:49:21 +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 gw1.transmode.se (gw1.transmode.se [213.115.205.20]) by theia.denx.de (Postfix) with ESMTPS id DE3C82821A for ; Tue, 23 Nov 2010 19:49:04 +0100 (CET) Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id 4E5F2650005 for ; Tue, 23 Nov 2010 19:49:04 +0100 (CET) Received: from gentoo-jocke.transmode.se ([192.168.1.15]) by sesr04.transmode.se (Lotus Domino Release 8.5.2 HF88) with ESMTP id 2010112319490442-51202 ; Tue, 23 Nov 2010 19:49:04 +0100 Received: from gentoo-jocke.transmode.se (gentoo-jocke.transmode.se [127.0.0.1]) by gentoo-jocke.transmode.se (8.14.4/8.14.0) with ESMTP id oANIn44q012448; Tue, 23 Nov 2010 19:49:04 +0100 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id oANIn4dx012447; Tue, 23 Nov 2010 19:49:04 +0100 From: Joakim Tjernlund To: "u-boot@lists.denx.de" Date: Tue, 23 Nov 2010 19:48:50 +0100 Message-Id: <1290538131-12383-6-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1290538131-12383-1-git-send-email-Joakim.Tjernlund@transmode.se> References: <1290538131-12383-1-git-send-email-Joakim.Tjernlund@transmode.se> X-MIMETrack: Itemize by SMTP Server on sesr04/Transmode(Release 8.5.2 HF88|October 08, 2010) at 2010-11-23 19:49:04, Serialize by Router on sesr04/Transmode(Release 8.5.2 HF88|October 08, 2010) at 2010-11-23 19:49:04, Serialize complete at 2010-11-23 19:49:04 Cc: Joakim Tjernlund Subject: [U-Boot] [PATCH 5/6] mpc83xx: Add true PIC support. 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 By copying the GOT to the end of the INIT_RAM(dcache) and relocating it there, it is much esier to support true PIC on u-boot. This cannot handle FIXUP so C code that depends on fixups before relocation to RAM must use LINK_OFF to calculate the difference. This depends on the upcoming single-pic-base option to gcc. --- arch/powerpc/cpu/mpc83xx/start.S | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S index 3d4e288..b24a89a 100644 --- a/arch/powerpc/cpu/mpc83xx/start.S +++ b/arch/powerpc/cpu/mpc83xx/start.S @@ -302,6 +302,34 @@ in_flash: /* Needed for upcoming -msingle-pic-base */ bl _GLOBAL_OFFSET_TABLE_@local-4 mflr r30 +#ifdef CONFIG_SYS_TRUE_PIC + /* + * Copy GOT to cache and relocate it + * This assumes there is enough space at the end + * INIT_RAM to hold a copy of the GOT. + */ + li r3,0 + bl link_off /* r3 holds link offset at return */ + lis r9, (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_END)@h + ori r9,r9,(CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_END)@l + lwz r11,GOT(_GOT2_TABLE_) + add r11,r11,r3 + + li r4, __got2_entries@sectoff@l + mtctr r4 + slwi r5,r4,2 /* r4 * 4 */ + subf r9,r5,r9 /* r9 - r5 */ + + subf r10,r9,r11 /* r11 - r9 */ + subf r30,r10,r30 /* r30 - r10, point PIC(r30) to new GOT */ + addi r11,r11,-4 + addi r9,r9,-4 +1: /* copy GOT and add link offset */ + lwzu r0,4(r11) + add r0,r0,r3 + stwu r0,4(r9) + bdnz 1b +#endif #endif /* r3: IMMR */ lis r3, CONFIG_SYS_IMMR@h @@ -869,9 +897,17 @@ relocate_code: bl _GLOBAL_OFFSET_TABLE_@local-4 mflr r30 #endif +#ifdef CONFIG_SYS_TRUE_PIC + li r3, 0 + bl link_off /* const void * link_off(const void *) */ +#endif lwz r4, GOT(_start) /* Source Address */ addi r4, r4, -EXC_OFF_SYS_RESET lwz r5, GOT(__bss_start) +#ifdef CONFIG_SYS_TRUE_PIC + add r4, r4, r3 /* Add link offset */ + add r5, r5, r3 /* Add link offset */ +#endif mr r3, r10 /* Destination Address */ sub r5, r5, r4