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]

strange problem with relocation


Fellows,

For the code given:

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

_main:
            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
there).
As result relocation points to wrong address.

If I write 'ld a12, _ipts' everything seems to be Ok: '2: R_C_IMM22
_ipts'
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;
where
	relocation = symbol->value;

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

Thanks in advance,
Dmitry.




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