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: multiple powerpc .got2 sections


At least for the time being, make the linker ignore .got2 relocs against
symbols from discarded sections.

	* elf-bfd.h (struct elf_backend_data): Add action_discarded.
	(enum action_discarded): Move from..
	* elflink.c (enum action_discarded): ..here.
	(_bfd_elf_default_action_discarded): Rename from elf_action_discarded.
	Remove target specific section checks.
	(elf_link_input_bfd): Adjust.
	* elfxx-target.h (elf_backend_action_discarded): Define.
	(elfNN_bed): Init new field.
	* bfd-in.h (_bfd_elf_default_action_discarded): Declare.
	* bfd-in2.h: Regenerate.
	* elf-hppa.h (elf_hppa_action_discarded): New function.
	* elf32-hppa.c (elf_backend_action_discarded): Define.
	* elf64-hppa.c (elf_backend_action_discarded): Define.
	* elf32-ppc.c (ppc_elf_action_discarded): New function.
	(elf_backend_action_discarded): Define.

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.106
diff -u -p -r1.106 bfd-in.h
--- bfd/bfd-in.h	15 Jul 2005 12:18:01 -0000	1.106
+++ bfd/bfd-in.h	29 Jul 2005 02:11:43 -0000
@@ -656,6 +656,8 @@ extern struct bfd_link_needed_list *bfd_
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean bfd_elf_discard_info
   (bfd *, struct bfd_link_info *);
+extern unsigned int _bfd_elf_default_action_discarded
+  (struct bfd_section *);
 
 /* Return an upper bound on the number of bytes required to store a
    copy of ABFD's program header table entries.  Return -1 if an error
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.193
diff -u -p -r1.193 elf-bfd.h
--- bfd/elf-bfd.h	25 Jul 2005 15:41:02 -0000	1.193
+++ bfd/elf-bfd.h	29 Jul 2005 02:11:47 -0000
@@ -546,6 +546,12 @@ struct bfd_elf_special_section
   int attr;
 };
 
+enum action_discarded
+  {
+    COMPLAIN = 1,
+    PRETEND = 2
+  };
+
 struct elf_backend_data
 {
   /* The architecture for this backend.  */
@@ -918,6 +924,11 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_ignore_discarded_relocs)
     (asection *);
 
+  /* What to do when ld finds relocations against symbols defined in
+     discarded sections.  */
+  unsigned int (*action_discarded)
+    (asection *);
+
   /* This function returns the width of FDE pointers in bytes, or 0 if
      that can't be determined for some reason.  The default definition
      goes by the bfd's EI_CLASS.  */
Index: bfd/elf-hppa.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-hppa.h,v
retrieving revision 1.79
diff -u -p -r1.79 elf-hppa.h
--- bfd/elf-hppa.h	8 Jul 2005 06:19:56 -0000	1.79
+++ bfd/elf-hppa.h	29 Jul 2005 02:11:49 -0000
@@ -1057,6 +1057,18 @@ static bfd_boolean elf_hppa_sort_unwind 
   return TRUE;
 }
 
+/* What to do when ld finds relocations against symbols defined in
+   discarded sections.  */
+
+static unsigned int
+elf_hppa_action_discarded (asection *sec)
+{
+  if (strcmp (".PARISC.unwind", sec->name) == 0)
+    return 0;
+
+  return _bfd_elf_default_action_discarded (sec);
+}
+
 #if ARCH_SIZE == 64
 /* Hook called by the linker routine which adds symbols from an object
    file.  HP's libraries define symbols with HP specific section
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.136
diff -u -p -r1.136 elf32-hppa.c
--- bfd/elf32-hppa.c	8 Jul 2005 06:19:58 -0000	1.136
+++ bfd/elf32-hppa.c	29 Jul 2005 02:11:52 -0000
@@ -4251,6 +4251,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte
 #define elf_backend_post_process_headers     elf32_hppa_post_process_headers
 #define elf_backend_get_symbol_type	     elf32_hppa_elf_get_symbol_type
 #define elf_backend_reloc_type_class	     elf32_hppa_reloc_type_class
+#define elf_backend_action_discarded	     elf_hppa_action_discarded
 
 #define elf_backend_can_gc_sections	     1
 #define elf_backend_can_refcount	     1
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.175
diff -u -p -r1.175 elf32-ppc.c
--- bfd/elf32-ppc.c	26 Jul 2005 12:06:38 -0000	1.175
+++ bfd/elf32-ppc.c	29 Jul 2005 02:11:55 -0000
@@ -5303,6 +5303,21 @@ ppc_elf_set_sdata_syms (bfd *obfd, struc
       _bfd_elf_provide_symbol (info, lsect->sym_name, val, s);
     }
 }
+
+/* What to do when ld finds relocations against symbols defined in
+   discarded sections.  */
+
+static unsigned int
+ppc_elf_action_discarded (asection *sec)
+{
+  if (strcmp (".fixup", sec->name) == 0)
+    return 0;
+
+  if (strcmp (".got2", sec->name) == 0)
+    return 0;
+
+  return _bfd_elf_default_action_discarded (sec);
+}
 
 /* Fill in the address for a pointer generated in a linker section.  */
 
