This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][ARM] Fix handling of GOT_PREL in gas.
gas handles your test case without no problems because i and . are in
the same section. This fails on powerpc as well.
.section .text.i,"x"
i:
.long 0
.section .text.j,"x"
j:
.long i + (. - (.LPIC0 + 4))
.long 0
.LPIC0:
$ ../obj/gas/as-new fwdexp.s
fwdexp.s: Assembler messages:
fwdexp.s:7: Error: operation combines symbols in different segments
在 2010年9月16日上午3:12,Alan Modra <amodra@gmail.com> 寫道:
> On Thu, Sep 16, 2010 at 10:24:57AM +0100, Richard Earnshaw wrote:
>> On Thu, 2010-09-16 at 01:44 -0700, Doug Kwan (關振德) wrote:
>> > Hi
>> >
>> > This patch fixes a problem in which gas fails to assemble data
>> > expression in the form:
>> >
>> > symbol(GOT_PREL) + (. - (.LPIC0 + 4))
>> >
>> > where .LPIC0 is a local label defined in the same function after the
>> > data expression. Currently, LPIC0 is undefined when the data
>> > expression is processed and that causes an error in the function
>> > expr() because the two operands of the addition have different
>> > segments.
> [snip]
>>
>> This really sounds to me like something that should be handled in a more
>> generic way than a special-case hack in the back-end.
>
> Other targets don't have a problem assembling expressions like this.
>
> $ cat /src/tmp/fwdexp.s
> .text
> .long i + (. - (.LPIC0+4))
> .long 0
> .LPIC0:
> $ gas/as-new /src/tmp/fwdexp.s
> $ binutils/objdump -dr a.out
>
> a.out: file format elf32-powerpc
>
>
> Disassembly of section .text:
>
> 00000000 <.text>:
> 0: ff ff ff f4 .long 0xfffffff4
> 0: R_PPC_ADDR32 i+0xfffffff4
> 4: 00 00 00 00 .long 0x0
>
> --
> Alan Modra
> Australia Development Lab, IBM
>