Bug 6342 - Shared library compiled without PIC
Shared library compiled without PIC
Status: CLOSED RAWHIDE
Product: Red Hat Powertools
Classification: Retired
Component: libpcap (Show other bugs)
6.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-10-25 12:42 EDT by andrewem
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-17 14:51:42 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description andrewem 1999-10-25 12:42:33 EDT
The Makefile creates both static and shared libraries from
the same objects.  Normally two sets of objects, one static
and one shared (built with -fPIC) would be produced for each
library, then linked.

On ARM this bug results in invalid relocs in the shared
library.  This could very possibly cause problems on other
architectures too.

It should be okay to just add -fPIC to the compile flags, as
it shouldn't have an adverse affect the static libs.

Additional: the spec file also uses the very EVIL construct
of setting the build prefix to the buildroot.  Although it
works, this time, this is NEVER a good idea!  One of these
days it will burn you.  The install prefix is what you
really want to change, which can be done in the %install
section in the make line(s).
Comment 1 Tim Powers 1999-10-25 12:51:59 EDT
assigning to owner of package.

Tim
Comment 2 andrewem 2000-01-13 12:17:59 EST
The problem affects all architechtures, but is troublesome on ARM and PowerPC.

The problem stems from relocs in the text segment.  In a shared library, you
cannot do the reloc because then it would screw up everyone sharing that
library.  On some architectures (like x86), this is handled transparently by the
dynamic linker/loader.  In this case, the text segment is copied, made
writeable, and then the reloc is done.  Of course the library is no longer
really shared as there are now multiple images in memory :(

This can be implimented to some extent on ARM as well, except that the reloc
can't be over 32 MB (PC24 reloc = 26 bit offset, 4 byte aligned) as that's the
largest immediate offset allowed.  So it isn't a reliable kludge.

On the other hand, PIC uses references to the GOT and PLT (PC32 relocs) which
solves the problem entirely on all architechtures.

[Perl is also an offender, as libperl.a and DynaLoader.a are not PIC, but are
linked by dynamically loaded modules like mod_perl.]

Summary: shared libraries and dynmaically loaded modules should only contain and
be linked to PIC code.
Comment 3 Bernhard Rosenkraenzer 2000-02-17 14:51:59 EST
Thanks, fixed.

Note You need to log in before you can comment on or make changes to this bug.