From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com [32.97.182.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e2.ny.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id ECBEDDDE03 for ; Tue, 22 Jul 2008 14:37:41 +1000 (EST) Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e2.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id m6M4bcmg001113 for ; Tue, 22 Jul 2008 00:37:38 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m6M4bcQp226696 for ; Tue, 22 Jul 2008 00:37:38 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m6M4bbgR032179 for ; Tue, 22 Jul 2008 00:37:37 -0400 Message-ID: <48856403.5050207@in.ibm.com> Date: Tue, 22 Jul 2008 10:07:23 +0530 From: Mohan Kumar M MIME-Version: 1.0 To: Paul Mackerras Subject: Re: [RFC v3 PATCH 6/4] Use LOAD_REG_IMMEDIATE macros References: <20080717183339.GA25070@in.ibm.com> <20080717184055.GB25070@in.ibm.com> <1216325187.7740.353.camel@pasglop> <48802AE0.30105@in.ibm.com> <4884E2E9.6050108@in.ibm.com> <18565.16369.993585.334427@cargo.ozlabs.ibm.com> In-Reply-To: <18565.16369.993585.334427@cargo.ozlabs.ibm.com> Content-Type: text/plain; charset=us-ascii; format=flowed Cc: naren@linux.vnet.ibm.com, Milton Miller , ppcdev List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Paul Mackerras wrote: > Mohan Kumar M writes: > > @@ -714,7 +714,7 @@ _GLOBAL(enter_rtas) > std r6,PACASAVEDMSR(r13) > > /* Setup our real return addr */ > - LOAD_REG_ADDR(r4,.rtas_return_loc) > + LOAD_REG_IMMEDIATE(r4,.rtas_return_loc) > > If LOAD_REG_ADDR doesn't work, then how are all the TOC loads in > gcc-generated code going to work? > Hi Paul, We have a problem only when there is a reference to a variable through got. Following mail sent to Segher yesterday may explain it. I was going through the output generated by objdump -D vmlinux and readelf -h vmlinux. Disassembly of section .got: c000000000805010 <__toc_start>: c000000000805010: c0 00 00 00 lfs f0,0(0) c000000000805014: 00 80 d0 10 .long 0x80d010 c000000000805018: c0 00 00 00 lfs f0,0(0) c00000000080501c: 00 00 83 58 .long 0x8358 c000000000805020: c0 00 00 00 lfs f0,0(0) c000000000805024: 00 85 1f e8 .long 0x851fe8 c000000000805028: c0 00 00 00 lfs f0,0(0) c00000000080502c: 00 00 8d 84 .long 0x8d84 c000000000805030: c0 00 00 00 lfs f0,0(0) c000000000805034: 00 85 03 38 .long 0x850338 c000000000805038: c0 00 00 00 lfs f0,0(0) c00000000080503c: 00 85 28 b8 .long 0x8528b8 c000000000805040: c0 00 00 00 lfs f0,0(0) c000000000805044: 00 85 28 b0 .long 0x8528b0 c000000000805048: c0 00 00 00 lfs f0,0(0) c00000000080504c: 00 6d ef 60 .long 0x6def60 All of the variables references through @got translated into relocation type R_PPC64_GOT16_DS entries. All these entries correspond to one of the above entries in the .got section. But none of the entries in .got section are relocated. For example the instruction with relocation type R_PPC64_GOT16_DS, c00000000000830c: e8 62 80 10 ld r3,-32752(r2) refers to current_set variable. r2 will be pointing to 0xc00000000280d010 (relocated __toc_start + 0x8000). So the instruction loads r3 with the content 0xc000000000851fe8 at location 0xc000000002805020, but which is not a relocated entry (0xc000000000851fe8) But when there is a relocation type of R_PPC64_ADDR16_HI, like c000000000008110: 64 84 00 00 oris r4,r4,0 we could easily get more info about this relocation from readelf like: c000000000008112 000100000005 R_PPC64_ADDR16_HI c000000000000000 .text + 8124 So from above output we can identify that instruction at address c000000000008112 needs to be patched with the relocation delta. Now I have two options left: 1. Check for R_PPC64_GOT16_DS entries and check whether the contents addressed by r2+offset is relocated or not and apply relocation if its not. 2. Change all LOAD_REG_ADDR macros to LOAD_REG_IMMEDIATE. This I have already done. Regards, Mohan.