mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-12 22:33:36 +00:00
Merge pull request #4449 from 0dminnimda/add-pie
Link as PIE for PIC by default
This commit is contained in:
@@ -453,7 +453,7 @@ struct BuildContext {
|
||||
bool no_threaded_checker;
|
||||
|
||||
bool show_debug_messages;
|
||||
|
||||
|
||||
bool copy_file_contents;
|
||||
|
||||
bool no_rtti;
|
||||
|
||||
@@ -605,9 +605,18 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_appendc(link_settings, "-Wl,-fini,'_odin_exit_point' ");
|
||||
}
|
||||
|
||||
} else if (build_context.metrics.os != TargetOs_openbsd && build_context.metrics.os != TargetOs_haiku && build_context.metrics.arch != TargetArch_riscv64) {
|
||||
// OpenBSD and Haiku default to PIE executable. do not pass -no-pie for it.
|
||||
link_settings = gb_string_appendc(link_settings, "-no-pie ");
|
||||
}
|
||||
|
||||
if (build_context.build_mode == BuildMode_Executable && build_context.reloc_mode == RelocMode_PIC) {
|
||||
// Do not disable PIE, let the linker choose. (most likely you want it enabled)
|
||||
} else if (build_context.build_mode != BuildMode_DynamicLibrary) {
|
||||
if (build_context.metrics.os != TargetOs_openbsd
|
||||
&& build_context.metrics.os != TargetOs_haiku
|
||||
&& build_context.metrics.arch != TargetArch_riscv64
|
||||
) {
|
||||
// OpenBSD and Haiku default to PIE executable. do not pass -no-pie for it.
|
||||
link_settings = gb_string_appendc(link_settings, "-no-pie ");
|
||||
}
|
||||
}
|
||||
|
||||
gbString platform_lib_str = gb_string_make(heap_allocator(), "");
|
||||
|
||||
Reference in New Issue
Block a user