[RFA] Fix broken .linkonce
H. J. Lu
Thu Jul 15 15:23:00 GMT 2004
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:
> 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)
2004-07-15 Christopher Faylor <firstname.lastname@example.org>
H.J. Lu <email@example.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)
+ 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 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);
More information about the Binutils