2014-03-27 2 views
0
내가 .O 다음과 같이 GCC와 공유 라이브러리를 만들 .S를 컴파일 NASM (64)를 사용하고

:NASM 문제 재배치 R_X86_64_PC32 공유 라이브러리

nasm -f elf64 source/strlen.S 
nasm -f elf64 source/strchr.S 
nasm -f elf64 source/memset.S 
nasm -f elf64 source/strcspn.S 
nasm -f elf64 source/rindex.S 
nasm -f elf64 source/strpbrk.S 
nasm -f elf64 source/strcmp.S 
nasm -f elf64 source/strncmp.S 
nasm -f elf64 source/strcasecmp.S 
/usr/bin/gcc -shared ./source/strlen.o ./source/strchr.o ./source/memset.o ./source/strcspn.o ./source/rindex.o ./source/strpbrk.o ./source/strcmp.o ./source/strncmp.o ./source/strcasecmp.o -o libasm.so 

소스/rindex.S가있는 fonction의 strlen 함수를 호출 소스/strlen.S 컴파일 라인에 오류가 던져 다음 .S를 컴파일하지만 NASM을 사용하고 때

/usr/bin/ld: ./source/rindex.o: relocation R_X86_64_PC32 against symbol `strlen' can not be used when making a shared object; recompile with -fPIC 

내가 GCC와 -fPIC 옵션을 사용할 수와 나는 이에 해당하는 옵션을 찾을 수 없습니다.

누군가이 문제를 어떻게 피할 수 있는지 알고 있습니까?

미리 감사드립니다.

답변

1

위치 독립적 코드를 작성해야합니다. DEFAULT RELREL 키워드 자체가 도움이 될 수 있습니다.

관련 문제