From owner-freebsd-hackers Wed Apr 23 16:40:15 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id QAA00796 for hackers-outgoing; Wed, 23 Apr 1997 16:40:15 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id QAA00791 for ; Wed, 23 Apr 1997 16:40:13 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id QAA29885; Wed, 23 Apr 1997 16:37:30 -0700 From: Terry Lambert Message-Id: <199704232337.QAA29885@phaeton.artisoft.com> Subject: Re: Dynamic linking libraries [Q] To: joerg_wunsch@uriah.heep.sax.de Date: Wed, 23 Apr 1997 16:37:30 -0700 (MST) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <19970423211522.OX52607@uriah.heep.sax.de> from "J Wunsch" at Apr 23, 97 09:15:22 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > Try using 'nm' instead. The error messages are static, so they can > > be mapped in as data, since they are referenced by the mapped in code > > in order to set up the global: > > > 00001670 F _exit.o > > 000015ac T _main > > 000020ec D _sys_errlist <************************************* > > 000015a0 t gcc2_compiled. > > 00001038 T start > > > > The marked data is from the libc for the sys_errlist[] reference. > > ...which actually turns out to be: > > j@uriah 912% gdb -q a.out > (gdb) b main > Breakpoint 1 at 0x160c: file foo.c, line 6. > (gdb) run > Starting program: /tmp/a.out > > Breakpoint 1, main () at foo.c:6 > 6 printf("%s\n", sys_errlist[E2BIG]); > (gdb) p/x sys_errlist > $1 = 0x80624fc > > (Thus inside the shared lib.) No it's not. It's at 20ec, in the image -- and is in the data segment of the in core image. You are dereferencing the thing. The compiler can not generate a post-link reference to the data in a shared library unless it knows where the data will be mapped in memory. Because shared library sizes can be changed, this is impossible to know in advance if you are using two or more shared libraries, since if the first one changes size, the second one may be mapped at a different location. The Microsoft compiler knows to do this because of __declspec(dllimport); the FreeBSD compiler doesn't know this because you can't tell it to generate different code... it doesn't have "__declspec" Are you claiming that the image is "fixed up" for all references? If it were, then the idea of "shared code" would go out the window. Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.