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]

[PATCH] Fix handling of symbols with non-default visibility in discardedCOMDAT group sections


Hi,

This patch fixes a problem with hidden symbols in sections which are discarded through being part of a COMDAT group. It does this by forcing their visibility to be STV_DEFAULT (AIUI, other values are fairly meaningless in this context anyway). This fixes some interoperability problems with another compiler.

It prevents the error condition in elflink.c:elf_link_output_extsym from triggering ("If a non-weak symbol with non-default visibility is not defined locally, it is a fatal error"), and henceforth lets linking work correctly -- that is, that error condition seems to be the only thing preventing linking working in the first place. Changing the condition to allow hidden visibility too definitely seems like the wrong solution though.

References:

  http://sources.redhat.com/ml/binutils/2003-04/msg00055.html
  http://sources.redhat.com/ml/binutils/2004-12/msg00007.html

ChangeLog:

	* bfd/elflink.c (elf_link_add_object_symbols): Force symbols in
	discarded COMDAT group sections to have default visibility.

--
Julian Brown
CodeSourcery, LLC
? bfd/.elflink.c.swp
? bfd/doc/bfd.info
? bfd/doc/bfd.info-1
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.134
diff -c -p -r1.134 elflink.c
*** bfd/elflink.c	11 Feb 2005 16:41:09 -0000	1.134
--- bfd/elflink.c	23 Feb 2005 15:45:59 -0000
*************** elf_link_add_object_symbols (bfd *abfd, 
*** 3575,3583 ****
  	    sec = bfd_abs_section_ptr;
  	  else if (sec->kept_section)
  	    {
! 	      /* Symbols from discarded section are undefined.  */
  	      sec = bfd_und_section_ptr;
  	      isym->st_shndx = SHN_UNDEF;
  	    }
  	  else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
  	    value -= sec->vma;
--- 3575,3586 ----
  	    sec = bfd_abs_section_ptr;
  	  else if (sec->kept_section)
  	    {
! 	      /* Symbols from discarded section are undefined, and have
! 	         default visibility.  */
  	      sec = bfd_und_section_ptr;
  	      isym->st_shndx = SHN_UNDEF;
+ 	      isym->st_other = STV_DEFAULT
+ 			       | (isym->st_other & ~ ELF_ST_VISIBILITY(-1));
  	    }
  	  else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
  	    value -= sec->vma;

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