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: mn10300 dynamic relocation clean up: remove dynamic PCREL32


On Jun 29, 2004, Alan Modra <amodra@bigpond.net.au> wrote:

> On Mon, Jun 28, 2004 at 04:55:10AM -0300, Alexandre Oliva wrote:
>> This patch introduces ELF_LINK_HASH_COMMON, set for symbols read in as
>> common symbols.  This bit remains set after the linker turns the

> I don't think you need this.  A symbol that was commonl can be detected
> after lang_common has run using existing flags, like so

>   was_common = ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
> 		&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
> 		&& h->root.type == bfd_link_hash_defined);

Thanks for the suggestion.  Ok to install this?

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* elf-bfd.h (ELF_COMMON_DEF_P): New.
	* elflink.c (_bfd_elf_symbol_refs_local_p): Use it to handle
	common definitions.
	* elf-m10300.c: Use SYMBOL_REFERENCES_LOCAL instead of
	_bfd_elf_symbol_refs_local_p.
	* elf32-frv.c (FRVFDPIC_SYM_LOCAL): Remove hack for common
	symbols.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf-bfd.h,v
retrieving revision 1.146
diff -u -p -r1.146 elf-bfd.h
--- bfd/elf-bfd.h 6 Jul 2004 16:58:41 -0000 1.146
+++ bfd/elf-bfd.h 8 Jul 2004 05:40:11 -0000
@@ -218,6 +218,13 @@ struct elf_link_hash_entry
 #define SYMBOL_CALLS_LOCAL(INFO, H) \
   _bfd_elf_symbol_refs_local_p (H, INFO, 1)
 
+/* Common symbols that are turned into definitions don't have the
+   DEF_REGULAR flag set, so they might appear to be undefined.  */
+#define ELF_COMMON_DEF_P(H) \
+  (((H)->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0		\
+   && ((H)->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0	\
+   && (H)->root.type == bfd_link_hash_defined)
+
 /* Records local symbols to be emitted in the dynamic symbol table.  */
 
 struct elf_link_local_dynamic_entry
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf-m10300.c,v
retrieving revision 1.55
diff -u -p -r1.55 elf-m10300.c
--- bfd/elf-m10300.c 27 Jun 2004 03:02:21 -0000 1.55
+++ bfd/elf-m10300.c 8 Jul 2004 05:40:13 -0000
@@ -1020,7 +1020,7 @@ mn10300_elf_final_link_relocate (howto, 
       if (info->shared
 	  && (input_section->flags & SEC_ALLOC) != 0
 	  && h != NULL
-	  && ! _bfd_elf_symbol_refs_local_p (h, info, 1))
+	  && ! SYMBOL_REFERENCES_LOCAL (info, h))
 	return bfd_reloc_dangerous;
     }
 
@@ -1079,7 +1079,7 @@ mn10300_elf_final_link_relocate (howto, 
 	      /* h->dynindx may be -1 if this symbol was marked to
 		 become local.  */
 	      if (h == NULL
-		  || _bfd_elf_symbol_refs_local_p (h, info, 1))
+		  || SYMBOL_REFERENCES_LOCAL (info, h))
 		{
 		  relocate = TRUE;
 		  outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
@@ -1302,7 +1302,7 @@ mn10300_elf_final_link_relocate (howto, 
 	      BFD_ASSERT (off != (bfd_vma) -1);
 
 	      if (! elf_hash_table (info)->dynamic_sections_created
-		  || _bfd_elf_symbol_refs_local_p (h, info, 1))
+		  || SYMBOL_REFERENCES_LOCAL (info, h))
 		/* This is actually a static link, or it is a
 		   -Bsymbolic link and the symbol is defined
 		   locally, or the symbol was forced to be local
@@ -1461,9 +1461,9 @@ mn10300_elf_relocate_section (output_bfd
 		       || r_type == R_MN10300_GOT24
 		       || r_type == R_MN10300_GOT16)
 		      && elf_hash_table (info)->dynamic_sections_created
-		      && !_bfd_elf_symbol_refs_local_p (h, info, 1))
+		      && !SYMBOL_REFERENCES_LOCAL (info, hh))
 		  || (r_type == R_MN10300_32
-		      && !_bfd_elf_symbol_refs_local_p (h, info, 1)
+		      && !SYMBOL_REFERENCES_LOCAL (info, hh)
 		      && ((input_section->flags & SEC_ALLOC) != 0
 			  /* DWARF will emit R_MN10300_32 relocations
 			     in its sections against symbols defined
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf32-frv.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf32-frv.c
--- bfd/elf32-frv.c 24 Jun 2004 04:46:18 -0000 1.26
+++ bfd/elf32-frv.c 8 Jul 2004 05:40:15 -0000
@@ -661,17 +661,7 @@ frvfdpic_elf_link_hash_table_create (bfd
    its function descriptor must be assigned by the dynamic linker.  */
 #define FRVFDPIC_SYM_LOCAL(INFO, H) \
   (_bfd_elf_symbol_refs_local_p ((H), (INFO), 1) \
-   || ! elf_hash_table (INFO)->dynamic_sections_created \
-   || (/* The condition below is an ugly hack to get .scommon data to
-	  be regarded as local.  For some reason the
-	  ELF_LINK_HASH_DEF_REGULAR bit is not set on such common
-	  symbols, and the SEC_IS_COMMON bit is not set any longer
-	  when we need to perform this test.  Hopefully this
-	  approximation is good enough.  */ \
-       ((H)->root.type == bfd_link_hash_defined \
-	|| (H)->root.type == bfd_link_hash_defweak) \
-       && (H)->root.u.def.section->output_section \
-       && ((H)->root.u.def.section->flags & SEC_LINKER_CREATED)))
+   || ! elf_hash_table (INFO)->dynamic_sections_created)
 #define FRVFDPIC_FUNCDESC_LOCAL(INFO, H) \
   ((H)->dynindx == -1 || ! elf_hash_table (INFO)->dynamic_sections_created)
 
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elflink.c,v
retrieving revision 1.80
diff -u -p -r1.80 elflink.c
--- bfd/elflink.c 6 Jul 2004 16:58:42 -0000 1.80
+++ bfd/elflink.c 8 Jul 2004 05:40:21 -0000
@@ -2456,9 +2456,13 @@ _bfd_elf_symbol_refs_local_p (struct elf
   if (h == NULL)
     return TRUE;
 
+  /* Common symbols that become definitions don't get the DEF_REGULAR
+     flag set, so test it first, and don't bail out.  */
+  if (ELF_COMMON_DEF_P (h))
+    /* Do nothing.  */;
   /* If we don't have a definition in a regular file, then we can't
      resolve locally.  The sym is either undefined or dynamic.  */
-  if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+  else if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
     return FALSE;
 
   /* Forced local symbols resolve locally.  */
-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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