[c] "main.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC" 해결 방법.
2022. 5. 26. 13:46ㆍLanguage/c
728x90
728x90
Makefile으로컴파일수행간, 하단과같은에러발생확인.
$ make
cc -o vmdecrypt main.o -ldl ~/libvmdecrypt.so -L~/lib64 -lssl -lcrypto
/usr/bin/ld: main.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:58: recipe for target 'vmdecrypt' failed
make: *** [vmdecrypt] Error 1
에러 발생하는 원인.
- https://stackoverflow.com/questions/67545995/gcc-promotes-weird-relocation-r-x86-64-32s-error-but-not-in-manually-linking
- https://krlrhkstk12.gitbook.io/hubcodes/engineering/general/undefined-1
"/usr/bin/ld: main.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC" 해결 방법.
컴파일 명령어 라인에 "-no-pie" 옵션 추가.
Makefile 수정.
Makefile에 "-no-pie" 옵션 추가 후 컴파일 동작을 확인.
$ make
cc -o vmdecrypt main.o -ldl ~/libvmdecrypt.so -L~/lib64 -lssl -lcrypto -no-pie
[Make Build Mode => Release]
cc 매뉴얼 참고.
1.pie
- Produce a position independent executable on targets that support it. For predictable results, you must also specify the same set of options used for compilation (-fpie, -fPIE, or model suboptions) when you specify this linker option.
2.no-pie
- Don't produce a position independent executable.
728x90
728x90
'Language > c' 카테고리의 다른 글
[c] linux TCP/IP socket code(*.c, TCPIP 소켓 코드) (0) | 2021.12.20 |
---|---|
[c] window TCP/IP socket code(*.c, TCPIP 소켓 코드) (0) | 2021.12.17 |