This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static libraries with fPIC on x86


john blair wrote:
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?

It slows things down a bit because 32 bit x86 doesn't have PC-relative addressing.


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

Then I don't know why it hasn't worked. It always works for me.


Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]