strange problem with relocation

Fri Aug 5 15:11:00 GMT 2005


For the code given:

           .section .data
           .p2align 2, 0
           .global _buff
           .word 0x0000
            .section .data
            .p2align 2, 0
            .global _ipts
            .word 0x1234
            .word 0x5678
            .word 0x9abc
            .word 0x0000
            .section .text._main, "ax"
            .p2align 2, 0
            .global  _main
            .type     _main, @function

            ld a12, _ipts+2
            ldw r12, @[a12]
            jmp       a14

I got the file assembled and then dumped as follows (objdump -DSx a.o):

00000000 <_main>:
   0:      ac 80 00 06       _main:
           ld A12, 0x6
                             2: R_C_IMM22       _ipts+0x6
   4:      87 e6             jmp A14

Here relocation has received wrong offset (0x6) whereas during fixup segment
fixp->fx_offset == 2 (I check it in md_apply_fix(). I set fixp->fx_done to 0
As result relocation points to wrong address.

If I write 'ld a12, _ipts' everything seems to be Ok: '2: R_C_IMM22
If I do not declare _ipts as global the result is correct as well '2:
R_C_IMM22       .data+0x6'.

I found that symbol _ipts receives an extra offset in
bfd_install_relocation() as
	reloc_entry->addend = relocation;
	relocation = symbol->value;

Do I have to handle global symbols within one file different than usual?

Thanks in advance,

More information about the Binutils mailing list