openbsd: defaults to PIE executable

OpenBSD uses PIE code by default to allow the system to load the binary at a random location.

don't pass -no-pie to preserve this behaviour, and build objects with -fPIC (LLVMRelocPIC).
This commit is contained in:
Sébastien Marie
2022-02-28 15:24:22 +00:00
parent dd9843aa21
commit f76f70c7cf
2 changed files with 7 additions and 1 deletions

View File

@@ -1295,6 +1295,11 @@ void lb_generate_code(lbGenerator *gen) {
reloc_mode = LLVMRelocPIC;
}
if (build_context.metrics.os == TargetOs_openbsd) {
// Always use PIC for OpenBSD: it defaults to PIE
reloc_mode = LLVMRelocPIC;
}
for_array(i, gen->modules.entries) {
target_machines[i] = LLVMCreateTargetMachine(
target, target_triple, llvm_cpu,