about summary refs log tree commit diff
path: root/llvm_mode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/afl-clang-fast.c42
-rw-r--r--llvm_mode/afl-ld.c68
-rw-r--r--llvm_mode/afl-llvm-rt.o.c42
3 files changed, 76 insertions, 76 deletions
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index bd2579c0..9caa7111 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -37,20 +37,20 @@
 #include <limits.h>
 #include <assert.h>
 
-static u8*  obj_path;                  /* Path to runtime libraries         */
-static u8** cc_params;                 /* Parameters passed to the real CC  */
+static u8 *obj_path;                  /* Path to runtime libraries         */
+static u8 **cc_params;                 /* Parameters passed to the real CC  */
 static u32  cc_par_cnt = 1;            /* Param count, including argv0      */
 static u8   llvm_fullpath[PATH_MAX];
 static u8   lto_mode;
-static u8*  lto_flag = AFL_CLANG_FLTO;
-static u8*  march_opt = CFLAGS_OPT;
+static u8 *lto_flag = AFL_CLANG_FLTO;
+static u8 *march_opt = CFLAGS_OPT;
 static u8   debug;
 static u8   cwd[4096];
 static u8   cmplog_mode;
 u8          use_stdin = 0;                                         /* dummy */
 u8          be_quiet = 0;
 
