From f76f70c7cf369a7e247a52e0c36da2fbe8d960c6 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Mon, 28 Feb 2022 15:24:22 +0000 Subject: 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). --- src/llvm_backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/llvm_backend.cpp') diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 52c46cadc..3b11f95a2 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -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, -- cgit v1.2.3