Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Apr 1997 12:36:22 +0300
From:      Ruslan Shevchenko <rssh@cki.ipri.kiev.ua>
To:        Terry Lambert <terry@lambert.org>
Cc:        joerg_wunsch@uriah.heep.sax.de, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Dynamic linking libraries [Q]
Message-ID:  <335F299C.843@cki.ipri.kiev.ua>
References:  <199704232337.QAA29885@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?335F299C.843>