I saw this problem can be fixed with adding -fPIC
but i tried and faild. I don't use makefile a lot, so maybe I didn't add it correctly. (Its assembly code).
This is my makefile:
PROGRAM = calc
ASFLAGS = -gstabs
CFLAGS = -g -Wall -pedantic
.PHONY: clean
$(PROGRAM): $(PROGRAM).o
gcc $(CFLAGS) -o $(PROGRAM) $(PROGRAM).o
$(PROGRAM).o: $(PROGRAM).s
as $(ASFLAGS) -o $(PROGRAM).o $(PROGRAM).s
clean:
rm -f *.o
rm -f $(PROGRAM)
rm -f *~
And this is the problem:
/usr/bin/ld: calc.o: relocation R_X86_64_32S against `.data' can not be
used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit sta
Where should I add -fPIC
in makefile?
I get this error with other codes just different '.something'.