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]

Problem with pcrel relocs and addends


Hi, I have a problem with an as-yet unreleased binutils port (2.16.1).
Our assembler is built with cgen, so this may be related to that. We are
using ELF with RELA relocs.

The addend field of a PC relative reloc is usually zero unless the
symbol has been globally defined previously in the same file, in which
case it is set to the PC relative offset of the symbol. Is this correct?

This situation makes it difficult when linking because the addend is
then not something to be added but the actual value of the relocation
(in the case when we have seen the symbol definition), or 0 (in the case
when we haven't seen the symbol yet) in which case we have to compute
the value of the relocation. My understanding was that the addend could
be simply added in, and it looks like the cgen assembler is putting an
incorrect value in the addend field. Or am I confused here?

An example:

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

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

Objdump -r:

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


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