diff options
| author | 2025-09-14 17:59:39 +0200 | |
|---|---|---|
| committer | 2025-09-14 18:24:05 +0200 | |
| commit | 7a318363ec4fdcd80d9d0154cef393c9bf205d5e (patch) | |
| tree | c254e3a3b985bc22e84480346c856052ef9963ca /main.c | |
| parent | 5753e393954aca532abd6a5c10d6e8ab9a96c96c (diff) | |
preliminary pie and pic
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -131,6 +131,16 @@ optparse(char **args) if (arg[1]) task.out = arg+1; else if (args[1]) task.out = *++args; else goto Bad; + } else if (*arg == 'f') { + const char *flag = arg+1; + bool set = 1; + if (!strncmp(flag, "no-", 3)) { + set = 0; + flag += 3; + } + if (!strcmp(flag, "pie") || !strcmp(flag, "PIE")) ccopt.pie = set; + else if (!strcmp(flag, "pic") || !strcmp(flag, "PIC")) ccopt.pic = set; + else goto Bad; } else if (!strcmp(arg, "v") || !strcmp(arg, "-verbose")) { task.verbose = 1; } else if (!strcmp(arg, "c")) { @@ -242,8 +252,9 @@ dolink(void) vpush(&cmd, "/bin/gcc"); if (task.outft == OFTdll) { vpush(&cmd, "-shared"); + } else if (task.outft == OFTexe) { + vpush(&cmd, ccopt.pie ? "-pie" : "-no-pie"); } - vpush(&cmd, "-no-pie"); vpush(&cmd, "-o"); vpush(&cmd, task.out); assert(task.ninf > 0); @@ -335,6 +346,7 @@ main(int argc, char **argv) /* setup defaults */ detectcolor(); ccopt.cstd = STDC99; + ccopt.pie = 1; /* parse cli ags */ optparse(argv); |