Better solution for ARM64 build fix (#315)

This commit is contained in:
David CARLIER
2020-04-12 15:55:52 +01:00
committed by GitHub
parent 5a8db5954c
commit 7919545499
14 changed files with 53 additions and 57 deletions

View File

@ -61,7 +61,6 @@
#include <termios.h>
#include <dlfcn.h>
#include <sched.h>
#include <inttypes.h>
#include <sys/wait.h>
#include <sys/time.h>

View File

@ -29,7 +29,6 @@
#define __AFL_FORKSERVER_H
#include <stdio.h>
#include <inttypes.h>
typedef struct afl_forkserver {
@ -98,9 +97,9 @@ void afl_fsrv_killall();
#endif
#ifdef RLIMIT_AS
#define MSG_ULIMIT_USAGE " ( ulimit -Sv $[%" PRIu64 " << 10];"
#define MSG_ULIMIT_USAGE " ( ulimit -Sv $[%llu << 10];"
#else
#define MSG_ULIMIT_USAGE " ( ulimit -Sd $[%" PRIu64 " << 10];"
#define MSG_ULIMIT_USAGE " ( ulimit -Sd $[%llu << 10];"
#endif /* ^RLIMIT_AS */
#endif

View File

@ -46,7 +46,7 @@ typedef uint32_t u32;
*/
#ifdef __x86_64__
#if defined(__x86_64__) || defined(__aarch64__)
typedef unsigned long long u64;
#else
typedef uint64_t u64;

View File

@ -909,7 +909,7 @@ int main(int argc, char **argv, char **envp) {
}
if (sscanf(optarg, "%" PRIu64 "%c", &mem_limit, &suffix) < 1 ||
if (sscanf(optarg, "%llu%c", &mem_limit, &suffix) < 1 ||
optarg[0] == '-')
FATAL("Bad syntax used for -m");
@ -1013,7 +1013,7 @@ int main(int argc, char **argv, char **envp) {
read_initial_file();
ACTF("Performing dry run (mem limit = %" PRIu64 " MB, timeout = %u ms%s)...",
ACTF("Performing dry run (mem limit = %llu MB, timeout = %u ms%s)...",
mem_limit, exec_tmout, edges_only ? ", edges only" : "");
run_target(use_argv, in_data, in_len, 1);

View File

@ -26,7 +26,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <inttypes.h>
#include "debug.h"
#include "alloc-inl.h"
@ -455,13 +454,13 @@ u8 *stringify_int(u8 *buf, size_t len, u64 val) {
} while (0)
/* 0-9999 */
CHK_FORMAT(1, 10000, "%" PRIu64, u64);
CHK_FORMAT(1, 10000, "%llu", u64);
/* 10.0k - 99.9k */
CHK_FORMAT(1000, 99.95, "%0.01fk", double);
/* 100k - 999k */
CHK_FORMAT(1000, 1000, "%" PRIu64 "k", u64);
CHK_FORMAT(1000, 1000, "%lluk", u64);
/* 1.00M - 9.99M */
CHK_FORMAT(1000 * 1000, 9.995, "%0.02fM", double);
@ -470,7 +469,7 @@ u8 *stringify_int(u8 *buf, size_t len, u64 val) {
CHK_FORMAT(1000 * 1000, 99.95, "%0.01fM", double);
/* 100M - 999M */
CHK_FORMAT(1000 * 1000, 1000, "%" PRIu64 "M", u64);
CHK_FORMAT(1000 * 1000, 1000, "%lluM", u64);
/* 1.00G - 9.99G */
CHK_FORMAT(1000LL * 1000 * 1000, 9.995, "%0.02fG", double);
@ -522,13 +521,13 @@ u8 *stringify_float(u8 *buf, size_t len, double val) {
u8 *stringify_mem_size(u8 *buf, size_t len, u64 val) {
/* 0-9999 */
CHK_FORMAT(1, 10000, "%" PRIu64 " B", u64);
CHK_FORMAT(1, 10000, "%llu B", u64);
/* 10.0k - 99.9k */
CHK_FORMAT(1024, 99.95, "%0.01f kB", double);
/* 100k - 999k */
CHK_FORMAT(1024, 1000, "%" PRIu64 " kB", u64);
CHK_FORMAT(1024, 1000, "%llu kB", u64);
/* 1.00M - 9.99M */
CHK_FORMAT(1024 * 1024, 9.995, "%0.02f MB", double);
@ -537,7 +536,7 @@ u8 *stringify_mem_size(u8 *buf, size_t len, u64 val) {
CHK_FORMAT(1024 * 1024, 99.95, "%0.01f MB", double);
/* 100M - 999M */
CHK_FORMAT(1024 * 1024, 1000, "%" PRIu64 " MB", u64);
CHK_FORMAT(1024 * 1024, 1000, "%llu MB", u64);
/* 1.00G - 9.99G */
CHK_FORMAT(1024LL * 1024 * 1024, 9.995, "%0.02f GB", double);
@ -615,13 +614,13 @@ u8 *u_stringify_int(u8 *buf, u64 val) {
} while (0)
/* 0-9999 */
CHK_FORMAT(1, 10000, "%" PRIu64, u64);
CHK_FORMAT(1, 10000, "%llu", u64);
/* 10.0k - 99.9k */
CHK_FORMAT(1000, 99.95, "%0.01fk", double);
/* 100k - 999k */
CHK_FORMAT(1000, 1000, "%" PRIu64 "k", u64);
CHK_FORMAT(1000, 1000, "%lluk", u64);
/* 1.00M - 9.99M */
CHK_FORMAT(1000 * 1000, 9.995, "%0.02fM", double);
@ -630,7 +629,7 @@ u8 *u_stringify_int(u8 *buf, u64 val) {
CHK_FORMAT(1000 * 1000, 99.95, "%0.01fM", double);
/* 100M - 999M */
CHK_FORMAT(1000 * 1000, 1000, "%" PRIu64 "M", u64);
CHK_FORMAT(1000 * 1000, 1000, "%lluM", u64);
/* 1.00G - 9.99G */
CHK_FORMAT(1000LL * 1000 * 1000, 9.995, "%0.02fG", double);
@ -681,13 +680,13 @@ u8 *u_stringify_float(u8 *buf, double val) {
u8 *u_stringify_mem_size(u8 *buf, u64 val) {
/* 0-9999 */
CHK_FORMAT(1, 10000, "%" PRIu64 " B", u64);
CHK_FORMAT(1, 10000, "%llu B", u64);
/* 10.0k - 99.9k */
CHK_FORMAT(1024, 99.95, "%0.01f kB", double);
/* 100k - 999k */
CHK_FORMAT(1024, 1000, "%" PRIu64 " kB", u64);
CHK_FORMAT(1024, 1000, "%llu kB", u64);
/* 1.00M - 9.99M */
CHK_FORMAT(1024 * 1024, 9.995, "%0.02f MB", double);
@ -696,7 +695,7 @@ u8 *u_stringify_mem_size(u8 *buf, u64 val) {
CHK_FORMAT(1024 * 1024, 99.95, "%0.01f MB", double);
/* 100M - 999M */
CHK_FORMAT(1024 * 1024, 1000, "%" PRIu64 " MB", u64);
CHK_FORMAT(1024 * 1024, 1000, "%llu MB", u64);
/* 1.00G - 9.99G */
CHK_FORMAT(1024LL * 1024 * 1024, 9.995, "%0.02f GB", double);

View File

@ -38,7 +38,6 @@
#include <time.h>
#include <errno.h>
#include <signal.h>
#include <inttypes.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>

View File

@ -441,7 +441,7 @@ u8 *describe_op(afl_state_t *afl, u8 hnb) {
sprintf(ret, "src:%06u", afl->current_entry);
sprintf(ret + strlen(ret), ",time:%" PRIu64, get_cur_time() - afl->start_time);
sprintf(ret + strlen(ret), ",time:%llu", get_cur_time() - afl->start_time);
if (afl->splicing_with >= 0)
sprintf(ret + strlen(ret), "+%06d", afl->splicing_with);
@ -659,12 +659,12 @@ u8 save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
#ifndef SIMPLE_FILES
snprintf(fn, PATH_MAX, "%s/hangs/id:%06" PRIu64 ",%s", afl->out_dir,
snprintf(fn, PATH_MAX, "%s/hangs/id:%06llu,%s", afl->out_dir,
afl->unique_hangs, describe_op(afl, 0));
#else
snprintf(fn, PATH_MAX, "%s/hangs/id_%06" PRIu64, afl->out_dir,
snprintf(fn, PATH_MAX, "%s/hangs/id_%06llu", afl->out_dir,
afl->unique_hangs);
#endif /* ^!SIMPLE_FILES */
@ -703,12 +703,12 @@ u8 save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
#ifndef SIMPLE_FILES
snprintf(fn, PATH_MAX, "%s/crashes/id:%06" PRIu64 ",sig:%02u,%s", afl->out_dir,
snprintf(fn, PATH_MAX, "%s/crashes/id:%06llu,sig:%02u,%s", afl->out_dir,
afl->unique_crashes, afl->kill_signal, describe_op(afl, 0));
#else
snprintf(fn, PATH_MAX, "%s/crashes/id_%06" PRIu64 "_%02u", afl->out_dir,
snprintf(fn, PATH_MAX, "%s/crashes/id_%06llu_%02u", afl->out_dir,
afl->unique_crashes, afl->kill_signal);
#endif /* ^!SIMPLE_FILES */

View File

@ -494,7 +494,7 @@ void perform_dry_run(afl_state_t *afl) {
if (afl->stop_soon) return;
if (res == afl->crash_mode || res == FAULT_NOBITS)
SAYF(cGRA " len = %u, map size = %u, exec speed = %" PRIu64 " us\n" cRST,
SAYF(cGRA " len = %u, map size = %u, exec speed = %llu us\n" cRST,
q->len, q->bitmap_size, q->exec_us);
switch (res) {
@ -1051,8 +1051,8 @@ static void handle_existing_out_dir(afl_state_t *afl) {
u64 start_time2, last_update;
if (fscanf(f,
"start_time : %" PRIu64 "\n"
"last_update : %" PRIu64 "\n",
"start_time : %llu\n"
"last_update : %llu\n",
&start_time2, &last_update) != 2)
FATAL("Malformed data in '%s'", fn);
@ -1602,7 +1602,7 @@ void check_cpu_governor(afl_state_t *afl) {
if (f) {
if (fscanf(f, "%" PRIu64, &min) != 1) min = 0;
if (fscanf(f, "%llu", &min) != 1) min = 0;
fclose(f);
}
@ -1611,7 +1611,7 @@ void check_cpu_governor(afl_state_t *afl) {
if (f) {
if (fscanf(f, "%" PRIu64, &max) != 1) max = 0;
if (fscanf(f, "%llu", &max) != 1) max = 0;
fclose(f);
}
@ -1620,7 +1620,7 @@ void check_cpu_governor(afl_state_t *afl) {
SAYF("\n" cLRD "[-] " cRST
"Whoops, your system uses on-demand CPU frequency scaling, adjusted\n"
" between %" PRIu64 " and %" PRIu64 " MHz. Unfortunately, the scaling algorithm in "
" between %llu and %llu MHz. Unfortunately, the scaling algorithm in "
"the\n"
" kernel is imperfect and can miss the short-lived processes spawned "
"by\n"

View File

@ -405,7 +405,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
if (unlikely(afl->not_on_tty)) {
ACTF("Fuzzing test case #%u (%u total, %" PRIu64 " uniq crashes found)...",
ACTF("Fuzzing test case #%u (%u total, %llu uniq crashes found)...",
afl->current_entry, afl->queued_paths, afl->unique_crashes);
fflush(stdout);
@ -2432,7 +2432,7 @@ u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) {
if (afl->not_on_tty) {
ACTF("Fuzzing test case #%u (%u total, %" PRIu64 " uniq crashes found)...",
ACTF("Fuzzing test case #%u (%u total, %llu uniq crashes found)...",
afl->current_entry, afl->queued_paths, afl->unique_crashes);
fflush(stdout);

View File

@ -89,7 +89,7 @@ u8 run_target(afl_state_t *afl, afl_forkserver_t *fsrv, u32 timeout) {
"Unable to communicate with fork server. Some possible reasons:\n\n"
" - You've run out of memory. Use -m to increase the the memory "
"limit\n"
" to something higher than %" PRIu64 ".\n"
" to something higher than %lld.\n"
" - The binary or one of the libraries it uses manages to "
"create\n"
" threads before the forkserver initializes.\n"

View File

@ -70,13 +70,13 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
fprintf(
f,
"start_time : %" PRIu64 "\n"
"last_update : %lld\n"
"run_time : %lld\n"
"start_time : %llu\n"
"last_update : %llu\n"
"run_time : %llu\n"
"fuzzer_pid : %d\n"
"cycles_done : %" PRIu64 "\n"
"cycles_wo_finds : %" PRIu64 "\n"
"execs_done : %" PRIu64 "\n"
"cycles_done : %llu\n"
"cycles_wo_finds : %llu\n"
"execs_done : %llu\n"
"execs_per_sec : %0.02f\n"
// "real_execs_per_sec: %0.02f\n" // damn the name is too long
"paths_total : %u\n"
@ -90,12 +90,12 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
"variable_paths : %u\n"
"stability : %0.02f%%\n"
"bitmap_cvg : %0.02f%%\n"
"unique_crashes : %" PRIu64 "\n"
"unique_hangs : %" PRIu64 "\n"
"last_path : %" PRIu64 "\n"
"last_crash : %" PRIu64 "\n"
"last_hang : %" PRIu64 "\n"
"execs_since_crash : %" PRIu64 "\n"
"unique_crashes : %llu\n"
"unique_hangs : %llu\n"
"last_path : %llu\n"
"last_crash : %llu\n"
"last_hang : %llu\n"
"execs_since_crash : %llu\n"
"exec_timeout : %u\n"
"slowest_exec_ms : %u\n"
"peak_rss_mb : %lu\n"
@ -171,7 +171,7 @@ void maybe_update_plot_file(afl_state_t *afl, double bitmap_cvg, double eps) {
execs_per_sec */
fprintf(afl->fsrv.plot_file,
"%" PRIu64 ", %" PRIu64 ", %u, %u, %u, %u, %0.02f%%, %" PRIu64 ", %" PRIu64 ", %u, %0.02f\n",
"%llu, %llu, %u, %u, %u, %u, %0.02f%%, %llu, %llu, %u, %0.02f\n",
get_cur_time() / 1000, afl->queue_cycle - 1, afl->current_entry,
afl->queued_paths, afl->pending_not_fuzzed, afl->pending_favored,
bitmap_cvg, afl->unique_crashes, afl->unique_hangs, afl->max_depth,

View File

@ -427,7 +427,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
if (sscanf(optarg, "%" PRIu64 "%c", &afl->fsrv.mem_limit, &suffix) < 1 ||
if (sscanf(optarg, "%llu%c", &afl->fsrv.mem_limit, &suffix) < 1 ||
optarg[0] == '-')
FATAL("Bad syntax used for -m");
@ -537,7 +537,7 @@ int main(int argc, char **argv_orig, char **envp) {
case 'V': {
afl->most_time_key = 1;
if (sscanf(optarg, "%" PRIu64, &afl->most_time) < 1 || optarg[0] == '-')
if (sscanf(optarg, "%llu", &afl->most_time) < 1 || optarg[0] == '-')
FATAL("Bad syntax used for -V");
} break;
@ -545,7 +545,7 @@ int main(int argc, char **argv_orig, char **envp) {
case 'E': {
afl->most_execs_key = 1;
if (sscanf(optarg, "%" PRIu64, &afl->most_execs) < 1 || optarg[0] == '-')
if (sscanf(optarg, "%llu", &afl->most_execs) < 1 || optarg[0] == '-')
FATAL("Bad syntax used for -E");
} break;
@ -556,7 +556,7 @@ int main(int argc, char **argv_orig, char **envp) {
afl->limit_time_sig = 1;
afl->havoc_max_mult = HAVOC_MAX_MULT_MOPT;
if (sscanf(optarg, "%" PRIu64, &afl->limit_time_puppet) < 1 ||
if (sscanf(optarg, "%llu", &afl->limit_time_puppet) < 1 ||
optarg[0] == '-')
FATAL("Bad syntax used for -L");
@ -566,7 +566,7 @@ int main(int argc, char **argv_orig, char **envp) {
FATAL("limit_time overflow");
afl->limit_time_puppet = limit_time_puppet2;
SAYF("limit_time_puppet %" PRIu64 "\n", afl->limit_time_puppet);
SAYF("limit_time_puppet %llu\n", afl->limit_time_puppet);
afl->swarm_now = 0;
if (afl->limit_time_puppet == 0) afl->key_puppet = 1;
@ -1079,7 +1079,7 @@ int main(int argc, char **argv_orig, char **envp) {
if (unlikely(afl->not_on_tty)) {
ACTF("Entering queue cycle %" PRIu64 ".", afl->queue_cycle);
ACTF("Entering queue cycle %llu.", afl->queue_cycle);
fflush(stdout);
}

View File

@ -720,7 +720,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
if (sscanf(optarg, "%" PRIu64 "%c", &fsrv->mem_limit, &suffix) < 1 ||
if (sscanf(optarg, "%llu%c", &fsrv->mem_limit, &suffix) < 1 ||
optarg[0] == '-')
FATAL("Bad syntax used for -m");

View File

@ -989,7 +989,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
if (sscanf(optarg, "%" PRIu64 "%c", &fsrv->mem_limit, &suffix) < 1 ||
if (sscanf(optarg, "%llu%c", &fsrv->mem_limit, &suffix) < 1 ||
optarg[0] == '-')
FATAL("Bad syntax used for -m");
@ -1134,7 +1134,7 @@ int main(int argc, char **argv_orig, char **envp) {
afl_fsrv_start(fsrv, use_argv, &stop_soon,
get_afl_env("AFL_DEBUG_CHILD_OUTPUT") ? 1 : 0);
ACTF("Performing dry run (mem limit = %" PRIu64 " MB, timeout = %u ms%s)...",
ACTF("Performing dry run (mem limit = %llu MB, timeout = %u ms%s)...",
fsrv->mem_limit, fsrv->exec_tmout, edges_only ? ", edges only" : "");
run_target(fsrv, use_argv, in_data, in_len, 1);