This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
relocation problem
- From: Dzianis Barzakouski <barzakouski at googlemail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 11 Mar 2009 23:07:54 +0100
- Subject: relocation problem
Hi,
I am trying to compile following code:
===lib.c====
extern int foo();
int bar()
{
??? int j = foo();
??? return j;
}
==========
===add.c===
static int i = 0;
int foo()
{
??? __asm__("mov 42, %ax");
??? __asm__("mov %ax, i");
??? return i;
}
==========
gcc -fPIC -c -o lib.o lib.c
gcc -fPIC -c -o add.o add.c
gcc -shared lib.o add.o -o lib.so
/usr/bin/ld: add.o: relocation R_X86_64_32S against `a local symbol'
can not be used when making a shared object; recompile with -fPIC
I thought that is due static declaration but it removing don't solves
the problem. Is this expected behavior? If yes, can somebody explain?
Thanks,
Dzianis