This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with pcrel relocs and addends


 
> > RELOCATION RECORDS FOR [.text]:
> > OFFSET   TYPE              VALUE
> > 00000000 R_META_RELBRANCH  __func2
> > 00000004 R_META_RELBRANCH  __func1+0xfffffffc
> 
> That appears to be correct, as long as the offset that the 
> CALLR insn expects is relative to the value of the PC after 
> the insn.  If you put something between the first CALLR and 
> the __func2 label you should see the first addend to increase 
> and the second addend to decrease by the same amount.

Thanks for your rapid response. :-)

The first reloc will never have an addend unless I add an explicit one,
e.g. CALLR D1RtP,__func1+4. The second reloc always has an addend and I
don't see why (I do actually want the value of __func1, not __func1 +
the negative offset to __func1). Here's the same example with a couple
of NOPs. Does this seem OK to you?

.text
        .global __func1
        .type __func1,function
__func1:
    CALLR D1RtP,__func2
    NOP
    NOP
    NOP

        .global __func2
        .type __func2,function
__func2:
    CALLR D1RtP,__func1

objdump -r:

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000000 R_META_RELBRANCH  __func2
00000010 R_META_RELBRANCH  __func1+0xfffffff0

If I change the first CALLR to "CALLR D1RtP,__func2+4" I get:

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000000 R_META_RELBRANCH  __func2+0x00000004
00000010 R_META_RELBRANCH  __func1+0xfffffff0

Which I read as:

At address 0x0, get the value of __func2, add 4 to it and fixup the
instruction with that value.
At address 0x10, get the value of __func1, add -16 to it and fixup the
instruction with that value.

The second is wrong in that case. Which suggests that either I am
misinterpreting what the addend field means, or cgen is doing something
a bit odd.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]