This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: GNU linker and Function stubs on mips.
- To: Ian Lance Taylor <ian at zembu dot com>
- Subject: Re: GNU linker and Function stubs on mips.
- From: Koundinya K <knk at dde dot dk>
- Date: Fri, 03 Mar 2000 07:34:42 -0700
- CC: binutils at sourceware dot cygnus dot com, mark at codesourcery dot com
- Organization: DDE
- References: <38B88B26.6E668A35@dde.dk> <20000227024222.12298.qmail@daffy.airs.com> <38BB0D4A.B3CBF1FD@dde.dk> <20000229004038.1453.qmail@daffy.airs.com> <38BD6CC4.4602BA0E@dde.dk> <38BEC110.284D2E0F@dde.dk> <20000303023346.589.qmail@daffy.airs.com>
Hi Ian & Mark,
Ian Lance Taylor wrote:
> Date: Thu, 02 Mar 2000 12:29:20 -0700
> From: Koundinya K <knk@dde.dk>
>
> *************** _bfd_mips_elf_adjust_dynamic_symbol (inf
> *** 7612,7618 ****
>
> /* For a function, create a stub, if needed. */
> if (h->type == STT_FUNC
> ! || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
> {
> if (! elf_hash_table (info)->dynamic_sections_created)
> return true;
> --- 7708,7714 ----
>
> /* For a function, create a stub, if needed. */
> if (h->type == STT_FUNC
> ! && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
> {
> if (! elf_hash_table (info)->dynamic_sections_created)
> return true;
> *************** _bfd_mips_elf_adjust_dynamic_symbol (inf
> *** 7642,7647 ****
> --- 7738,7751 ----
> return true;
> }
> }
> + else if (h->type == STT_FUNC
> + && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
> + {
> + /* This will set the entry for this symbol in the GOT to 0, and
> + the dynamic linker will take care of this */
> + h->root.u.def.value = 0;
> + return true;
> + }
>
> Please provide your views on this change.
>
> I think the first test can be for ELF_LINK_HASH_NEEDS_PLT only. I
> don't think we need to test for STT_FUNC at all.
>
Yes you are right. In fact even in the second test we don't need to test for
STT_FUNC at all.
*************** _bfd_mips_elf_adjust_dynamic_symbol (inf
*** 7611,7618 ****
hmips->possibly_dynamic_relocs);
/* For a function, create a stub, if needed. */
! if (h->type == STT_FUNC
! || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
{
if (! elf_hash_table (info)->dynamic_sections_created)
return true;
--- 7707,7713 ----
hmips->possibly_dynamic_relocs);
/* For a function, create a stub, if needed. */
! if ( (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
{
if (! elf_hash_table (info)->dynamic_sections_created)
return true;
*************** _bfd_mips_elf_adjust_dynamic_symbol (inf
*** 7642,7647 ****
--- 7737,7749 ----
return true;
}
}
+ else
+ {
+ /* This will set the entry for this symbol in the GOT to 0, and
+ the dynamic linker will take care of this */
+ h->root.u.def.value = 0;
+ return true;
+ }
because in libstdc++.so generated bt GNU linker, cout is defined to be a
object. I don't understand why it has to put cout as an object type.
[187324] |0x60070e54|0x00000028|OBJT |GLOB |0 |65282 |cout
So the second change was failing. cout happens to be GOT16 reloc in hello.o
and again it does not need a stub and also the fact that it is defined in the
shared library.
So I feel it is better to check against whether a symbol requires a PLT or
not.
>
> However, I'm not convinced that it will always work. If a symbol has
> both call relocations and ordinary relocations, then I think that
> NEEDS_PLT will be set, but we want to set the dynamic symbol table
> entry to 0. Try something like this with the native tools and with
> your linker, to see what happens:
> extern int foo ();
> int (*pfn) = foo;
> int bar () { return foo (); }
>
I did not quite understand this. Here is the objdump -r of the above you
asked me to check. I just wrote a main and tried to link main.o and ruf.o. I
got undefined references to foo. I am not sure what I am supposed to do.
Please clarify ? What results from the Linker am I supposed to expect ??
halfway:2708 [knk/work/hello] objdump -r ruf.o
ruf.o: file format elf32-tradbigmips
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_MIPS_HI16 _gp_disp
00000004 R_MIPS_LO16 _gp_disp
00000024 R_MIPS_GOT16 foo
RELOCATION RECORDS FOR [.data]:
OFFSET TYPE VALUE
00000000 R_MIPS_32 foo
Thanks a lot.
koundinya