mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-19 04:58:08 +00:00
import transform fix into autodict, code-format
This commit is contained in:
@ -279,12 +279,13 @@ library_list_t *find_library(char *name) {
|
|||||||
/* for having an easy breakpoint after load the shared library */
|
/* for having an easy breakpoint after load the shared library */
|
||||||
// this seems to work for clang too. nice :) requires gcc 4.4+
|
// this seems to work for clang too. nice :) requires gcc 4.4+
|
||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC optimize ("O0")
|
#pragma GCC optimize("O0")
|
||||||
void breakpoint() {
|
void breakpoint() {
|
||||||
|
|
||||||
if (debug) fprintf(stderr, "Breakpoint function \"breakpoint\" reached.\n");
|
if (debug) fprintf(stderr, "Breakpoint function \"breakpoint\" reached.\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC pop_options
|
#pragma GCC pop_options
|
||||||
|
|
||||||
/* Error reporting to forkserver controller */
|
/* Error reporting to forkserver controller */
|
||||||
@ -510,8 +511,10 @@ void setup_trap_instrumentation() {
|
|||||||
// Create shadow memory.
|
// Create shadow memory.
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *shadow_addr = SHADOW(lib_addr + i);
|
void *shadow_addr = SHADOW(lib_addr + i);
|
||||||
@ -549,7 +552,8 @@ void setup_trap_instrumentation() {
|
|||||||
|
|
||||||
// Make lookup entry in shadow memory.
|
// Make lookup entry in shadow memory.
|
||||||
|
|
||||||
#if ((defined(__APPLE__) && defined(__LP64__)) || defined(__x86_64__) || defined(__i386__))
|
#if ((defined(__APPLE__) && defined(__LP64__)) || defined(__x86_64__) || \
|
||||||
|
defined(__i386__))
|
||||||
|
|
||||||
// this is for Intel x64
|
// this is for Intel x64
|
||||||
|
|
||||||
@ -566,7 +570,7 @@ void setup_trap_instrumentation() {
|
|||||||
|
|
||||||
// this is for aarch64
|
// this is for aarch64
|
||||||
|
|
||||||
uint32_t *patch_bytes = (uint32_t*)(lib_addr + offset);
|
uint32_t *patch_bytes = (uint32_t *)(lib_addr + offset);
|
||||||
uint32_t orig_bytes = *patch_bytes;
|
uint32_t orig_bytes = *patch_bytes;
|
||||||
*shadow = (bitmap_index << 32) | orig_bytes;
|
*shadow = (bitmap_index << 32) | orig_bytes;
|
||||||
*patch_bytes = 0xd4200000; // replace instruction with debug trap
|
*patch_bytes = 0xd4200000; // replace instruction with debug trap
|
||||||
|
@ -718,7 +718,9 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (instrument_opt_mode && lto_mode)
|
if (instrument_opt_mode && lto_mode)
|
||||||
FATAL("CTX and NGRAM can not be used in LTO mode (and would make LTO useless)");
|
FATAL(
|
||||||
|
"CTX and NGRAM can not be used in LTO mode (and would make LTO "
|
||||||
|
"useless)");
|
||||||
|
|
||||||
if (!instrument_opt_mode) {
|
if (!instrument_opt_mode) {
|
||||||
|
|
||||||
|
@ -346,6 +346,8 @@ struct InsTrimLTO : public ModulePass {
|
|||||||
if (auto *Var =
|
if (auto *Var =
|
||||||
dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
||||||
|
|
||||||
|
if (Var->hasInitializer()) {
|
||||||
|
|
||||||
if (auto *Array = dyn_cast<ConstantDataArray>(
|
if (auto *Array = dyn_cast<ConstantDataArray>(
|
||||||
Var->getInitializer())) {
|
Var->getInitializer())) {
|
||||||
|
|
||||||
@ -360,6 +362,8 @@ struct InsTrimLTO : public ModulePass {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// for the internal memcpy routine we only care for the second
|
// for the internal memcpy routine we only care for the second
|
||||||
// parameter and are not reporting anything.
|
// parameter and are not reporting anything.
|
||||||
if (isIntMemcpy == true) {
|
if (isIntMemcpy == true) {
|
||||||
@ -419,6 +423,8 @@ struct InsTrimLTO : public ModulePass {
|
|||||||
if (auto *Var =
|
if (auto *Var =
|
||||||
dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
||||||
|
|
||||||
|
if (Var->hasInitializer()) {
|
||||||
|
|
||||||
if (auto *Array = dyn_cast<ConstantDataArray>(
|
if (auto *Array = dyn_cast<ConstantDataArray>(
|
||||||
Var->getInitializer())) {
|
Var->getInitializer())) {
|
||||||
|
|
||||||
@ -433,6 +439,8 @@ struct InsTrimLTO : public ModulePass {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Neither a literal nor a global variable?
|
// Neither a literal nor a global variable?
|
||||||
// maybe it is a local variable that we saved
|
// maybe it is a local variable that we saved
|
||||||
if (!HasStr1) {
|
if (!HasStr1) {
|
||||||
|
@ -326,8 +326,10 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
||||||
|
|
||||||
if (auto *Array =
|
if (Var->hasInitializer()) {
|
||||||
dyn_cast<ConstantDataArray>(Var->getInitializer())) {
|
|
||||||
|
if (auto *Array = dyn_cast<ConstantDataArray>(
|
||||||
|
Var->getInitializer())) {
|
||||||
|
|
||||||
HasStr2 = true;
|
HasStr2 = true;
|
||||||
Str2 = Array->getAsString().str();
|
Str2 = Array->getAsString().str();
|
||||||
@ -340,6 +342,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// for the internal memcpy routine we only care for the second
|
// for the internal memcpy routine we only care for the second
|
||||||
// parameter and are not reporting anything.
|
// parameter and are not reporting anything.
|
||||||
if (isIntMemcpy == true) {
|
if (isIntMemcpy == true) {
|
||||||
@ -398,8 +402,10 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
|
||||||
|
|
||||||
if (auto *Array =
|
if (Var->hasInitializer()) {
|
||||||
dyn_cast<ConstantDataArray>(Var->getInitializer())) {
|
|
||||||
|
if (auto *Array = dyn_cast<ConstantDataArray>(
|
||||||
|
Var->getInitializer())) {
|
||||||
|
|
||||||
HasStr1 = true;
|
HasStr1 = true;
|
||||||
Str1 = Array->getAsString().str();
|
Str1 = Array->getAsString().str();
|
||||||
@ -412,6 +418,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Neither a literal nor a global variable?
|
// Neither a literal nor a global variable?
|
||||||
// maybe it is a local variable that we saved
|
// maybe it is a local variable that we saved
|
||||||
if (!HasStr1) {
|
if (!HasStr1) {
|
||||||
|
Reference in New Issue
Block a user