Bug 10853 - Relocations for ppc assembler apply to entire field argument
Summary: Relocations for ppc assembler apply to entire field argument
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-27 17:14 UTC by Chris Constantine
Modified: 2009-10-28 11:09 UTC (History)
2 users (show)

See Also:
Host: ppc-unknown-linux-gnu
Target: ppc-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Constantine 2009-10-27 17:14:26 UTC
Given an assembly file like:

*** asm file ***
.global foo
lis 3, foo@h+4
****************

When I assemble and run objdump I get:

*** as/objdump output ***
$ as -o test.o test.s && objdump -Dr test.o                                                    

test.o:     file format elf32-powerpc
Disassembly of section .text:

00000000 <l1>:
   0:   3c 60 00 00     lis     r3,0
                        2: R_PPC_ADDR16_HI      foo+0x8
*************************

It appears that the relocation is being applied to the result of '<address of foo> + 0x8'.  My understanding 
is that the immediate field of the 'lis' should have a value of 0x8 and the relocation should only apply to 
'foo'.  The output I expect would look like:

*** expected as/objdump output ***
$ as -o test.o test.s && objdump -Dr test.o                                                    

test.o:     file format elf32-powerpc
Disassembly of section .text:

00000000 <l1>:
   0:   3c 60 00 08     lis     r3,8
                        2: R_PPC_ADDR16_HI      foo
**********************************

I'm using ubuntu jaunty ppc.  My binutils package is version '2.19.1-0ubuntu3'.  Is this a problem with my 
understanding of how arguments in ppc assembly should be parsed, or in the way gas does assembly?
Comment 1 Andreas Schwab 2009-10-27 20:08:15 UTC
Powerpc uses RELA relocations where the addend is stored in the relocation 
entry.
Comment 2 Chris Constantine 2009-10-28 11:09:43 UTC
Thanks for the quick clarification.