Recommend compiling with PIC consistently.

While shared objects with non-PIC code work on some architectures
(notably x86), unless code is always PIC on that arch (not true for x86)
doing so requires runtime relocations, which prevents the object
actually being shared, and means such segments can't be marked as
read-only.
This commit is contained in:
Olly Betts 2014-02-21 08:09:58 +13:00
commit de7ed84f77
7 changed files with 29 additions and 27 deletions

View file

@ -368,17 +368,12 @@ for a few common platforms is shown below:</p>
<div class="shell"><pre>
# Build a shared library for Solaris
gcc -c example.c example_wrap.c -I/usr/local/include
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
ld -G example.o example_wrap.o -o example.so
# Build a shared library for Linux
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
gcc -shared example.o example_wrap.o -o example.so
# Build a shared library for Irix
gcc -c example.c example_wrap.c -I/usr/local/include
ld -shared example.o example_wrap.o -o example.so
</pre></div>
<p>