'relocation R_X86_64_32 against symbol `G8' can not be used when making a PIE object; recompile with -fPIE
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|