This is the mail archive of the binutils@sourceware.org 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]

multi-obj gas fix


This fixes a segfault I noticed in a multi-obj coff gas target that
isn't present in the corresponding single coff target.  With the
multi-obj coff gas we didn't get calls to coff_obj_symbol_clone_hook,
resulting in coffsymbol(bfd_sym)->native being NULL.

I've also added an ecoff_symbol_clone_hook that simply copies the
ecoff sy_obj field from the original symbol to the clone, which better
approximates the situation we had before symbols were cloned.

	* ecoff.c (ecoff_symbol_clone_hook): New function.
	* ecoff.h (ecoff_symbol_clone_hook): Declare.
	* obj.h (struct format_ops): Add symbol_clone_hook.
	* config/obj-aout.c (aout_format_ops): Init new field.
	* config/obj-coff.c (coff_format_ops): Likewise.
	* config/obj-ecoff.c (ecoff_format_ops): Likewise.
	* config/obj-elf.c (elf_format_ops): Likewise.
	* config/obj-ecoff.h (obj_symbol_clone_hook): Define.
	* config/obj-multi.h (obj_symbol_clone_hook): Define.

Index: gas/ecoff.c
===================================================================
RCS file: /cvs/src/src/gas/ecoff.c,v
retrieving revision 1.26
diff -u -p -r1.26 ecoff.c
--- gas/ecoff.c	25 Sep 2009 19:13:26 -0000	1.26
+++ gas/ecoff.c	2 Nov 2009 00:49:31 -0000
@@ -1506,6 +1506,16 @@ ecoff_symbol_new_hook (symbolS *symbolP)
   obj->ecoff_symbol = NULL;
   obj->ecoff_extern_size = 0;
 }
+
+void
+ecoff_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP)
+{
+  OBJ_SYMFIELD_TYPE *n, *o;
+
+  n = symbol_get_obj (newsymP);
+  o = symbol_get_obj (orgsymP);
+  memcpy (n, o, sizeof *n);
+}
 
 /* Add a page to a varray object.  */
 
Index: gas/ecoff.h
===================================================================
RCS file: /cvs/src/src/gas/ecoff.h,v
retrieving revision 1.9
diff -u -p -r1.9 ecoff.h
--- gas/ecoff.h	2 Sep 2009 07:24:19 -0000	1.9
+++ gas/ecoff.h	2 Nov 2009 00:49:31 -0000
@@ -44,6 +44,8 @@ extern void ecoff_new_file (const char *
    obj_symbol_new_hook.  */
 extern void ecoff_symbol_new_hook (symbolS *);
 
+extern void ecoff_symbol_clone_hook (symbolS *, symbolS *);
+
 /* This function should be called by the obj_frob_symbol hook.  */
 extern void ecoff_frob_symbol (symbolS *);
 
Index: gas/obj.h
===================================================================
RCS file: /cvs/src/src/gas/obj.h,v
retrieving revision 1.12
diff -u -p -r1.12 obj.h
--- gas/obj.h	3 Jul 2007 11:01:03 -0000	1.12
+++ gas/obj.h	2 Nov 2009 00:49:33 -0000
@@ -71,6 +71,7 @@ struct format_ops {
 
   void (*read_begin_hook) (void);
   void (*symbol_new_hook) (symbolS *);
+  void (*symbol_clone_hook) (symbolS *, symbolS *);
 };
 
 extern const struct format_ops elf_format_ops;
Index: gas/config/obj-aout.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-aout.c,v
retrieving revision 1.27
diff -u -p -r1.27 obj-aout.c
--- gas/config/obj-aout.c	2 Sep 2009 07:24:20 -0000	1.27
+++ gas/config/obj-aout.c	2 Nov 2009 00:49:39 -0000
@@ -310,7 +310,8 @@ const struct format_ops aout_format_ops 
   aout_pop_insert,
   0,	/* ecoff_set_ext.  */
   0,	/* read_begin_hook.  */
-  0 	/* symbol_new_hook.  */
+  0, 	/* symbol_new_hook.  */
+  0 	/* symbol_clone_hook.  */
 };
 
 const pseudo_typeS aout_pseudo_table[] =
Index: gas/config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.101
diff -u -p -r1.101 obj-coff.c
--- gas/config/obj-coff.c	9 Sep 2009 13:19:51 -0000	1.101
+++ gas/config/obj-coff.c	2 Nov 2009 00:49:40 -0000
@@ -1930,5 +1930,6 @@ const struct format_ops coff_format_ops 
   coff_pop_insert,
   0,	/* ecoff_set_ext */
   coff_obj_read_begin_hook,
-  coff_obj_symbol_new_hook
+  coff_obj_symbol_new_hook,
+  coff_obj_symbol_clone_hook
 };
Index: gas/config/obj-ecoff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-ecoff.c,v
retrieving revision 1.19
diff -u -p -r1.19 obj-ecoff.c
--- gas/config/obj-ecoff.c	2 Sep 2009 07:24:20 -0000	1.19
+++ gas/config/obj-ecoff.c	2 Nov 2009 00:49:40 -0000
@@ -314,5 +314,6 @@ const struct format_ops ecoff_format_ops
   ecoff_pop_insert,
   ecoff_set_ext,
   ecoff_read_begin_hook,
-  ecoff_symbol_new_hook
+  ecoff_symbol_new_hook,
+  ecoff_symbol_clone_hook
 };
Index: gas/config/obj-ecoff.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-ecoff.h,v
retrieving revision 1.9
diff -u -p -r1.9 obj-ecoff.h
--- gas/config/obj-ecoff.h	3 Jul 2007 11:01:04 -0000	1.9
+++ gas/config/obj-ecoff.h	2 Nov 2009 00:49:40 -0000
@@ -59,6 +59,7 @@ struct ecoff_sy_obj
 /* We use the ECOFF functions as our hooks.  */
 #define obj_read_begin_hook ecoff_read_begin_hook
 #define obj_symbol_new_hook ecoff_symbol_new_hook
+#define obj_symbol_clone_hook ecoff_symbol_clone_hook
 
 /* Record file switches in the ECOFF symbol table.  */
 #define obj_app_file(name, app) ecoff_new_file (name, app)
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.123
diff -u -p -r1.123 obj-elf.c
--- gas/config/obj-elf.c	25 Sep 2009 19:13:26 -0000	1.123
+++ gas/config/obj-elf.c	2 Nov 2009 00:49:41 -0000
@@ -2424,5 +2424,6 @@ const struct format_ops elf_format_ops =
   0,	/* ecoff_set_ext */
 #endif
   elf_obj_read_begin_hook,
-  elf_obj_symbol_new_hook
+  elf_obj_symbol_new_hook,
+  0
 };
Index: gas/config/obj-multi.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-multi.h,v
retrieving revision 1.14
diff -u -p -r1.14 obj-multi.h
--- gas/config/obj-multi.h	2 Sep 2009 07:24:20 -0000	1.14
+++ gas/config/obj-multi.h	2 Nov 2009 00:49:41 -0000
@@ -81,6 +81,11 @@
 	 ? (*this_format->symbol_new_hook) (S)		\
 	 : (void) 0)
 
+#define obj_symbol_clone_hook(N, O)			\
+	(this_format->symbol_clone_hook			\
+	 ? (*this_format->symbol_clone_hook) (N, O)	\
+	 : (void) 0)
+
 #define obj_sec_sym_ok_for_reloc(A)			\
 	(this_format->sec_sym_ok_for_reloc		\
 	 ? (*this_format->sec_sym_ok_for_reloc) (A)	\

-- 
Alan Modra
Australia Development Lab, IBM


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