Merge pull request #1565 from semarie/openbsd-pie

openbsd: defaults to PIE executable
This commit is contained in:
gingerBill
2022-02-28 16:11:59 +00:00
committed by GitHub
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,

View File

@@ -463,7 +463,8 @@ i32 linker_stage(lbGenerator *gen) {
#endif
link_settings = gb_string_appendc(link_settings, "-Wl,-init,'_odin_entry_point' ");
link_settings = gb_string_appendc(link_settings, "-Wl,-fini,'_odin_exit_point' ");
} else {
} else if (build_context.metrics.os != TargetOs_openbsd) {
// OpenBSD defaults to PIE executable. do not pass -no-pie for it.
link_settings = gb_string_appendc(link_settings, "-no-pie ");
}
if (build_context.out_filepath.len > 0) {