Problems about generating dynamic library using mipsisa32-elf target toolchain

Daniel Jacobowitz drow@false.org
Wed May 19 14:39:00 GMT 2004


On Wed, May 19, 2004 at 06:04:17PM +0800, Jie Zhang wrote:
> I have problems about generating dynamic library using mipsisa32-elf 
> target toolchain, including gcc-3.3.3 and binutils-2.14.
> 
> For the following simple code:
> 
>   /* t.c */
>   extern void bar ()
> 
>   void foo ()
>   {
>     bar ();
>   }
> 
> > mipsisa32-elf-gcc -fpic -c t.c
> 
> After this command, I get t.o.
> 
> There is a relocation in its .text section:
> 
> > mipsisa32-elf-readelf -r t.o
> 
> Relocation section '.rel.text' at offset 0x378 contains 1 entries:
>  Offset     Info    Type            Sym.Value  Sym. Name
> 0000000c  00000904 R_MIPS_26         00000000   bar
> 
> But after link, there is no relocation in the dynamic library.
> 
> > mipsisa32-elf-ld -shared -o t.so t.o
> > mipsisa32-elf-readelf -r t.so
> 
> readelf: Error: Unable to read in 263192 bytes of dynamic segment
> 
> There are no relocations in this file.
> 
> Now I have two questions:
> 
> 1. Why is there no relocation in the dynamic section? After all, there 
> is an undefined symbol in it.

This is a peculiarity of the MIPS ABI.  GOT relocations for the initial
GOT do not need explicit entries in .rel.dyn.

> 2. What is there an error when readelf t.so? What's wrong about it?

I have no idea.  It souns like ld produced a corrupt binary.

-- 
Daniel Jacobowitz



More information about the Binutils mailing list