This is the mail archive of the binutils@sourceware.cygnus.com 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]

Re: GNU linker and Function stubs on mips.


   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.

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 guess the second change is correct, although I'm having a bit of
trouble convincing myself.

Mark, what would these patches do on Irix 6?  Should they be
conditional on IRIX_COMPAT somehow?  It seems to me that they are MIPS
ELF ABI compliant.

Ian

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