Currently, with -fPIC,
We see this:
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIC Level", i32 2}
and module.getPICLevel() is used to query PIC. I am doing the same for PIE.
I will follow this up with patches to:
- Set PIE Level in LLVM in Clang and delete llvm::TargetOptions::PositionIndependentExecutable target member.
- Use Module::getPIELevel to check for PIE.