Static libraries with fPIC on x86

john blair mailtome200420032002@yahoo.com
Tue Nov 3 18:33:00 GMT 2009


I have built openssl-0.9.8k and am trying to link libcrypto.a statically with my project. 
For example, consider the following:
#include <openssl/des.h>
void foo(void) {
            DES_encrypt3(NULL, NULL, NULL, NULL);
            AES_encrypt(NULL, NULL);

}

$ gcc -fPIC -o libfoo.so -shared foo.c /usr/lib/libcrypto.a
$ eu-findtextrel libfoo.so
the file containing the function 'DES_encrypt3' is not compiled with -fpic/-fPIC
the file containing the function 'DES_decrypt3' is not compiled with -fpic/-fPIC
the file containing the function 'DES_ncbc_encrypt' is not compiled with -fpic/-fPIC
the file containing the function 'DES_ede3_cbc_encrypt' is not compiled with -fpic/-fPIC

This does not happen on 64bit system and eu-findtextrel reports on text relocations. I think this is the default behavior on x86 systems.

Can someone point me to why building static libs on 32 bit system with fPIC is a bad idea?
Also, if I want to build the static lib with fPIC, how do I go about it? All the .o files are built with fPIC

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list