Resolving External References
Nick Clifton
nickc@redhat.com
Thu Mar 27 17:33:00 GMT 2003
Hi Savi,
> > * What version of binutils are you using ? What target are the
> > binutils targeted at, (if it is different from your host) ?
> I am using Algor MIPS cross-compler, release 4.0c ( SDE-MIPS )
This does not really help. Which version of binutils is used in the
Algor MIPS cross-compiler ? (ie what does "ld --version" report ?)
Also if this is a cross compiler supplied by a company called Algor,
why are you not asking them to solve this problem for you ?
> gcc -c -EL -fpic -o a.o fun1.c
> gcc -c -EL -fpic -o b.o fun2.c
> ld -verbose -i -EL -fpic -o mytest.elf -defsym __start=0xbfc00000
> -Tmyapp_lnk a.o b.o
The problem is that you are creating a relocatable application. This
means that the executable binary still contains relocations that need
to be resolved by the loader. If you run "objdump -dr mytest.elf" you
will see things like this:
Disassembly of section .BOOT:
bfc00000 <myfunc>:
bfc00000: 27bdfff0 addiu sp,sp,-16
bfc00004: afbf000c sw ra,12(sp)
bfc00008: afbe0008 sw s8,8(sp)
bfc0000c: 0c000000 jal b0000000 <x+0x2fffdf84>
bfc0000c: R_MIPS_26 foo
bfc00010: 03a0f021 move s8,sp
So the JAL instruction at 0xbfc0000c has an R_MIPS_26 relocation
associated with it, which when resolved, will make the instruction
jump to the (relocated) address of "foo".
This is normal behaviour. If you are having problems it must be
because the loader that you are using is not resolving or
understanding the relocations embedded in the mytest.elf binary.
Cheers
Nick
More information about the Binutils
mailing list