From tejblum@arc.hq.cti.ru  Wed Mar 18 06:54:16 1998
Received: from yandex.hq.cti.ru (yandex.hq.cti.ru [194.67.85.53])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA22985
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Mar 1998 06:53:49 -0800 (PST)
          (envelope-from tejblum@arc.hq.cti.ru)
Received: (from tejblum@localhost)
	by yandex.hq.cti.ru (8.8.8/8.8.7) id RAA11391;
	Wed, 18 Mar 1998 17:53:10 +0300 (MSK)
	(envelope-from tejblum)
Message-Id: <199803181453.RAA11391@yandex.hq.cti.ru>
Date: Wed, 18 Mar 1998 17:53:10 +0300 (MSK)
From: Dmitrij Tejblum <tejblum@arc.hq.cti.ru>
Reply-To: tejblum@arc.hq.cti.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: as(1) sometimes incorrectly handle EGCS output
X-Send-Pr-Version: 3.2

>Number:         6055
>Category:       gnu
>Synopsis:       as(1) sometimes incorrectly handle EGCS output
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 18 07:00:06 PST 1998
>Closed-Date:    Tue Apr 7 10:10:23 PDT 1998
>Last-Modified:  Tue Apr  7 10:13:24 PDT 1998
>Originator:     Dmitrij Tejblum
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
CompTek
>Environment:

FreeBSD 2.2.5-stable
EGCS 1.0.2 configured with --with-gnu-as --with-gnu-ld

>Description:

When a C++ program contains a static variable with a constructor, GCC emit 
something like 
.stabs "___CTOR_LIST__",22,0,0,__GLOBAL_$I$whatever
GCC 2.7.2.1 always emit it after __GLOBAL_$I$whatever was defined. 
EGCS sometimes (apparently, with -O3, as I see now) emit it before 
__GLOBAL_$I$whatever was defined. In this case, assembler silently convert 
that stab to "usual" text symbol. As a result, ld complains about multiply 
defined ___CTOR_LIST__.

>How-To-Repeat:

put something like 

.stabs "___CTOR_LIST__",22,0,0,_qq
_qq:
	movl %eax, %eax

to an .s file, assemble it, look at result with nm.


>Fix:

Not sure about correct fix. Here is my workaround, just FYI. (And so I have a
chance to hear that all my object are hopelessly broken :).

--- config/obj-aout.c	Tue Mar 17 11:25:17 1998
+++ config/obj-aout.c	Tue Mar 17 11:55:42 1998
@@ -469,7 +469,8 @@
 	/* JF deal with forward references first... */
 	for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
 		if (symbolP->sy_forward && symbolP->sy_forward != symbolP) {
-			S_SET_SEGMENT(symbolP,
+			if ((symbolP->sy_symbol.n_type & 0xf0) == 0) 
+				S_SET_SEGMENT(symbolP,
 				      S_GET_SEGMENT(symbolP->sy_forward));
 			S_SET_VALUE(symbolP, S_GET_VALUE(symbolP)
 				    + S_GET_VALUE(symbolP->sy_forward)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Tue Apr 7 10:10:23 PDT 1998 
State-Changed-Why:  
Fixed in src/gnu/usr.bin/as/config/obj-aout.c revision 1.6.  I used 
the patch submitted by Dmitrij Tejblum, with only minor changes.  Thanks, 
Dmitrij, for locating the problem! 
>Unformatted:
