From owner-freebsd-bugs Sat Oct 14 4:50: 8 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5EBD537B670 for ; Sat, 14 Oct 2000 04:50:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id EAA95292; Sat, 14 Oct 2000 04:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) 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 ; 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) Reply-To: pfeifer@dbai.tuwien.ac.at To: FreeBSD-gnats-submit@freebsd.org Cc: Ulrich Weigand X-Send-Pr-Version: 3.2 Subject: gnu/21983: gcc fails to link shared libraries against libgcc Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 21983 >Category: gnu >Synopsis: gcc fails to link shared libraries against libgcc >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Oct 14 04:50:01 PDT 2000 >Closed-Date: >Last-Modified: >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 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 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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message