afl-cc fixes

This commit is contained in:
vanhauser-thc
2023-12-07 16:15:18 +01:00
parent 5b655e0d59
commit bb1d4a2491

View File

@ -395,12 +395,16 @@ static void process_params(u32 argc, char **argv) {
} }
// reset
have_instr_list = 0;
have_c = 0;
if (lto_mode && argc > 1) { if (lto_mode && argc > 1) {
u32 idx; u32 idx;
for (idx = 1; idx < argc; idx++) { for (idx = 1; idx < argc; idx++) {
if (!strncasecmp(argv[idx], "-fpic", 5)) have_pic = 1; if (!strncasecmp(argv[idx], "-fpic", 5)) { have_pic = 1; }
} }
@ -689,6 +693,18 @@ static void edit_params(u32 argc, char **argv, char **envp) {
cc_params = ck_alloc(MAX_PARAMS_NUM * sizeof(u8 *)); cc_params = ck_alloc(MAX_PARAMS_NUM * sizeof(u8 *));
for (u32 c = 1; c < argc; ++c) {
if (!strcmp(argv[c], "-c")) have_c = 1;
if (!strncmp(argv[c], "-fsanitize-coverage-", 20) &&
strstr(argv[c], "list=")) {
have_instr_list = 1;
}
}
if (lto_mode) { if (lto_mode) {
if (lto_flag[0] != '-') if (lto_flag[0] != '-')
@ -1125,24 +1141,18 @@ static void edit_params(u32 argc, char **argv, char **envp) {
// cc_params[cc_par_cnt++] = "-Qunused-arguments"; // cc_params[cc_par_cnt++] = "-Qunused-arguments";
if (lto_mode && argc > 1) {
u32 idx;
for (idx = 1; idx < argc; idx++) {
if (!strncasecmp(argv[idx], "-fpic", 5)) have_pic = 1;
}
}
} }
/* Inspect the command line parameters. */ /* Inspect the command line parameters. */
process_params(argc, argv); process_params(argc, argv);
if (!have_pic) { cc_params[cc_par_cnt++] = "-fPIC"; } if (!have_pic) {
cc_params[cc_par_cnt++] = "-fPIC";
have_pic = 1;
}
if (compiler_mode != GCC_PLUGIN && compiler_mode != GCC && if (compiler_mode != GCC_PLUGIN && compiler_mode != GCC &&
!getenv("AFL_LLVM_NO_RPATH")) { !getenv("AFL_LLVM_NO_RPATH")) {