From tody@noao.edu  Fri Jul 19 14:22:59 1996
Received: from noao.edu (noao.edu [140.252.1.54])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA20254
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jul 1996 14:22:58 -0700 (PDT)
Received: from tucana.tuc.noao.edu (tucana.tuc.noao.edu [140.252.1.1]) by noao.edu (8.7.5/8.7.3/SAG-15Apr96) with SMTP id OAA21728 for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jul 1996 14:22:52 -0700 (MST)
Received: from lepus.tuc.noao.edu by tucana.tuc.noao.edu (4.1/SAG.sat.14)
	id AA00602; Fri, 19 Jul 96 14:22:52 MST; for FreeBSD-gnats-submit@freebsd.org
Received: (from tody@localhost) by lepus.tuc.noao.edu (8.7.5/8.7.3) id OAA06363; Fri, 19 Jul 1996 14:22:44 -0700 (MST)
Message-Id: <199607192122.OAA06363@lepus.tuc.noao.edu>
Date: Fri, 19 Jul 1996 14:22:44 -0700 (MST)
From: tody@noao.edu
Reply-To: tody@noao.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: Problem with ld and common sizes
X-Send-Pr-Version: 3.2

>Number:         1407
>Category:       gnu
>Synopsis:       ld computes wrong size of common (global data)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    jdp
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 19 14:30:01 PDT 1996
>Closed-Date:    Mon Apr 14 11:09:00 PDT 1997
>Last-Modified:  Mon Apr 14 11:13:28 PDT 1997
>Originator:     Doug Tody
>Release:        FreeBSD 2.2-960612-SNAP i386
>Organization:
Doug Tody       National Optical Astronomy Observatories    IRAF project
tody@noao.edu   P.O. Box 26732, Tucson, Arizona, 85726   http://iraf.noao.edu
>Environment:

    FreeBSD lepus 2.2-960612-SNAP
    FreeBSD 2.2-960612-SNAP #0: Tue Jul 16 14:45:25 MST 1996 
    tody@lepus:/usr/src/sys/compile/LEPUS  i386

>Description:

    When linking an executable and the same common (global structure)
    exists in both the program and a library with different sizes, the
    smaller of the two sizes is erroneously used.  The larger size should
    be used.

>How-To-Repeat:

    Requires some test code to repeat.

>Fix:

    I just looked at the LD code but the following appears to be the problem.
    See line 531 of gnu/usr.bin/ld/lib.c:

	if (iscommon && p->n_value < sp->common_size)
	    sp->common_size = p->n_value;

    In words, "if the value we are looking at is less than the currently
    recorded size of the common use the new (smaller) value".  Should read

	if (iscommon && sp->common_size < p->n_value)
	    sp->common_size = p->n_value;

    as is done everywhere else in the code.  (I didn't look into it further
    or test the changes but whoever is responsible for LD ought to be able
    to verify this visually).

Doug Tody       National Optical Astronomy Observatories    IRAF project
tody@noao.edu   P.O. Box 26732, Tucson, Arizona, 85726   http://iraf.noao.edu
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Wed Sep 25 17:07:40 PDT 1996 
Responsible-Changed-Why:  
The compiler oracle. 
Responsible-Changed-From-To: bde->jdp 
Responsible-Changed-By: bde 
Responsible-Changed-When: Tue Dec 17 04:01:00 PST 1996 
Responsible-Changed-Why:  
John Polstra maintains ld. 
State-Changed-From-To: open->feedback 
State-Changed-By: jdp 
State-Changed-When: Fri Jan 17 10:15:30 PST 1997 
State-Changed-Why:  
Doug, the linker code has undergone some fairly extensive changes since 
the version in which you found this bug.  I've just gone over the 
common-related code fairly carefully, and I believe that the problem you 
reported is no longer present.  (The code you cited was indeed 
incorrect, but it's already fixed in the current version.) 

I'd like to confirm this if possible.  Do you have a test case you could 
send me, or would it be possible for you to try the currrent version of 
the linker yourself? 
-- 
John Polstra                                       jdp@polstra.com 
John D. Polstra & Co., Inc.                Seattle, Washington USA 
"Self-knowledge is always bad news."                 -- John Barth 
State-Changed-From-To: feedback->closed 
State-Changed-By: jdp 
State-Changed-When: Mon Apr 14 11:09:00 PDT 1997 
State-Changed-Why:  
As far as I can tell, this bug no longer exists in the current 
version of the linker, including FreeBSD-2.2.  It appears to have 
been fixed in multiple commits that took place at 1996/10/01 
01:22:30 UTC.  I asked the submitter for confirmation, but didn't 
receive an answer one way or the other. 
>Unformatted:
