libpython and position-independent code

Gregory (Grisha) Trubetskoy grisha at modpython.org
Wed Aug 22 15:00:51 EDT 2001


Hello there -

I am a bit puzzled by what significance PIC code has in shared libraries.
(This is Solaris 8, but I'm intersted in how this applies to other OS's
too)

While tinkering with libtool, I found that it wouldn't link libpython into
a shared library (mod_python.so), because libpython might not be PIC.

But, I can accomplish this without libtool with

ld -G -o mod_python.so mod_python.o _apachemodule.o requestobject.o \
      tableobject.o util.o serverobject.o connobject.o -lm \
      /usr/local/lib/python2.1/config/libpython2.1.a

Is the resulting mod_python.so unsafe to use somehow? It sure seems to
work just fine... Isn't it supposed to crash?

My searching of the net didn't turn up a lot of useful info on the
subject. The Python compile seems to not have the -fPIC option, so I'm
guessing libpython2.1.a isn't PIC indeed.

If it is indeed a problem, then what is the solution?

P.S. Recompiling Python with -fPIC didn't make libtool any happier
regarding libpython2.1.a - but that's just probably libtool suffering from
the "not invented here" syndrom. BTW, the reason I have to tinker with
libtool is because Apache 2.0 relies on it heavily.

Thanks,

Grisha






More information about the Python-list mailing list