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: SH: forced local symbols


On Thu, Aug 22, 2002 at 01:02:54PM -0400, Daniel Jacobowitz wrote:
> The first of two patches to bring SH up to date in some changes since it was
> contributed.  This one is for forced local symbols.  We can't allocate
> relocation space for them if they aren't going to need relocations, and we
> need to handle them in sh_elf_relocate_sections if the runtime linker won't
> do it.  Based on the similar changes to elf32-sparc.c in April.

That patch wasn't quite right; I checked created_dynamic_sections
before it was necessarily set.  Here's an update; this should probably
be taken together with Stephen's zalloc patch, since it now could
potentially allocate more relocation slots than necessary.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2002-08-22  Daniel Jacobowitz  <drow@mvista.com>

	* elf32-sh.c (WILL_CALL_FINISH_DYNAMIC_SYMBOL): Define.
	(sh_elf_relocate_section):  Call it.  Check ELF_LINK_FORCED_LOCAL.
	(sh_elf_check_relocs): Call it.

Index: elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.53
diff -u -p -r1.53 elf32-sh.c
--- elf32-sh.c	16 Aug 2002 18:40:54 -0000	1.53
+++ elf32-sh.c	22 Aug 2002 19:19:51 -0000
@@ -3971,6 +3971,17 @@ sh_elf_discard_copies (h, ignore)
   return true;
 }
 
+/* This is the condition under which finish_dynamic_symbol will be called
+   from elflink.h.  If elflink.h doesn't call our finish_dynamic_symbol
+   routine, we'll need to do something about initializing any .plt and .got
+   entries in relocate_section.  */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H)		       \
+  ((DYN)							       \
+   && ((INFO)->shared						       \
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)     \
+   && ((H)->dynindx != -1					       \
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
 /* Relocate an SH ELF section.  */
 
 static boolean
@@ -4464,6 +4475,7 @@ sh_elf_relocate_section (output_bfd, inf
 	  if (h != NULL)
 	    {
 	      bfd_vma off;
+	      boolean dyn;
 
 	      off = h->got.offset;
 #ifdef INCLUDE_SHMEDIA
@@ -4476,12 +4488,13 @@ sh_elf_relocate_section (output_bfd, inf
 		}
 #endif
 	      BFD_ASSERT (off != (bfd_vma) -1);
+	      dyn = elf_hash_table (info)->dynamic_sections_created;
 
-	      if (! elf_hash_table (info)->dynamic_sections_created
+	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
 		  || (info->shared
-		      && (info->symbolic || h->dynindx == -1
-			  || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
-			  || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
+		      && (info->symbolic
+			  || h->dynindx == -1
+			  || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
 		      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
 		{
 		  /* This is actually a static link, or it is a
@@ -5091,7 +5104,12 @@ sh_elf_check_relocs (abfd, info, sec, re
 		    return false;
 		}
 
-	      srelgot->_raw_size += sizeof (Elf32_External_Rela);
+	      /* If the symbol is still dynamic allocate space for the
+		 relocation.  We have to use true instead of the correct
+		 dynamic_sections_created, because we don't know if they've
+		 been created yet.  */
+	      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (true, info, h))
+		srelgot->_raw_size += sizeof (Elf32_External_Rela);
 	    }
 	  else
 	    {


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