Moving libafl related files in dedicating folders (#60)

* Restructuration of libafl dirs. Formatting + export of maps struct and functions.

* Fix wrong header path.

* Fix misc path
This commit is contained in:
Romain Malmain 2024-04-11 16:45:36 +02:00 committed by GitHub
parent e99b9da658
commit 50b0c90e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 113 additions and 95 deletions

View File

@ -715,7 +715,7 @@ static inline void cpu_handle_debug_exception(CPUState *cpu)
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/exit.h" #include "libafl/exit.h"
//// --- End LibAFL code --- //// --- End LibAFL code ---

View File

@ -37,7 +37,7 @@
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/exit.h" #include "libafl/exit.h"
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY

View File

@ -68,7 +68,7 @@
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/hook.h" #include "libafl/hook.h"
//// --- End LibAFL code --- //// --- End LibAFL code ---

View File

@ -114,8 +114,8 @@ static void gen_tb_end(const TranslationBlock *tb, uint32_t cflags,
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/exit.h" #include "libafl/exit.h"
#include "libafl_extras/hook.h" #include "libafl/hook.h"
#ifndef TARGET_LONG_BITS #ifndef TARGET_LONG_BITS
#error "TARGET_LONG_BITS not defined" #error "TARGET_LONG_BITS not defined"

View File

@ -30,7 +30,7 @@
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#ifdef CONFIG_SOFTMMU #ifdef CONFIG_SOFTMMU
#include "libafl_extras/syx-snapshot/syx-snapshot.h" #include "libafl/syx-snapshot/syx-snapshot.h"
#endif #endif
//// --- End LibAFL code --- //// --- End LibAFL code ---

View File

@ -45,8 +45,8 @@
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/exit.h" #include "libafl/exit.h"
#include "libafl_extras/hook.h" #include "libafl/hook.h"
static __thread GByteArray *libafl_qemu_mem_buf = NULL; static __thread GByteArray *libafl_qemu_mem_buf = NULL;

View File

@ -14,7 +14,7 @@
#include "device-save.h" #include "device-save.h"
#include "syx-cow-cache.h" #include "syx-cow-cache.h"
#include "../syx-misc.h" #include "libafl/syx-misc.h"
#define SYX_SNAPSHOT_COW_CACHE_DEFAULT_CHUNK_SIZE 64 #define SYX_SNAPSHOT_COW_CACHE_DEFAULT_CHUNK_SIZE 64
#define SYX_SNAPSHOT_COW_CACHE_DEFAULT_MAX_BLOCKS (1024 * 1024) #define SYX_SNAPSHOT_COW_CACHE_DEFAULT_MAX_BLOCKS (1024 * 1024)

16
include/libafl/user.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "qemu/osdep.h"
#include "qapi/error.h"
struct libafl_mapinfo {
target_ulong start;
target_ulong end;
target_ulong offset;
const char* path;
int flags;
int is_priv;
};
IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info);
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret);

View File

@ -1,4 +1,4 @@
#include "exit.h" #include "libafl/exit.h"
#include "sysemu/runstate.h" #include "sysemu/runstate.h"
#include "cpu.h" #include "cpu.h"

View File

@ -4,8 +4,8 @@
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "exec/tb-flush.h" #include "exec/tb-flush.h"
#include "hook.h" #include "libafl/hook.h"
#include "exit.h" #include "libafl/exit.h"
#ifndef TARGET_LONG_BITS #ifndef TARGET_LONG_BITS
#error "TARGET_LONG_BITS not defined" #error "TARGET_LONG_BITS not defined"

View File

@ -3,7 +3,7 @@
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "jit.h" #include "libafl/jit.h"
#ifndef TARGET_LONG_BITS #ifndef TARGET_LONG_BITS
#error "TARGET_LONG_BITS not defined" #error "TARGET_LONG_BITS not defined"

View File

