I'm not so familiar with the 64 bit versions of Linux, but the 32 bit ones 
used the MMU to map each process identically.  All programs were loaded at 
the same logical address in each process.  If I remember right, it was 
loaded toward high memory, leaving low memory available for shared memory, 
shared libraries, etc.

So a statically linked program would be loaded at that high address, 
including all the .o files extracted from the .a libraries and physically 
included in the binary file.  The shared libraries would be loaded at 
arbitrary addresses in the lower address space.  The "arbitrary" making 
relocatable binary format all but required (for shared libraries).

At least that's my understanding.

Anyhow, I ran into this issue (the relocation error) when trying to mix 
static and shared libraries and using dlopen() to load .so files at run 
time on top of that.  The only solution I found after 10+ hours of trial 
and error (and reading lots of googled www pages) was to make as much of 
the linking against dynamic libraries as possible.  Though for some of 
those dlopen() .so files, linking in entire static libraries worked in some 
cases.

You can link with static libraries two ways:
-Lpath/to/static/libraries -llibrary
or
liblibrary.a (just like any .o)

The former pulls in the .o's referenced in the .a only.  The latter 
includes the entire .a (all its .o files) in the resulting binary.


On Monday, July 2, 2012 4:39:11 AM UTC-7, Stephan Beal wrote:
>
> On Mon, Jul 2, 2012 at 1:13 PM, Michael Schwartz <[email protected]> wrote:
>
>> The more interesting question is why he thinks he needs -fPIC for a 
>> static library.  The error message indicates the elf file contains a 32-bit 
>> relocation and it needs to be a 64-bit one.  
>>
>
> FWIW: i had the same problem with libsqlite4.a (yes, 4) until i added 
> -fPIC to its build options.
>  
>
>> Position Independent Code (PIC) is typically (almost always) used in 
>> shared libraries.  
>>
>
> Ubuntu likes it to always be set :/.
>
> -- 
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
> http://gplus.to/sgbeal
>
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to