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]

ARM forced-local symbols


Has anyone else noticed that this seems to be one of the most fragile parts
of BFD?  Every time I move my embedded targets to a new linker release, I've
found at least one new problem with .hidden symbols whose GOT entries don't
get initialized.  I wish I could find a better way to centralize this.

This patch fixes such a problem on ARM.  Updates the code to be pretty much
in sync with the SH version.  This patch is appropriate for the 2.14 branch;
for head, SYMBOL_REFERENCES_LOCAL should probably be used instead.

Comments?  OK (with that change for HEAD)?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-07-31  Daniel Jacobowitz  <drow@mvista.com>

	* elf32-arm.h (WILL_CALL_FINISH_DYNAMIC_SYMBOL): Define.
	(elf32_arm_final_link_relocate, elf32_arm_relocate_section): Use it.

Index: elf32-arm.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/bfd/elf32-arm.h,v
retrieving revision 1.108
diff -u -p -r1.108 elf32-arm.h
--- binutils-2.14/bfd/elf32-arm.h	12 Jul 2003 11:16:46 -0000	1.108
+++ binutils-2.14/bfd/elf32-arm.h	31 Jul 2003 15:46:19 -0000
@@ -1038,6 +1038,18 @@ elf32_arm_to_thumb_stub (info, name, inp
   return TRUE;
 }
 
+/* This is the condition under which elf32_arm_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 elf32_arm_relocate_section
+   and elf32_arm_final_link_relocate.  */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H)			\
+  ((DYN)								\
+   && ((SHARED)							 	\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)	\
+   && ((H)->dynindx != -1						\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
 /* Perform a relocation as part of a final link.  */
 
 static bfd_reloc_status_type
@@ -1605,13 +1617,16 @@ elf32_arm_final_link_relocate (howto, in
       if (h != NULL)
 	{
 	  bfd_vma off;
+	  bfd_boolean dyn = elf_hash_table (info)->dynamic_sections_created;
 
 	  off = h->got.offset;
 	  BFD_ASSERT (off != (bfd_vma) -1);
 
-	  if (!elf_hash_table (info)->dynamic_sections_created ||
-	      (info->shared && (info->symbolic || h->dynindx == -1)
-	       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+	  if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+	      || (info->shared
+		  && (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 -Bsymbolic link
 		 and the symbol is defined locally.  We must initialize this
@@ -1991,12 +2006,13 @@ elf32_arm_relocate_section (output_bfd, 
 		  break;
 
 	        case R_ARM_GOT32:
-	          if (elf_hash_table(info)->dynamic_sections_created
-	              && (!info->shared
+	          if ((WILL_CALL_FINISH_DYNAMIC_SYMBOL
+		       (elf_hash_table(info)->dynamic_sections_created,
+			info->shared, h))
+		      && (!info->shared
 	                  || (!info->symbolic && h->dynindx != -1)
-	                  || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
-			  )
-		      )
+	                  || (h->elf_link_hash_flags
+			      & ELF_LINK_HASH_DEF_REGULAR) == 0))
 	            relocation_needed = 0;
 		  break;
 


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