This is the mail archive of the binutils@sources.redhat.com 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]

Problem with relocation records (PowerPC)


I am having some problems with relocations when linking with pre-compiled
libraries built with a compiler other than GCC. In these libraries, relocation
records of type R_PPC_EMB_SDA21 point to addresses two bytes after the start of
the instruction to which they apply. When GNU ld encounters one of these
relocation records, the address in the instruction is always relocated to an
offset of +13 from r0, and the next instruction is corrupted. For example, the
following unlinked code (_SDA_BASE_ is 0x8003a0a0 and __DBInterface is at
0x800323c0 in section .sbss):

      28:   80 60 00 00       lwz r3,0(r0)
                  2a: R_PPC_EMB_SDA21 __DBInterface
      2c:   28 03 00 00       cmplwi r3,0

may give the following when linked:

8002af98:   80 60 00 0d       lwz r3,13(r0)
8002af9c:   83 20 00 00       lwz r25,0(r0)

The address of __DBInterace should be an offset of 0x800323c0-0x8003a0a0 (0x8320
or -31968 in decimal) from r13, so the result of this relocation should be to
change the instruction "lwz r3,0(r0)" to "lwz r3,-31968(r13)". It appears that
the bits affected by this change have been computed correctly, but written as if
the original instruction were at the address pointed to by the relocation
record. The libraries contain other types of relocation record (R_PPC_ADDR16_HA
and R_PPC_ADDR16_LO) that point to addresses two bytes after the start of the
instruction, but these relocate correctly. Is this a bug in GNU ld, or does GNU
ld require R_PPC_EMB_SDA21 records to point to the first byte of the
instruction? If the latter, is there a tool for adjusting the addresses of
relocation records in pre-compiled libraries?
--
Paul Mikell
Rare Ltd                Telephone: +44 (0) 1827 883 400
Manor Park
Twycross, Warwickshire  Fax:       +44 (0) 1827 883 410
CV9 3QN, England


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