From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23249 invoked by alias); 25 Jul 2006 12:53:32 -0000 Received: (qmail 23083 invoked by uid 22791); 25 Jul 2006 12:53:30 -0000 X-Spam-Check-By: sourceware.org Received: from shell4.BAYAREA.NET (HELO shell4.bayarea.net) (209.128.82.1) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Jul 2006 12:53:25 +0000 Received: from [192.168.20.7] (209-128-106-254.bayarea.net [209.128.106.254]) (authenticated bits=0) by shell4.bayarea.net (8.13.6/8.13.6) with ESMTP id k6PCqGMt007868; Tue, 25 Jul 2006 05:52:16 -0700 Message-ID: <44C613FF.6060101@eagercon.com> Date: Tue, 25 Jul 2006 12:53:00 -0000 From: Michael Eager User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Richard Earnshaw CC: Santosh , binutils@sourceware.org Subject: Re: Multiple relocation in ELF References: <000001c6af0f$4a9a8a50$eb00a8c0@santosh> <20060724140259.GE6872@bubble.grove.modra.org> <44C510D3.5020702@eagercon.com> <1153830663.2040.54.camel@pc960.cambridge.arm.com> In-Reply-To: <1153830663.2040.54.camel@pc960.cambridge.arm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00299.txt.bz2 Richard Earnshaw wrote: > On Mon, 2006-07-24 at 19:26, Michael Eager wrote: >> Alan Modra wrote: >>> On Mon, Jul 24, 2006 at 04:22:41PM +0530, Santosh wrote: >>>> ADDIU r2, RELOCATABLE_SYMBOL + RELOCATABLE_SYMBOL >>>> >>>> In ELF, we can emit relocation information for only one symbol having >>>> its symbol index, offset and relocation value to apply. But when I try >>>> to give more than one relocatable symbol, it cannot be represented by >>>> ELF format. >>> ELF can support multiple symbols in a relocation expression. The trick >>> is to apply multiple suitably defined relocations to the one location. >> Alan -- >> >> Can you give an example of how this might be done? I don't think that >> it is possible to apply two relocations to a single location in ELF. >> >> I can think of one way that this might work, but it's problematic: >> >> If the relocations are in REL format, the addend is saved in the >> object file. (If RELA is used, the addend is in the reloc entry.) >> In either case, it seems that the result value from the first >> relocation will computed and stored in the output, then overwritten >> by the computation of the second relocation. The only way that >> these two relocations could be composed is if REL format is used, >> and the result of the relocation overwrote the value in the *input* >> object file, so that the result value from the first relocation >> is used as the addend of the second. >> >> If this is the scheme, I don't think that this behavior is defined >> by the ELF spec. > > The ELF spec is pretty specific on this issue. It's known as a composed > sequence > > - Multiple relocations on the same place must all be of the same type > (all REL or all RELA). > - Composed relocations are processed in order in the table > - The initial addend for the first relocation in the sequence is > extracted as normal > - Subsequent relocations use the result of the previous relocation > calculation as the initial addend value. > > The result is only written back at the end of the composed sequence. > > Note, however, that since all relocations are machine specific the rules > can be varied somewhat. In particular a relocation code can be > specified to terminate a sequence or to start a new one. Thanks. You're right -- it is specified in the ELF 4.1 draft. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077