From pfeifer@deneb.dbai.tuwien.ac.at  Sat Oct 14 04:43:24 2000
Return-Path: <pfeifer@deneb.dbai.tuwien.ac.at>
Received: from vexpert.dbai.tuwien.ac.at (vexpert.dbai.tuwien.ac.at [128.130.111.12])
	by hub.freebsd.org (Postfix) with ESMTP id 4A9A737B66E
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Oct 2000 04:43:23 -0700 (PDT)
Received: from deneb.dbai.tuwien.ac.at (deneb [128.130.111.2])
	by vexpert.dbai.tuwien.ac.at (8.9.3/8.9.3) with ESMTP id NAA02027;
	Sat, 14 Oct 2000 13:42:21 +0200 (MET DST)
Received: (from pfeifer@localhost)
	by deneb.dbai.tuwien.ac.at (8.9.3/8.9.3) id NAA48611;
	Sat, 14 Oct 2000 13:42:20 +0200 (CEST)
	(envelope-from pfeifer)
Message-Id: <200010141142.NAA48611@deneb.dbai.tuwien.ac.at>
Date: Sat, 14 Oct 2000 13:42:20 +0200 (CEST)
From: pfeifer@dbai.tuwien.ac.at (Gerald Pfeifer)
Sender: pfeifer@deneb.dbai.tuwien.ac.at
Reply-To: pfeifer@dbai.tuwien.ac.at
To: FreeBSD-gnats-submit@freebsd.org
Cc: Ulrich Weigand <weigand@immd1.informatik.uni-erlangen.de>
Subject: gcc fails to link shared libraries against libgcc
X-Send-Pr-Version: 3.2

>Number:         21983
>Category:       gnu
>Synopsis:       gcc fails to link shared libraries against libgcc
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 14 04:50:01 PDT 2000
>Closed-Date:    Fri Nov 10 09:14:26 PST 2000
>Last-Modified:  Fri Nov 10 09:15:11 PST 2000
>Originator:     Gerald Pfeifer
>Release:        FreeBSD 4.1-RELEASE i386
>Organization:
>Environment:

	4.1-RELEASE

>Description:

	When generating an executable, gcc 2.95.2 as shipped with FreeBSD
	4.1 links against libgcc, which includes important helper functions
	like __fixunsdfdi. For shared libraries, this does not happen.

	In some cases, like the example included below or the Wine port,
	shared libraries will have unresolved references to libgcc symbols.

	If such a library is linked against an executable, the unresolved
	libraries will be linked against the executable (sic!) and when
	loading the library upon startup of the executable, the reference
	is resolved.

	If such a library is loaded during run-time (by means of dlopen()),
	the executable may lack these helper functions as these were neeeded
	for the executable itself and dlopen() will fail.

	This is a bug in the hacked version of gcc 2.95.2 shipped with
	FreeBSD 4.1, a version of gcc 2.95.2 from pristine sources does
	not have this bug.
 
	Thanks to Ulrich Weigand <weigand@immd1.informatik.uni-erlangen.de>
	for tracking down and analysing this.

>How-To-Repeat:

	Execute the following commands

 	  gcc -shared -o test.so test.c
          gcc -o main main.c
	  ./main

	using the following two source files:

	test.c

	  unsigned long long test(double x)
	  {
	  #if 1
	    return (unsigned long long) x;
	  #else
	    return 0;
	  #endif
	  }

	main.c

	  #include <dlfcn.h>

	  unsigned long long (*test)(double x);

	  int main()
	  {
	    void *lib;

	    lib = dlopen("./test.so", RTLD_NOW);
	    if (!lib)
	    {
	      printf("dlopen: %s\n", dlerror());
	      exit(1);
	      }

	    test = dlsym(lib, "test");
	    if (!test)
	    {
	      printf("dlsym: %s\n", dlerror());
	      exit(1);
	    }

	    test(1.0);
	  }

>Fix:
	
	Remove the patch against FSF GCC 2.95.2 that causes this change.

	Modify the GCC specs to link against libgcc_pic?


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: johan 
Responsible-Changed-When: Sat Oct 14 07:07:31 PDT 2000 
Responsible-Changed-Why:  
Over to GCC maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21983 
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Fri Nov 10 09:14:26 PST 2000 
State-Changed-Why:  
Fixed in -current and will be in -stable right after the 4.2 code freeze 
(unless the release engineer decides to allow a MFC, then it will be in 
4.2). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21983 
>Unformatted:
