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: PATCH: Optimize protected call for i386


On Wed, May 14, 2003 at 10:37:16PM -0700, H. J. Lu wrote:
> This patch optimizes protected call for i386. 
> 
> 
> H.J.

> 2003-05-14  H.J. Lu <hongjiu.lu@intel.com>
> 
> 	* elf32-i386.c (allocate_dynrelocs): Use SYMBOL_CALLS_LOCAL for
> 	dynreloc check. 
> 	(elf_i386_relocate_section): Use SYMBOL_CALLS_LOCAL for .got
> 	relocs.

I'm committing a patch with some comments instead of this one.

> 	* elflink.c (_bfd_elf_fix_symbol_flags): Also hide protected
> 	symbol.

Not OK until proven good.  I reckon this is the source of
http://sources.redhat.com/ml/binutils/2003-05/msg00457.html on ppc32.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

bfd/ChangeLog
	* elf32-i386.c (allocate_dynrelocs): Use SYMBOL_CALLS_LOCAL.
	(elf_i386_relocate_section): Likewise.
	* elf32-ppc.c (allocate_dynrelocs): Likewise.
	(ppc_elf_relocate_section): Likewise.
	* elf64-ppc.c (allocate_dynrelocs): Likewise.
	(ppc64_elf_relocate_section): Likewise.

Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.101
diff -u -p -r1.101 elf32-i386.c
--- bfd/elf32-i386.c	13 May 2003 14:09:51 -0000	1.101
+++ bfd/elf32-i386.c	15 May 2003 01:43:39 -0000
@@ -1679,7 +1679,13 @@ allocate_dynrelocs (h, inf)
 
   if (info->shared)
     {
-      if (SYMBOL_REFERENCES_LOCAL (info, h))
+      /* The only reloc that uses pc_count is R_386_PC32, which will
+	 appear on a call or on something like ".long foo - .".  We
+	 want calls to protected symbols to resolve directly to the
+	 function rather than going via the plt.  If people want
+	 function pointer comparisons to work as expected then they
+	 should avoid writing assembly like ".long foo - .".  */
+      if (SYMBOL_CALLS_LOCAL (info, h))
 	{
 	  struct elf_i386_dyn_relocs **pp;
 
@@ -2434,7 +2440,7 @@ elf_i386_relocate_section (output_bfd, i
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && (r_type != R_386_PC32
 		   || (h != NULL
-		       && !SYMBOL_REFERENCES_LOCAL (info, h))))
+		       && !SYMBOL_CALLS_LOCAL (info, h))))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
 		  && h != NULL
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.79
diff -u -p -r1.79 elf32-ppc.c
--- bfd/elf32-ppc.c	13 May 2003 14:09:50 -0000	1.79
+++ bfd/elf32-ppc.c	15 May 2003 01:56:17 -0000
@@ -2799,7 +2799,13 @@ allocate_dynrelocs (h, inf)
 
   if (info->shared)
     {
-      if (SYMBOL_REFERENCES_LOCAL (info, h))
+      /* Relocs that use pc_count are those that appear on a call
+	 insn, or certain REL relocs (see MUST_BE_DYN_RELOC) that can
+	 generated via assembly.  We want calls to protected symbols
+	 to resolve directly to the function rather than going via the
+	 plt.  If people want function pointer comparisons to work as
+	 expected then they should avoid writing weird assembly.  */
+      if (SYMBOL_CALLS_LOCAL (info, h))
 	{
 	  struct ppc_elf_dyn_relocs **pp;
 
@@ -4991,7 +4997,7 @@ ppc_elf_relocate_section (output_bfd, in
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && (MUST_BE_DYN_RELOC (r_type)
 		   || (h != NULL
-		       && !SYMBOL_REFERENCES_LOCAL (info, h))))
+		       && !SYMBOL_CALLS_LOCAL (info, h))))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
 		  && (input_section->flags & SEC_ALLOC) != 0
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.96
diff -u -p -r1.96 elf64-ppc.c
--- bfd/elf64-ppc.c	13 May 2003 14:09:50 -0000	1.96
+++ bfd/elf64-ppc.c	15 May 2003 03:34:27 -0000
@@ -5621,7 +5621,13 @@ allocate_dynrelocs (h, inf)
 
   if (info->shared)
     {
-      if (SYMBOL_REFERENCES_LOCAL (info, h))
+      /* Relocs that use pc_count are those that appear on a call
+	 insn, or certain REL relocs (see MUST_BE_DYN_RELOC) that can
+	 generated via assembly.  We want calls to protected symbols
+	 to resolve directly to the function rather than going via the
+	 plt.  If people want function pointer comparisons to work as
+	 expected then they should avoid writing weird assembly.  */
+      if (SYMBOL_CALLS_LOCAL (info, h))
 	{
 	  struct ppc_dyn_relocs **pp;
 
@@ -7874,7 +7880,7 @@ ppc64_elf_relocate_section (output_bfd, 
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && (MUST_BE_DYN_RELOC (r_type)
 		   || (h != NULL
-		       && !SYMBOL_REFERENCES_LOCAL (info, h))))
+		       && !SYMBOL_CALLS_LOCAL (info, h))))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
 		  && h != NULL


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