break up llvm rt afl init

This commit is contained in:
van Hauser
2020-08-11 03:37:02 +02:00
parent fee58a4d1b
commit 9cf8637fab
2 changed files with 18 additions and 7 deletions

View File

@ -35,6 +35,8 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
#include <limits.h>
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -848,7 +850,6 @@ void __afl_manual_init(void) {
if (!init_done) { if (!init_done) {
__afl_map_shm();
__afl_start_forkserver(); __afl_start_forkserver();
init_done = 1; init_done = 1;
@ -856,17 +857,27 @@ void __afl_manual_init(void) {
} }
/* Proper initialization routine. */ /* Initialization of the forkserver - latest possible */
__attribute__((constructor(CONST_PRIO))) void __afl_auto_init(void) { __attribute__((constructor())) void __afl_auto_init(void) {
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
if (getenv(DEFER_ENV_VAR)) return;
__afl_manual_init();
}
/* Initialization of the shmem - earliest possible because of LTO fixed mem. */
__attribute__((constructor(0))) void __afl_auto_early(void) {
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return; if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
is_persistent = !!getenv(PERSIST_ENV_VAR); is_persistent = !!getenv(PERSIST_ENV_VAR);
if (getenv(DEFER_ENV_VAR)) return; __afl_map_shm();
__afl_manual_init();
} }

View File

@ -1305,7 +1305,7 @@ int main(int argc, char **argv_orig, char **envp) {
OKF("Taint forkserver successfully started"); OKF("Taint forkserver successfully started");
const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb const rlim_t kStackSize = 256L * 1024L * 1024L; // min stack size = 256 Mb
struct rlimit rl; struct rlimit rl;
rl.rlim_cur = kStackSize; rl.rlim_cur = kStackSize;
if (getrlimit(RLIMIT_STACK, &rl) != 0) if (getrlimit(RLIMIT_STACK, &rl) != 0)