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]

Re: RFC: PATCH: ld/12942: Plugin not handling correctly resolution of COMDATs.


Now that I've had time to properly look at this problem, I believe
much of your patch isn't needed.  Everything related to
SEC_LTO_COMDAT and GNU_LTO_COMDAT_SECTION_NAME, and the changes to
plugin_notice are all working around a bug uncovered by the
section_already_linked change.  I'm about to install the following
patch along with your changes related to section_already_linked.
(Another approach would be to use elf_discarded_section in
plugin_notice, but it's neater to catch the real problem at the
source.)

bfd/

2011-07-09  Alan Modra  <amodra@gmail.com>

	PR ld/12942
	* elflink.c (elf_link_add_object_symbols): Use elf_discarded_section
	rather than kept_section to determine whether a symbol is from
	a discarded section.
	* cofflink.c (coff_link_add_symbols): Make symbols from discarded
	sections appear undefined.

2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12942
	* elf-bfd.h (_bfd_elf_section_already_linked): Replace
	"asection *" with "struct already_linked *".
	* libbfd-in.h (_bfd_nolink_section_already_linked): Likewise.
	(_bfd_generic_section_already_linked): Likewise.
	(bfd_section_already_linked_table_insert): Likewise.
	(struct already_linked): New.
	(struct bfd_section_already_linked): Use it.
	* elflink.c (_bfd_elf_section_already_linked): Replace.
	"asection *" with "struct already_linked *".  Replace the plugin
	dummy with the LTO output.
	* linker.c (_bfd_generic_section_already_linked): Likewise.
	* targets.c (struct already_linked): Add forward declaration.
	(bfd_target): Replace "struct bfd_section *" with
	"struct already_linked *" in _section_already_linked.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

include/

2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12942
	* bfdlink.h (bfd_link_info): Add loading_lto_outputs.

ld/

2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12942
	* ldlang.c (section_already_linked): Pass "struct already_linked *"
	to bfd_section_already_linked.
	(lang_process): Set link_info.loading_lto_outputs before
	loading LTO outputs.
	* plugin.c: Include "libbfd.h".
	(add_symbols): Call bfd_section_already_linked with comdat_key.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.412
diff -u -p -r1.412 elflink.c
--- bfd/elflink.c	21 Jun 2011 14:55:26 -0000	1.412
+++ bfd/elflink.c	8 Jul 2011 13:49:04 -0000
@@ -3900,7 +3900,7 @@ error_free_dyn:
 	  sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
 	  if (sec == NULL)
 	    sec = bfd_abs_section_ptr;
-	  else if (sec->kept_section)
+	  else if (elf_discarded_section (sec))
 	    {
 	      /* Symbols from discarded section are undefined.  We keep
 		 its visibility.  */
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.77
diff -u -p -r1.77 cofflink.c
--- bfd/cofflink.c	13 Jun 2011 00:59:09 -0000	1.77
+++ bfd/cofflink.c	9 Jul 2011 03:17:55 -0000
@@ -392,7 +392,11 @@ coff_link_add_symbols (bfd *abfd,
 	      section = coff_section_from_bfd_index (abfd, sym.n_scnum);
 	      if (! obj_pe (abfd))
 		value -= section->vma;
-	      break;
+	      /* Treat a symbol from a discarded section as undefined.  */
+	      if (bfd_is_abs_section (section)
+		  || !bfd_is_abs_section (section->output_section))
+		break;
+	      /* Fall thru */
 
 	    case COFF_SYMBOL_UNDEFINED:
 	      flags = 0;

-- 
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]