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]

SH: forced local symbols


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.


Sigh... <insert long rant about the amount of pointless code duplication
between ELF targets, for things that are target-independent>.  I suspect
I'll be sending awfully similar looking patches for ARM in a couple of
days, when I get to it - unless by some luck ARM is unaffected, but a casual
glance is not encouraging.

I'm reasonably confident in this patch, but I'd like comments.

-- 
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 16:39:57 -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
@@ -4463,7 +4434,8 @@ sh_elf_relocate_section (output_bfd, inf
 
 	  if (h != NULL)
 	    {
 	      bfd_vma off;
+	      boolean dyn;
 
 	      off = h->got.offset;
 #ifdef INCLUDE_SHMEDIA
@@ -4476,12 +4447,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
@@ -5059,6 +5044,8 @@ sh_elf_check_relocs (abfd, info, sec, re
 
 	  if (h != NULL)
 	    {
+	      boolean dyn;
+
 #ifdef INCLUDE_SHMEDIA
 	      if (h->type == STT_DATALABEL)
 		{
@@ -5091,7 +5078,11 @@ 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.  */
+	      dyn = elf_hash_table (info)->dynamic_sections_created;
+	      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 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]