Date: Wed, 23 Apr 1997 10:41:17 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: msmith@atrad.adelaide.edu.au (Michael Smith) Cc: terry@lambert.org, msmith@atrad.adelaide.edu.au, rssh@cki.ipri.kiev.ua, freebsd-hackers@FreeBSD.org Subject: Re: Dynamic linking libraries [Q] Message-ID: <199704231741.KAA29305@phaeton.artisoft.com> In-Reply-To: <199704230223.LAA18646@genesis.atrad.adelaide.edu.au> from "Michael Smith" at Apr 23, 97 11:53:21 am
next in thread | previous in thread | raw e-mail | index | archive | help
> > > If you are referring to interprocess communication using static > > > variables in a DLL, I think people here might be very ill. 8) > > > > I believe what he is referring to is that the MS executables put the > > library-specific data segment into the DLL rather than statically > > linking it with the program, as BSD does. > > Um, you are saying that if I link against a shared library, the > .data segment from that library is linked into my executable at > compile time? > > I honestly cannot believe that this is the case. eg. : [ ... strings of testprog ... ] > I certainly don't see the static data from libc there. 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: % nm testprog 00001020 F /usr/lib/crt0.o 000015a0 F /var/tmp/cc0292711.o 00002000 d __DYNAMIC 000020e4 B ___CTOR_LIST__ 000020dc B ___DTOR_LIST__ 000015f8 T ___do_global_ctors 000015d0 T ___do_global_dtors 000015a0 t ___gnu_compiled_c 00001650 T ___main 000020a8 D ___progname 000020c4 D __exit_dummy_decl 000020b4 D __exit_dummy_ref 000015d0 F __main.o 00001460 T _dlclose 000014bc T _dlerror 0000143c T _dlopen 00001484 T _dlsym 000020d4 D _edata 00002234 B _end 0000222c B _environ 00002230 B _errno 00001a38 T _etext 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. One of the benefits of ELF is that, using segment coloring, you can refer to multiple image data segments. Consider: how would the compiler *know* to generate relative references for the symbol sys_errlist so that when the data wass loaded from the library, the code referenced the load location (which was not static)? The way this is done in Microsoft-land is to explicitly tag the reference to the compiler in the header file. For the Microsoft-land equivalent, we would have: extern __declspec(dllimport) __const char *__const sys_errlist[]; Instead of the FreeBSD: extern __const char *__const sys_errlist[]; To notify the compiler that it should generate indirect-through-vtable references to the variable, instead of direct references. Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704231741.KAA29305>