Bug 6342 - Shared library compiled without PIC
Summary: Shared library compiled without PIC
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Powertools
Classification: Retired
Component: libpcap
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-10-25 16:42 UTC by andrewem
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-02-17 19:51:42 UTC
Embargoed:


Attachments (Terms of Use)

Description andrewem 1999-10-25 16:42:33 UTC
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 16:51:59 UTC
assigning to owner of package.

Tim

Comment 2 andrewem 2000-01-13 17:17:59 UTC
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 19:51:59 UTC
Thanks, fixed.


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