This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

Re: [RFC] unify dynamic_symbol_p implementations


On Friday 18 July 2003 03:21 pm, Richard Henderson wrote:
> On Fri, Jul 18, 2003 at 03:16:12PM -0700, Bob Wilson wrote:
> > Right.  We always set -fpic for Xtensa/Linux.
>
> Ah, ok.  In which case you shouldn't have any problems.
> I've already committed the patch (with ia64 fixed), so
> you should just do the s/0/1/ and update the commentary.

OK.  While I was at it, I made xtensa_elf_dynamic_symbol_p an inline function 
and swapped the order of its arguments to match _bfd_elf_dynamic_symbol_p.  I 
committed the following patch on the mainline.

2003-07-23  Bob Wilson  <bob.wilson@acm.org>

        * elf32-xtensa.c (xtensa_elf_dynamic_symbol_p): Make inline and move
        near the beginning of the file.  Swap order of arguments.  Call
        _bfd_elf_dynamic_symbol_p with "ignore_protected" set to 0.
        (elf_xtensa_fix_refcounts): Adjust xtensa_elf_dynamic_symbol_p call.
        (elf_xtensa_relocate_section): Likewise.
        (shrink_dynamic_reloc_sections): Likewise.

Index: elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-xtensa.c
--- elf32-xtensa.c	24 Jul 2003 00:13:42 -0000	1.7
+++ elf32-xtensa.c	24 Jul 2003 00:14:08 -0000
@@ -102,6 +102,8 @@ static bfd_boolean elf_xtensa_new_sectio
 
 /* Local helper functions.  */
 
+static bfd_boolean xtensa_elf_dynamic_symbol_p
+  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
 static int property_table_compare
   PARAMS ((const PTR, const PTR));
 static bfd_boolean elf_xtensa_in_literal_pool
@@ -131,8 +133,6 @@ static void do_fix_for_relocatable_link
   PARAMS ((Elf_Internal_Rela *, bfd *, asection *));
 static void do_fix_for_final_link
   PARAMS ((Elf_Internal_Rela *, asection *, bfd_vma *));
-static bfd_boolean xtensa_elf_dynamic_symbol_p
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 static bfd_vma elf_xtensa_create_plt_entry
   PARAMS ((bfd *, bfd *, unsigned));
 static int elf_xtensa_combine_prop_entries
@@ -449,6 +449,21 @@ static const bfd_byte elf_xtensa_le_plt_
   0			/* unused */
 };
 
+
+static inline bfd_boolean
+xtensa_elf_dynamic_symbol_p (h, info)
+     struct elf_link_hash_entry *h;
+     struct bfd_link_info *info;
+{
+  /* Check if we should do dynamic things to this symbol.  The
+     "ignore_protected" argument need not be set, because Xtensa code
+     does not require special handling of STV_PROTECTED to make function
+     pointer comparisons work properly.  The PLT addresses are never
+     used for function pointers.  */
+
+  return _bfd_elf_dynamic_symbol_p (h, info, 0);
+}
+
 
 static int
 property_table_compare (ap, bp)
@@ -1063,7 +1078,7 @@ elf_xtensa_fix_refcounts (h, arg)
   if (h->root.type == bfd_link_hash_warning)
     h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-  if (! xtensa_elf_dynamic_symbol_p (info, h))
+  if (! xtensa_elf_dynamic_symbol_p (h, info))
     elf_xtensa_make_sym_local (info, h);
 
   /* If the symbol has a relocation outside the GOT, set the
@@ -1830,17 +1845,6 @@ elf_xtensa_create_plt_entry (dynobj, out
 }
 
 
-static bfd_boolean
-xtensa_elf_dynamic_symbol_p (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-{
-  /* ??? What, if anything, needs to happen wrt STV_PROTECTED and PLT
-     entries?  For now assume the worst.  */
-  return _bfd_elf_dynamic_symbol_p (h, info, 1);
-}
-
-
 /* Relocate an Xtensa ELF section.  This is invoked by the linker for
    both relocatable and final links.  */
 
@@ -2067,7 +2071,7 @@ elf_xtensa_relocate_section (output_bfd,
       /* Generate dynamic relocations.  */
       if (elf_hash_table (info)->dynamic_sections_created)
 	{
-	  bfd_boolean dynamic_symbol = xtensa_elf_dynamic_symbol_p (info, h);
+	  bfd_boolean dynamic_symbol = xtensa_elf_dynamic_symbol_p (h, info);
 
 	  if (dynamic_symbol && (r_type == R_XTENSA_OP0
 				 || r_type == R_XTENSA_OP1
@@ -4963,7 +4967,7 @@ shrink_dynamic_reloc_sections (info, abf
   else
     h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 
-  dynamic_symbol = xtensa_elf_dynamic_symbol_p (info, h);
+  dynamic_symbol = xtensa_elf_dynamic_symbol_p (h, info);
 
   if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
       && (input_section->flags & SEC_ALLOC) != 0

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