@@ -7360,6 +7375,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 #define elf_backend_write_section		ppc_elf_write_section
 #define elf_backend_get_sec_type_attr		ppc_elf_get_sec_type_attr
 #define elf_backend_plt_sym_val			ppc_elf_plt_sym_val
+#define elf_backend_action_discarded		ppc_elf_action_discarded
 
 #include "elf32-target.h"
 
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf64-hppa.c
--- bfd/elf64-hppa.c	8 Jul 2005 06:20:02 -0000	1.63
+++ bfd/elf64-hppa.c	29 Jul 2005 02:11:57 -0000
@@ -2745,6 +2745,7 @@ const struct elf_size_info hppa64_elf_si
 #define elf_backend_reloc_type_class	elf64_hppa_reloc_type_class
 #define elf_backend_rela_normal		1
 #define elf_backend_special_sections	elf64_hppa_special_sections
+#define elf_backend_action_discarded	elf_hppa_action_discarded
 
 #include "elf64-target.h"
 
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.183
diff -u -p -r1.183 elflink.c
--- bfd/elflink.c	27 Jul 2005 08:32:53 -0000	1.183
+++ bfd/elflink.c	29 Jul 2005 02:12:03 -0000
@@ -6690,12 +6690,6 @@ elf_section_ignore_discarded_relocs (ase
   return FALSE;
 }
 
-enum action_discarded
-  {
-    COMPLAIN = 1,
-    PRETEND = 2
-  };
-
 /* Return a mask saying how ld should treat relocations in SEC against
    symbols defined in discarded sections.  If this function returns
    COMPLAIN set, ld will issue a warning message.  If this function
@@ -6705,8 +6699,8 @@ enum action_discarded
    zero the reloc (at least that is the intent, but some cooperation by
    the target dependent code is needed, particularly for REL targets).  */
 
-static unsigned int
-elf_action_discarded (asection *sec)
+unsigned int
+_bfd_elf_default_action_discarded (asection *sec)
 {
   if (sec->flags & SEC_DEBUGGING)
     return PRETEND;
@@ -6717,12 +6711,6 @@ elf_action_discarded (asection *sec)
   if (strcmp (".gcc_except_table", sec->name) == 0)
     return 0;
 
-  if (strcmp (".PARISC.unwind", sec->name) == 0)
-    return 0;
-
-  if (strcmp (".fixup", sec->name) == 0)
-    return 0;
-
   return COMPLAIN | PRETEND;
 }
 
@@ -7042,7 +7030,7 @@ elf_link_input_bfd (struct elf_final_lin
 	  if (!elf_section_ignore_discarded_relocs (o))
 	    {
 	      Elf_Internal_Rela *rel, *relend;
-	      unsigned int action = elf_action_discarded (o);
+	      unsigned int action = (*bed->action_discarded) (o);
 
 	      rel = internal_relocs;
 	      relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.87
diff -u -p -r1.87 elfxx-target.h
--- bfd/elfxx-target.h	25 Jul 2005 15:35:37 -0000	1.87
+++ bfd/elfxx-target.h	29 Jul 2005 02:12:03 -0000
@@ -445,6 +445,9 @@
 #ifndef elf_backend_ignore_discarded_relocs
 #define elf_backend_ignore_discarded_relocs	NULL
 #endif
+#ifndef elf_backend_action_discarded
+#define elf_backend_action_discarded _bfd_elf_default_action_discarded
+#endif
 #ifndef elf_backend_eh_frame_address_size
 #define elf_backend_eh_frame_address_size _bfd_elf_eh_frame_address_size
 #endif
@@ -596,6 +599,7 @@ static const struct elf_backend_data elf
   elf_backend_reloc_type_class,
   elf_backend_discard_info,
   elf_backend_ignore_discarded_relocs,
+  elf_backend_action_discarded,
   elf_backend_eh_frame_address_size,
   elf_backend_can_make_relative_eh_frame,
   elf_backend_can_make_lsda_relative_eh_frame,

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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