From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Peyton Bland Newsgroups: gmane.os.tru64.managers Subject: SUMMARY: dynamic vs. shared executables Date: Mon, 23 Jun 2003 15:41:44 -0400 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed X-Trace: main.gmane.org 1056397377 24425 80.91.224.249 (23 Jun 2003 19:42:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 23 Jun 2003 19:42:57 +0000 (UTC) Original-X-From: tru64-unix-managers-owner-gotm-tru64-unix-managers=m.gmane.org@sws1.ctd.ornl.gov Mon Jun 23 21:42:56 2003 Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.22.101]) by main.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 19UXCJ-0006EO-00 for ; Mon, 23 Jun 2003 21:41:52 +0200 Original-Received: (qmail 32103 invoked by uid 5); 23 Jun 2003 19:41:57 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 32094 invoked by uid 49493); 23 Jun 2003 19:41:56 -0000 Original-Received: from bland@umich.edu by sws1 by uid 49491 with qmail-scanner-1.14 (clamscan: 0.54. spamassassin: 2.50-cvs. Clear:SA:0(-0.7/5.0):. Processed in 0.455416 secs); 23 Jun 2003 19:41:56 -0000 Original-Received: from unknown (HELO emroute2.cind.ornl.gov) (160.91.86.17) by 0 with SMTP; 23 Jun 2003 19:41:56 -0000 Original-Received: from emroute2.cind.ornl.gov (LOCALHOST [127.0.0.1]) by emroute2.cind.ornl.gov (PMDF V6.2 #30669) with ESMTP id <0HGY00G299DU81@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Mon, 23 Jun 2003 15:41:55 -0400 (EDT) Original-Received: from ladygodiva.mr.itd.umich.edu (ladygodiva.mr.itd.umich.edu [141.211.125.17]) by emroute2.cind.ornl.gov (PMDF V6.2 #30669) with ESMTP id <0HGY004EE9DRN3@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Mon, 23 Jun 2003 15:41:52 -0400 (EDT) Original-Received: from [141.214.12.61] (fanatic.rad.med.umich.edu [141.214.12.61]) by ladygodiva.mr.itd.umich.edu (3.7s) with ESMTP id h5NJfpe05092 for ; Mon, 23 Jun 2003 15:41:51 -0400 (EDT) X-Sender: bland@b.imap.itd.umich.edu Original-To: Tru64 Unix Managers Xref: main.gmane.org gmane.os.tru64.managers:4641 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:4641 Hi, Here's another late summary. My thanks to Joe, James, Lindsay, and J.A. for their answers. Peyton Bland -------------- The original question: Can someone clarify the difference between a "dynamic executable" which is produced by ld when the -call_shared switch is given versus a "shared executable" which is produced when the -shared switch is given? (And if someone wants to answer a similar question for the gcc compiler under Linux, I would appreciate it, but maybe it's the same for gcc under Tru64... The man page says that -shared produces a shared *library*, so I guess that wouldn't work if I need to produce an executable...) --------------- From: Joe Mario When you specify "-call_shared" during a link, an executable that will use shared libraries is created. All executables of that kind of link will link with the libc.so shared library at a minimum. The "-call_shared" flag is the default for linking. When you link with "-shared", you are creating a shared library. --------------- From: James Sainsbury I think the real difference is that -shared produces a position independent shared object whereas the main program isn't or doesn't need to be. Curiously the glibc runtime loader used in linux (/lib/ld-linux.so.2-->/lib/ld-2.2.4) is both a shared object and an executable. (Try running /lib/ld-linux.so.2) ----------------- From: "J.A. Gutierrez" You use "-call_shared" when you want to create an executable which will use a shared library. In fact, when you use "cc" with default options as a linker, it will call "ld -call_shared" So, for instance: cc -c hello.c ld -o static_hello /usr/lib/cmplrs/cc/crt0.o hello.o -lc will make a "static_hello" program which doesn't require any shared library to run. while ld -o hello -call_shared /usr/lib/cmplrs/cc/crt0.o hello.o -lc will make a "hello" which is a "dynamic executable" which depends on /usr/shlib/libc.so, as you can see using "file" and "ldd" commands. (and, yes, you use "-shared" when you want to create lib*.so) --------------------- From: "Wakeman, Lindsay" I was reading up on this issue a while back. As far as I understood it (and I may be wrong..) the link loader produces dynamically linked executables *by default* The '-call_shared' flag is also available to specify this - but it isn't actually needed. The '-shared' flag produces dynamically shareable objects - i.e. that can be used by other dynamically linked executables. This would be used to produce shared library components for example. The '-non-shared' flag produces static executables - i.e. no dynamic linking.