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: [RFA] Fix broken .linkonce


On Thu, Jul 15, 2004 at 07:00:44AM -0700, H. J. Lu wrote:
> On Thu, Jul 15, 2004 at 09:23:31AM -0400, Christopher Faylor wrote:
> > On Mon, Jul 05, 2004 at 09:55:51AM -0700, H. J. Lu wrote:
> > >On Mon, Jul 05, 2004 at 12:50:52PM -0400, Christopher Faylor wrote:
> > >> On Sun, Jul 04, 2004 at 07:48:08AM -0700, H. J. Lu wrote:
> > >> >On Sat, Jul 03, 2004 at 11:11:37PM -0400, Christopher Faylor wrote:
> > >> >>H.J.  Lu's 2004-05-11 change to subsegs.c caused .linkonce symbols to
> > >> >>be treated as undeclared, at least for PE.
> > >> >
> > >> >Can you add a testcase for it?
> > >> 
> > >> Can I get confirmation that this is actually the right fix before we
> > >> start talking about test cases?
> > >
> > >I have used the new binutils to build gcc, glibc and kernel on Linux. I
> > >don't have any problems. I am trying to understand why/how it is broken
> > >on PE. A testcase will be very helpful.
> > 
> > Sorry for the delay.  Real world intrusions.
> > 
> > Here's a very simple test case.  It fails with the new version of gas
> > and succeeds with older versions and after the application of the
> > previously mentioned patch.
> > 
> >   as -o linkonce.o linkonce.s
> >   gcc -o linkonce linkonce.o -lcygwin
> >   linkonce.o(.txt+0x0):fake: undefined reference to `.foo'
> >   collect2: ld returned 1 exit status
> > 
> > cgf
> > 
> > 	 .section .foo,"w" 
> > 	 .linkonce 
> > 	 .long	27 
> >  
> > 	 .section .txt,"wx" 
> > 	 .long .foo 
> 	^^^^^^^^^^^^^
> 
> This is a known issue:
> 
> http://gcc.gnu.org/ml/gcc/2004-05/msg00030.html
> 
> Where does this code come from? If you can change your code, we can
> make it as error. Or you should somehow revert my patch for PE only
> and add your teestcase to gas testsuite.
> 
> > 	.global	_WinMain@16
> > _WinMain@16:
> 
> 

Can you try this patch? I don't think we want to remove

	if (S_GET_SEGMENT (s) == undefined_section)


H.J.
----
2004-07-15  Christopher Faylor  <cgf@timesys.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

	* subsegs.c (section_symbol): Don't create a new segment when
	existing segment is undefined.

--- gas/subsegs.c.sec	2004-05-11 10:48:42.000000000 -0700
+++ gas/subsegs.c	2004-07-15 08:07:20.924094407 -0700
@@ -523,18 +523,18 @@ section_symbol (segT sec)
     }
   else
     {
+      segT *seg;
       s = symbol_find_base (sec->symbol->name, 0);
       /* We have to make sure it is the right symbol when we
 	 have multiple sections with the same section name.  */
-      if (s == NULL || S_GET_SEGMENT (s) != sec)
+      if (s == NULL
+	  || ((seg = S_GET_SEGMENT (s)) != sec
+	      && seg != undefined_section))
 	s = symbol_new (sec->symbol->name, sec, 0, &zero_address_frag);
-      else
+      else if (seg == undefined_section)
 	{
-	  if (S_GET_SEGMENT (s) == undefined_section)
-	    {
-	      S_SET_SEGMENT (s, sec);
-	      symbol_set_frag (s, &zero_address_frag);
-	    }
+	  S_SET_SEGMENT (s, sec);
+	  symbol_set_frag (s, &zero_address_frag);
 	}
     }
 


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