[linux] change default settings to enable pie and full relro

This commit is contained in:
A1029384756
2026-06-06 21:23:26 -04:00
parent 23f57a4328
commit 43b057dfeb
3 changed files with 23 additions and 11 deletions

View File

@@ -1898,6 +1898,20 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
}
break;
}
} else if (metrics->os == TargetOs_linux) {
if (bc->reloc_mode == RelocMode_Default) {
bc->reloc_mode = RelocMode_PIC;
}
} else if (metrics->os == TargetOs_openbsd) {
// Always use PIC for OpenBSD: it defaults to PIE
if (bc->reloc_mode == RelocMode_Default) {
bc->reloc_mode = RelocMode_PIC;
}
} else if (metrics->arch == TargetArch_riscv64) {
// NOTE(laytan): didn't seem to work without this.
if (bc->reloc_mode == RelocMode_Default) {
bc->reloc_mode = RelocMode_PIC;
}
} else if (metrics->os == TargetOs_linux && subtarget == Subtarget_Android) {
switch (metrics->arch) {
case TargetArch_arm64: