Date: Mon, 24 Apr 95 11:17:00 MDT From: terry@cs.weber.edu (Terry Lambert) To: gena@NetVision.net.il (Gennady Sorokopud) Cc: hackers@FreeBSD.org Subject: Re: library conversion Message-ID: <9504241717.AA14701@cs.weber.edu> In-Reply-To: <199504230648.JAA29346@Burka.NetVision.net.il> from "Gennady Sorokopud" at Apr 23, 95 09:48:06 am
next in thread | previous in thread | raw e-mail | index | archive | help
> Is there any way to convert static library to shared? Not unless the builf procedure for static libraries is changed. > I succeded once with: > > ar x libxxx.o > ld *.o -Bshareable -o libxxx.so.1.0 > > But now when i try to run a program linked with such library > i get : ld.so failed :-( > > Any ideas? Yes. It failed because the code in the library was position dependent code that used resolved jump label locations instead of relative jumps in order to do its branching (among other things). A shared library on an i386/i486/i586 box must be specifically compiled as PIC (Position Independent Code). This is because it could be mapped at any location in the executing program's address space, and thus the position that the code occupies must not be assumed. Actually, I've been considering the issues involved in dynamically relocatining the data are of shared libraries as well so that there is not the possibility of a version mismatch based on globals or static locals changing, and have almost come to the conclusion that all code should be compiled PIC for this to happen. This would help greatly with virtual base classes in a shared C++ library, I think. Anyway, the easy answer is that there is no way to convert the code from non-PIC to PIC, so unless the static libraries are compiled PIC, there's no way to convert a static library to a shared library. Sorry. Terry Lambert terry@cs.weber.edu --- 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?9504241717.AA14701>