Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Apr 1997 16:37:30 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        joerg_wunsch@uriah.heep.sax.de
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Dynamic linking libraries [Q]
Message-ID:  <199704232337.QAA29885@phaeton.artisoft.com>
In-Reply-To: <19970423211522.OX52607@uriah.heep.sax.de> from "J Wunsch" at Apr 23, 97 09:15:22 pm

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



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