-u8* getthecwd() {
+u8 *getthecwd() {
 
   static u8 fail[] = "";
   if (getcwd(cwd, sizeof(cwd)) == NULL) return fail;
@@ -60,9 +60,9 @@ u8* getthecwd() {
 
 /* Try to find the runtime libraries. If that fails, abort. */
 
-static void find_obj(u8* argv0) {
+static void find_obj(u8 *argv0) {
 
-  u8* afl_path = getenv("AFL_PATH");
+  u8 *afl_path = getenv("AFL_PATH");
   u8 *slash, *tmp;
 
   if (afl_path) {
@@ -89,7 +89,7 @@ static void find_obj(u8* argv0) {
 
   if (slash) {
 
-    u8* dir;
+    u8 *dir;
 
     *slash = 0;
     dir = ck_strdup(argv0);
@@ -135,13 +135,13 @@ static void find_obj(u8* argv0) {
 
 /* Copy argv to cc_params, making the necessary edits. */
 
-static void edit_params(u32 argc, char** argv) {
+static void edit_params(u32 argc, char **argv) {
 
   u8  fortify_set = 0, asan_set = 0, x_set = 0, maybe_linking = 1, bit_mode = 0;
   u8  has_llvm_config = 0;
-  u8* name;
+  u8 *name;
 
-  cc_params = ck_alloc((argc + 128) * sizeof(u8*));
+  cc_params = ck_alloc((argc + 128) * sizeof(u8 *));
 
   name = strrchr(argv[0], '/');
   if (!name)
@@ -168,21 +168,21 @@ static void edit_params(u32 argc, char** argv) {
 
   if (!strcmp(name, "afl-clang-fast++") || !strcmp(name, "afl-clang-lto++")) {
 
-    u8* alt_cxx = getenv("AFL_CXX");
+    u8 *alt_cxx = getenv("AFL_CXX");
     if (has_llvm_config)
       snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang++", LLVM_BINDIR);
     else
       sprintf(llvm_fullpath, "clang++");
-    cc_params[0] = alt_cxx ? alt_cxx : (u8*)llvm_fullpath;
+    cc_params[0] = alt_cxx ? alt_cxx : (u8 *)llvm_fullpath;
 
   } else {
 
-    u8* alt_cc = getenv("AFL_CC");
+    u8 *alt_cc = getenv("AFL_CC");
     if (has_llvm_config)
       snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang", LLVM_BINDIR);
     else
       sprintf(llvm_fullpath, "clang");
-    cc_params[0] = alt_cc ? alt_cc : (u8*)llvm_fullpath;
+    cc_params[0] = alt_cc ? alt_cc : (u8 *)llvm_fullpath;
 
   }
 
@@ -267,8 +267,8 @@ static void edit_params(u32 argc, char** argv) {
 
   if (lto_mode) {
 
-    char* old_path = getenv("PATH");
-    char* new_path = alloc_printf("%s:%s", AFL_PATH, old_path);
+    char *old_path = getenv("PATH");
+    char *new_path = alloc_printf("%s:%s", AFL_PATH, old_path);
 
     setenv("PATH", new_path, 1);
     setenv("AFL_LD", "1", 1);
@@ -322,7 +322,7 @@ static void edit_params(u32 argc, char** argv) {
 
   while (--argc) {
 
-    u8* cur = *(++argv);
+    u8 *cur = *(++argv);
 
     if (!strcmp(cur, "-m32")) bit_mode = 32;
     if (!strcmp(cur, "armv7a-linux-androideabi")) bit_mode = 32;
@@ -521,10 +521,10 @@ static void edit_params(u32 argc, char** argv) {
 
 /* Main entry point */
 
-int main(int argc, char** argv, char** envp) {
+int main(int argc, char **argv, char **envp) {
 
   int   i;
-  char* callname = "afl-clang-fast";
+  char *callname = "afl-clang-fast";
 
   if (getenv("AFL_DEBUG")) {
 
@@ -671,7 +671,7 @@ int main(int argc, char** argv, char** envp) {
 
   }
 
-  execvp(cc_params[0], (char**)cc_params);
+  execvp(cc_params[0], (char **)cc_params);
 
   FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
 
diff --git a/llvm_mode/afl-ld.c b/llvm_mode/afl-ld.c
index bd451ca5..0a244727 100644
--- a/llvm_mode/afl-ld.c
+++ b/llvm_mode/afl-ld.c
@@ -51,17 +51,17 @@ static u8 **ld_params,              /* Parameters passed to the real 'ld'   */
     **opt_params,                   /* Parameters passed to 'opt' opt       */
     **inst_params;                  /* Parameters passed to 'opt' inst      */
 
-static u8* input_file;              /* Originally specified input file      */
+static u8 *input_file;              /* Originally specified input file      */
 static u8 *final_file,              /* Instrumented file for the real 'ld'  */
     *linked_file,                   /* file where we link all files         */
     *modified_file;                 /* file that was optimized before instr */
-static u8* afl_path = AFL_PATH;
-static u8* real_ld = AFL_REAL_LD;
+static u8 *afl_path = AFL_PATH;
+static u8 *real_ld = AFL_REAL_LD;
 static u8  cwd[4096];
-static u8* tmp_dir;
-static u8* ar_dir;
+static u8 *tmp_dir;
+static u8 *ar_dir;
 static u8  ar_dir_cnt;
-static u8* libdirs[254];
+static u8 *libdirs[254];
 static u8  libdir_cnt;
 
 static u8 be_quiet,                 /* Quiet mode (no stderr output)        */
@@ -76,10 +76,10 @@ static u32 ld_param_cnt = 1,        /* Number of params to 'ld'             */
     inst_param_cnt = 1;             /* Number of params to 'opt' instr      */
 
 /* This function wipes a directory - our AR unpack directory in this case */
-static u8 wipe_directory(u8* path) {
+static u8 wipe_directory(u8 *path) {
 
-  DIR*           d;
-  struct dirent* d_ent;
+  DIR *d;
+  struct dirent *d_ent;
 
   d = opendir(path);
 
@@ -89,7 +89,7 @@ static u8 wipe_directory(u8* path) {
 
     if (strcmp(d_ent->d_name, ".") != 0 && strcmp(d_ent->d_name, "..") != 0) {
 
-      u8* fname = alloc_printf("%s/%s", path, d_ent->d_name);
+      u8 *fname = alloc_printf("%s/%s", path, d_ent->d_name);
       if (unlink(fname)) PFATAL("Unable to delete '%s'", fname);
       ck_free(fname);
 
@@ -142,7 +142,7 @@ static void at_exit_handler(void) {
 
 /* This function checks if the parameter is a) an existing file and b)
    if it is a BC or LL file, if both are true it returns 1 and 0 otherwise */
-int is_llvm_file(const char* file) {
+int is_llvm_file(const char *file) {
 
   int fd;
   u8  buf[5];
@@ -169,7 +169,7 @@ int is_llvm_file(const char* file) {
 }
 
 /* Return the current working directory, not thread safe ;-) */
-u8* getthecwd() {
+u8 *getthecwd() {
 
   static u8 fail[] = "";
   if (getcwd(cwd, sizeof(cwd)) == NULL) return fail;
@@ -178,7 +178,7 @@ u8* getthecwd() {
 }
 
 /* Check if an ar extracted file is already in the parameter list */
-int is_duplicate(u8** params, u32 ld_param_cnt, u8* ar_file) {
+int is_duplicate(u8 **params, u32 ld_param_cnt, u8 *ar_file) {
 
   for (uint32_t i = 0; i < ld_param_cnt; i++)
     if (params[i] != NULL)
@@ -191,7 +191,7 @@ int is_duplicate(u8** params, u32 ld_param_cnt, u8* ar_file) {
 /* Examine and modify parameters to pass to 'ld', 'llvm-link' and 'llmv-ar'.
    Note that the file name is always the last parameter passed by GCC,
    so we exploit this property to keep the code "simple". */
-static void edit_params(int argc, char** argv) {
+static void edit_params(int argc, char **argv) {
 
   u32 i, have_lto = 0, libdir_index;
   u8  libdir_file[4096];
@@ -212,12 +212,12 @@ static void edit_params(int argc, char** argv) {
   final_file =
       alloc_printf("%s/.afl-%u-%u-3.bc", tmp_dir, getpid(), (u32)time(NULL));
 
-  ld_params = ck_alloc(4096 * sizeof(u8*));
-  link_params = ck_alloc(4096 * sizeof(u8*));
-  inst_params = ck_alloc(12 * sizeof(u8*));
-  opt_params = ck_alloc(12 * sizeof(u8*));
+  ld_params = ck_alloc(4096 * sizeof(u8 *));
+  link_params = ck_alloc(4096 * sizeof(u8 *));
+  inst_params = ck_alloc(12 * sizeof(u8 *));
+  opt_params = ck_alloc(12 * sizeof(u8 *));
 
-  ld_params[0] = (u8*)real_ld;
+  ld_params[0] = (u8 *)real_ld;
   ld_params[ld_param_cnt++] = "--allow-multiple-definition";
 
   link_params[0] = alloc_printf("%s/%s", LLVM_BINDIR, "llvm-link");
@@ -328,13 +328,13 @@ static void edit_params(int argc, char** argv) {
       // where the same "foo.o" was in both .a archives. llvm-link does not
       // like this so we have to work around that ...
 
-      u8             this_wd[4096], *this_ar;
-      u8             ar_params_cnt = 4;
-      u8*            ar_params[ar_params_cnt];
-      u8*            file = argv[i];
-      s32            pid, status;
-      DIR*           arx;
-      struct dirent* dir_ent;
+      u8 this_wd[4096], *this_ar;
+      u8 ar_params_cnt = 4;
+      u8 *ar_params[ar_params_cnt];
+      u8 *file = argv[i];
+      s32 pid, status;
+      DIR *arx;
+      struct dirent *dir_ent;
 
       if (libdir_index < libdir_cnt) file = libdir_file;
 
@@ -373,7 +373,7 @@ static void edit_params(int argc, char** argv) {
 
       if (!(pid = fork())) {
 
-        execvp(ar_params[0], (char**)ar_params);
+        execvp(ar_params[0], (char **)ar_params);
         FATAL("Oops, failed to execute '%s'", ar_params[0]);
 
       }
@@ -389,7 +389,7 @@ static void edit_params(int argc, char** argv) {
 
       while ((dir_ent = readdir(arx)) != NULL) {
 
-        u8* ar_file = alloc_printf("%s/%s", ar_dir, dir_ent->d_name);
+        u8 *ar_file = alloc_printf("%s/%s", ar_dir, dir_ent->d_name);
 
         if (dir_ent->d_name[strlen(dir_ent->d_name) - 1] == 'o' &&
             dir_ent->d_name[strlen(dir_ent->d_name) - 2] == '.') {
@@ -535,7 +535,7 @@ void clean_path() {
 
 /* Main entry point */
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
 
   s32 pid, i;
   int status;
@@ -665,7 +665,7 @@ int main(int argc, char** argv) {
 
       if (!(pid = fork())) {
 
-        execvp(link_params[0], (char**)link_params);
+        execvp(link_params[0], (char **)link_params);
         FATAL("Oops, failed to execute '%s'", link_params[0]);
 
       }
@@ -707,7 +707,7 @@ int main(int argc, char** argv) {
 
       if (!(pid = fork())) {
 
-        execvp(opt_params[0], (char**)opt_params);
+        execvp(opt_params[0], (char **)opt_params);
         FATAL("Oops, failed to execute '%s'", opt_params[0]);
 
       }
@@ -730,7 +730,7 @@ int main(int argc, char** argv) {
 
       if (!(pid = fork())) {
 
-        execvp(inst_params[0], (char**)inst_params);
+        execvp(inst_params[0], (char **)inst_params);
         FATAL("Oops, failed to execute '%s'", inst_params[0]);
 
       }
@@ -761,8 +761,8 @@ int main(int argc, char** argv) {
 
     unsetenv("AFL_LD");
 
-    if (strlen(real_ld) > 1) execvp(real_ld, (char**)ld_params);
-    execvp("ld", (char**)ld_params);  // fallback
+    if (strlen(real_ld) > 1) execvp(real_ld, (char **)ld_params);
+    execvp("ld", (char **)ld_params);  // fallback
     FATAL("Oops, failed to execute 'ld' - check your PATH");
 
   }
diff --git a/llvm_mode/afl-llvm-rt.o.c b/llvm_mode/afl-llvm-rt.o.c
index 58b64670..1fa77fd9 100644
--- a/llvm_mode/afl-llvm-rt.o.c
+++ b/llvm_mode/afl-llvm-rt.o.c
@@ -59,7 +59,7 @@
    run. It will end up as .comm, so it shouldn't be too wasteful. */
 
 u8  __afl_area_initial[MAP_SIZE];
-u8* __afl_area_ptr = __afl_area_initial;
+u8 *__afl_area_ptr = __afl_area_initial;
 
 #ifdef __ANDROID__
 u32 __afl_prev_loc;
@@ -69,7 +69,7 @@ __thread u32 __afl_prev_loc;
 __thread u32 __afl_final_loc;
 #endif
 
-struct cmp_map* __afl_cmp_map;
+struct cmp_map *__afl_cmp_map;
 __thread u32    __afl_cmp_counter;
 
 /* Running in persistent mode? */
@@ -80,7 +80,7 @@ static u8 is_persistent;
 
 static void __afl_map_shm(void) {
 
-  u8* id_str = getenv(SHM_ENV_VAR);
+  u8 *id_str = getenv(SHM_ENV_VAR);
 
   /* If we're running under AFL, attach to the appropriate region, replacing the
      early-stage __afl_area_initial region that is needed to allow some really
@@ -89,9 +89,9 @@ static void __afl_map_shm(void) {
   if (id_str) {
 
 #ifdef USEMMAP
-    const char*    shm_file_path = id_str;
-    int            shm_fd = -1;
-    unsigned char* shm_base = NULL;
+    const char *shm_file_path = id_str;
+    int shm_fd = -1;
+    unsigned char *shm_base = NULL;
 
     /* create the shared memory segment as if it was a file */
     shm_fd = shm_open(shm_file_path, O_RDWR, 0600);
@@ -123,7 +123,7 @@ static void __afl_map_shm(void) {
 
     /* Whooooops. */
 
-    if (__afl_area_ptr == (void*)-1) _exit(1);
+    if (__afl_area_ptr == (void *)-1) _exit(1);
 
     /* Write something into the bitmap so that even with low AFL_INST_RATIO,
        our parent doesn't give up on us. */
@@ -137,9 +137,9 @@ static void __afl_map_shm(void) {
   if (id_str) {
 
 #ifdef USEMMAP
-    const char*    shm_file_path = id_str;
-    int            shm_fd = -1;
-    unsigned char* shm_base = NULL;
+    const char *shm_file_path = id_str;
+    int shm_fd = -1;
+    unsigned char *shm_base = NULL;
 
     /* create the shared memory segment as if it was a file */
     shm_fd = shm_open(shm_file_path, O_RDWR, 0600);
@@ -170,7 +170,7 @@ static void __afl_map_shm(void) {
     __afl_cmp_map = shmat(shm_id, NULL, 0);
 #endif
 
-    if (__afl_cmp_map == (void*)-1) _exit(1);
+    if (__afl_cmp_map == (void *)-1) _exit(1);
 
   }
 
@@ -354,7 +354,7 @@ __attribute__((constructor(CONST_PRIO))) void __afl_auto_init(void) {
    The first function (__sanitizer_cov_trace_pc_guard) is called back on every
    edge (as opposed to every basic block). */
 
-void __sanitizer_cov_trace_pc_guard(uint32_t* guard) {
+void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {
 
   __afl_area_ptr[*guard]++;
 
@@ -364,10 +364,10 @@ void __sanitizer_cov_trace_pc_guard(uint32_t* guard) {
    ID of 0 as a special value to indicate non-instrumented bits. That may
    still touch the bitmap, but in a fairly harmless way. */
 
-void __sanitizer_cov_trace_pc_guard_init(uint32_t* start, uint32_t* stop) {
+void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
 
   u32 inst_ratio = 100;
-  u8* x;
+  u8 *x;
 
   if (start == stop || *start) return;
 
@@ -504,7 +504,7 @@ void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2)
     __attribute__((alias("__cmplog_ins_hook8")));
 #endif                                                /* defined(__APPLE__) */
 
-void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t* Cases) {
+void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {
 
   for (uint64_t i = 0; i < Cases[0]; i++) {
 
@@ -530,10 +530,10 @@ void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t* Cases) {
 // POSIX shenanigan to see if an area is mapped.
 // If it is mapped as X-only, we have a problem, so maybe we should add a check
 // to avoid to call it on .text addresses
-static int area_is_mapped(void* ptr, size_t len) {
+static int area_is_mapped(void *ptr, size_t len) {
 
-  char* p = ptr;
-  char* page = (char*)((uintptr_t)p & ~(sysconf(_SC_PAGE_SIZE) - 1));
+  char *p = ptr;
+  char *page = (char *)((uintptr_t)p & ~(sysconf(_SC_PAGE_SIZE) - 1));
 
   int r = msync(page, (p - page) + len, MS_ASYNC);
   if (r < 0) return errno != ENOMEM;
@@ -541,7 +541,7 @@ static int area_is_mapped(void* ptr, size_t len) {
 
 }
 
-void __cmplog_rtn_hook(void* ptr1, void* ptr2) {
+void __cmplog_rtn_hook(void *ptr1, void *ptr2) {
 
   if (!__afl_cmp_map) return;
 
@@ -559,9 +559,9 @@ void __cmplog_rtn_hook(void* ptr1, void* ptr2) {
   __afl_cmp_map->headers[k].shape = 31;
 
   hits &= CMP_MAP_RTN_H - 1;
-  __builtin_memcpy(((struct cmpfn_operands*)__afl_cmp_map->log[k])[hits].v0,
+  __builtin_memcpy(((struct cmpfn_operands *)__afl_cmp_map->log[k])[hits].v0,
                    ptr1, 32);
-  __builtin_memcpy(((struct cmpfn_operands*)__afl_cmp_map->log[k])[hits].v1,
+  __builtin_memcpy(((struct cmpfn_operands *)__afl_cmp_map->log[k])[hits].v1,
                    ptr2, 32);
 
 }