OLD | NEW |
1 /* | 1 /* |
2 american fuzzy lop - wrapper for GCC and clang | 2 american fuzzy lop - wrapper for GCC and clang |
3 ---------------------------------------------- | 3 ---------------------------------------------- |
4 | 4 |
5 Written and maintained by Michal Zalewski <lcamtuf@google.com> | 5 Written and maintained by Michal Zalewski <lcamtuf@google.com> |
6 | 6 |
7 Copyright 2013, 2014, 2015 Google Inc. All rights reserved. | 7 Copyright 2013, 2014, 2015 Google Inc. All rights reserved. |
8 | 8 |
9 Licensed under the Apache License, Version 2.0 (the "License"); | 9 Licensed under the Apache License, Version 2.0 (the "License"); |
10 you may not use this file except in compliance with the License. | 10 you may not use this file except in compliance with the License. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 static void edit_params(u32 argc, char** argv) { | 110 static void edit_params(u32 argc, char** argv) { |
111 | 111 |
112 u8 fortify_set = 0, asan_set = 0; | 112 u8 fortify_set = 0, asan_set = 0; |
113 u8 *name; | 113 u8 *name; |
114 | 114 |
115 #if defined(__FreeBSD__) && defined(__x86_64__) | 115 #if defined(__FreeBSD__) && defined(__x86_64__) |
116 u8 m32_set = 0; | 116 u8 m32_set = 0; |
117 #endif | 117 #endif |
118 | 118 |
119 cc_params = ck_alloc((argc + 64) * sizeof(u8*)); | 119 cc_params = ck_alloc((argc + 128) * sizeof(u8*)); |
120 | 120 |
121 name = strrchr(argv[0], '/'); | 121 name = strrchr(argv[0], '/'); |
122 if (!name) name = argv[0]; else name++; | 122 if (!name) name = argv[0]; else name++; |
123 | 123 |
124 if (!strncmp(name, "afl-clang", 9)) { | 124 if (!strncmp(name, "afl-clang", 9)) { |
125 | 125 |
126 clang_mode = 1; | 126 clang_mode = 1; |
127 | 127 |
128 setenv(CLANG_ENV_VAR, "1", 1); | 128 setenv(CLANG_ENV_VAR, "1", 1); |
129 | 129 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 cc_params[cc_par_cnt++] = "-funroll-loops"; | 264 cc_params[cc_par_cnt++] = "-funroll-loops"; |
265 | 265 |
266 /* Two indicators that you're building for fuzzing; one of them is | 266 /* Two indicators that you're building for fuzzing; one of them is |
267 AFL-specific, the other is shared with libfuzzer. */ | 267 AFL-specific, the other is shared with libfuzzer. */ |
268 | 268 |
269 cc_params[cc_par_cnt++] = "-D__AFL_COMPILER=1"; | 269 cc_params[cc_par_cnt++] = "-D__AFL_COMPILER=1"; |
270 cc_params[cc_par_cnt++] = "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"; | 270 cc_params[cc_par_cnt++] = "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"; |
271 | 271 |
272 } | 272 } |
273 | 273 |
| 274 if (getenv("AFL_NO_BUILTIN")) { |
| 275 |
| 276 cc_params[cc_par_cnt++] = "-fno-builtin-strcmp"; |
| 277 cc_params[cc_par_cnt++] = "-fno-builtin-strncmp"; |
| 278 cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp"; |
| 279 cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp"; |
| 280 cc_params[cc_par_cnt++] = "-fno-builtin-memcmp"; |
| 281 |
| 282 } |
| 283 |
274 cc_params[cc_par_cnt] = NULL; | 284 cc_params[cc_par_cnt] = NULL; |
275 | 285 |
276 } | 286 } |
277 | 287 |
278 | 288 |
279 /* Main entry point */ | 289 /* Main entry point */ |
280 | 290 |
281 int main(int argc, char** argv) { | 291 int main(int argc, char** argv) { |
282 | 292 |
283 if (isatty(2) && !getenv("AFL_QUIET")) { | 293 if (isatty(2) && !getenv("AFL_QUIET")) { |
(...skipping 25 matching lines...) Expand all Loading... |
309 | 319 |
310 edit_params(argc, argv); | 320 edit_params(argc, argv); |
311 | 321 |
312 execvp(cc_params[0], (char**)cc_params); | 322 execvp(cc_params[0], (char**)cc_params); |
313 | 323 |
314 FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]); | 324 FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]); |
315 | 325 |
316 return 0; | 326 return 0; |
317 | 327 |
318 } | 328 } |
OLD | NEW |