SOLVED: relocation R_X86_64_32 against symbol `G8' can not be used when making a PIE object; recompile with -fPIE

↘锁芯ラ 提交于 2020-08-09 09:14:06

问题


I'm trying to compile lambda-expressions from scheme to llvm-ir and am having trouble with position independet code.

source:

(lambda (x) (display x)) 

target:

bunch of declares...
define %SObj* @G7() {
entry:
  %calltmp = call %SObj* @closure_create(i64 ptrtoint (%SObj* (%SObj*)* @G8 to i64), %SObj* null)
  ret %SObj* %calltmp
}

define %SObj* @G8(%SObj* %G6) {
entry:
  %calltmp = call %SObj* @display(%SObj* %G6)
  ret %SObj* %calltmp
}

define i32 @main(i32 %0, i8** %1) {
entry:
  %calltmp = call %SObj* @G7()
  %calltmp1 = call %SObj* @display(%SObj* %calltmp)
  ret i32 0
}

compiling this with:

llc code.ll && clang code.s -L/usr/lib -lgc -lSRuntime -o code -v

where code.ll is the printed ll-ir module gives me the error message:

/usr/bin/ld: /tmp/code-1c0b5f.o: relocation R_X86_64_32 against symbol `G8' can not be used when making a PIE object; recompile with -fPIE

Reading up on PIE doesn't quite help me solve my issue. Can someone explain me, why the ptrtoint cast in G7 causes the code to be non-PIC and how one would then implement such behaviour?

EDIT: Issue was solved by adding --relocation-model=pic to the llc call, which compiles the module

来源:https://stackoverflow.com/questions/62106371/solved-relocation-r-x86-64-32-against-symbol-g8-can-not-be-used-when-making-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!