From owner-freebsd-current Wed Mar 12 6:48:53 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E0CF37B401; Wed, 12 Mar 2003 06:48:49 -0800 (PST) Received: from mail.imp.ch (mail.imp.ch [157.161.1.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id DF0EE43FB1; Wed, 12 Mar 2003 06:48:46 -0800 (PST) (envelope-from mb@imp.ch) Received: from cvs.imp.ch (cvs.imp.ch [157.161.4.9]) by mail.imp.ch (8.12.6/8.12.3) with ESMTP id h2CEmjms024410; Wed, 12 Mar 2003 15:48:45 +0100 (CET) (envelope-from Martin.Blapp@imp.ch) Date: Wed, 12 Mar 2003 15:48:45 +0100 (CET) From: Martin Blapp To: current@freebsd.org Cc: kan@freebsd.org Subject: ld -Bsharable broken in CURRENT ? Message-ID: <20030312154243.C59497@cvs.imp.ch> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG See testcase STABLE: mb@stable:~/cxxtest2$ export LD_LIBRARY_PATH=. mb@stable:~/cxxtest2$ ./a.out cought string: x == 1 bar: cought string: x == 1 mb@stable:~/cxxtest2$ ./b.out cought string: x == 1 bar: cought string: x == 1 CURRENT: mb@current:~/cxxtest2$ ./a.out cought string: x == 1 bar: cought string: x == 1 mb@current:~/cxxtest2$ ./b.out Abort trap (core dumped) cxxtest2/Makefile ---------------------------------------------------- CXX=g++ LD=ld CXXFLAGS=-fpic -fexceptions all: a.out b.out # # Works # a.out: main.o foo.so bar.so ${CXX} -o a.out main.o foo.so bar.so # # Broken # b.out: main.o foo2.so bar2.so ${CXX} -o b.out main.o foo2.so bar2.so # # Works # bar.so: bar.o ${CXX} -shared -o bar.so bar.o foo.so: foo.o ${CXX} -shared -o foo.so foo.o # # Broken # bar2.so: bar.o ${LD} -Bshareable -o bar2.so bar.o foo2.so: foo.o ${LD} -Bshareable -o foo2.so foo.o clean: rm -f a.out *.o *.so ---------------------------------------------------- cxxtest2/bar.cc ---------------------------------------------------- /* compile with "g++ -shared -fPIC -o bar.so bar.cc" */ #include #include using namespace std; using std::cerr; extern void foo(int); void bar(int x) { try { foo(x); } catch (string s) { cerr << "bar: cought string: " << s << endl; } catch (int i) { cerr << "bar: cought int: " << i << endl; } catch (...) { cerr << "bar: cought something" << endl; } } ---------------------------------------------------- cxxtest2/foo.cc ---------------------------------------------------- /* compile with "g++ -shared -fPIC -o foo.so foo.cc" */ #include using namespace std; void foo(int x) { switch(x) { case 1: throw string("x == 1"); case 2: throw int(2); default: throw float(3.1415); } } ---------------------------------------------------- cxxtest2/main.cc ---------------------------------------------------- /* compile with "g++ main.cc ./foo.so ./bar.so" */ #include #include using namespace std; extern void foo(int); extern void bar(int); main(int argc, char *argv[]) { try { foo(argc); } catch (string s) { cerr << "cought string: " << s << endl; } catch (int i) { cerr << "cought int: " << i << endl; } catch (...) { cerr << "cought something" << endl; } bar(argc); return 0; } ---------------------------------------------------- Martin Blapp, ------------------------------------------------------------------ ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH Phone: +41 61 826 93 00 Fax: +41 61 826 93 01 PGP: PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E ------------------------------------------------------------------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message