From owner-freebsd-hackers Thu Apr 24 07:01:51 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA07476 for hackers-outgoing; Thu, 24 Apr 1997 07:01:51 -0700 (PDT) Received: from aviion.ts.kiev.ua (aviion.ts.kiev.ua [193.124.229.12]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id HAA07449 for ; Thu, 24 Apr 1997 07:01:03 -0700 (PDT) Received: from nbki.ipri.kiev.ua by aviion.ts.kiev.ua with ESMTP id NAA23506; (8.6.11/zah/2.1) Thu, 24 Apr 1997 13:20:46 GMT Received: from cki.ipri.kiev.ua by nbki.ipri.kiev.ua with ESMTP id NAA01002; (8.6.9/zah/1.1) Thu, 24 Apr 1997 13:26:20 +0100 Received: from 194.44.146.14 (mac.ipri.kiev.ua [194.44.146.14]) by cki.ipri.kiev.ua (8.7.6/8.7.3) with SMTP id NAA24478; Thu, 24 Apr 1997 13:34:09 +0300 (EET DST) Message-ID: <335F299C.843@cki.ipri.kiev.ua> Date: Thu, 24 Apr 1997 12:36:22 +0300 From: Ruslan Shevchenko Reply-To: rssh@cki.ipri.kiev.ua Organization: IPRI X-Mailer: Mozilla 3.01Gold (Macintosh; I; 68K) MIME-Version: 1.0 To: Terry Lambert CC: joerg_wunsch@uriah.heep.sax.de, freebsd-hackers@FreeBSD.ORG Subject: Re: Dynamic linking libraries [Q] References: <199704232337.QAA29885@phaeton.artisoft.com> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Terry Lambert wrote: > > > > 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. > But we can do pointer to the data, which have p[ost0link reference (i.e. we have lib_cln.so, which stab to lib-manager, and lib_srv.so, which really lib) > 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. What means fixed-up ? > > Regards, > Terry Lambert > terry@lambert.org > --- > Any opinions in this posting are my own and not those of my present > or previous employers.