@ -1,7 +1,13 @@
specific_ss.add(files(
'exit.c',
'hook.c',
'jit.c'
))
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
'syx-snapshot/device-save.c', 'syx-snapshot/device-save.c',
'syx-snapshot/syx-snapshot.c', 'syx-snapshot/syx-snapshot.c',
'syx-snapshot/syx-cow-cache.c', 'syx-snapshot/syx-cow-cache.c',
'syx-snapshot/channel-buffer-writeback.c', 'syx-snapshot/channel-buffer-writeback.c',
)]) )])
specific_ss.add(files('exit.c', 'hook.c', 'jit.c'))

View File

@ -1,7 +1,8 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "migration/qemu-file.h" #include "migration/qemu-file.h"
#include "channel-buffer-writeback.h"
#include "../syx-misc.h" #include "libafl/syx-misc.h"
#include "libafl/syx-snapshot/channel-buffer-writeback.h"
QIOChannelBufferWriteback* qio_channel_buffer_writeback_new(size_t capacity, uint8_t* writeback_buf, size_t writeback_buf_capacity, size_t* writeback_buf_usage) { QIOChannelBufferWriteback* qio_channel_buffer_writeback_new(size_t capacity, uint8_t* writeback_buf, size_t writeback_buf_capacity, size_t* writeback_buf_usage) {
assert(writeback_buf != NULL); assert(writeback_buf != NULL);

View File

@ -1,11 +1,12 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "device-save.h"
#include "migration/qemu-file.h" #include "migration/qemu-file.h"
#include "io/channel-buffer.h" #include "io/channel-buffer.h"
#include "channel-buffer-writeback.h"
#include "migration/vmstate.h" #include "migration/vmstate.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"
#include "../syx-misc.h"
#include "libafl/syx-misc.h"
#include "libafl/syx-snapshot/channel-buffer-writeback.h"
#include "libafl/syx-snapshot/device-save.h"
#include "migration/savevm.h" #include "migration/savevm.h"

View File

@ -1,4 +1,4 @@
#include "syx-cow-cache.h" #include "libafl/syx-snapshot/syx-cow-cache.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"

View File

@ -8,8 +8,8 @@
#include "exec/ram_addr.h" #include "exec/ram_addr.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "syx-snapshot.h" #include "libafl/syx-snapshot/syx-snapshot.h"
#include "device-save.h" #include "libafl/syx-snapshot/device-save.h"
#define SYX_SNAPSHOT_LIST_INIT_SIZE 4096 #define SYX_SNAPSHOT_LIST_INIT_SIZE 4096
#define SYX_SNAPSHOT_LIST_GROW_FACTOR 2 #define SYX_SNAPSHOT_LIST_GROW_FACTOR 2

View File

@ -25,7 +25,7 @@
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/exit.h" #include "libafl/exit.h"
//// --- End LibAFL code --- //// --- End LibAFL code ---

View File

@ -6522,7 +6522,7 @@ typedef struct {
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
#include "libafl_extras/hook.h" #include "libafl/hook.h"
extern __thread CPUArchState *libafl_qemu_env; extern __thread CPUArchState *libafl_qemu_env;
@ -13672,22 +13672,16 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
//// --- Begin LibAFL code --- //// --- Begin LibAFL code ---
struct libafl_mapinfo { #include "libafl/user.h"
target_ulong start, end;
target_ulong offset;
const char* path;
int flags, is_priv;
};
IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info);
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret);
IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info) { IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info) {
return interval_tree_iter_first(map_info, 0, -1); return interval_tree_iter_first(map_info, 0, -1);
} }
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret) { IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret) {
if (!node || !ret) if (!node || !ret) {
return NULL; return NULL;
}
MapInfo *e = container_of(node, MapInfo, itree); MapInfo *e = container_of(node, MapInfo, itree);

View File

@ -3256,7 +3256,7 @@ target_user_arch = {}
### LibAFL extras ### LibAFL extras
subdir('libafl_extras') subdir('libafl')
############### ###############
# Trace files # # Trace files #