Fix libafl_qemu.h (#2250)

* fix header for gcc

* fix comment
This commit is contained in:
Romain Malmain 2024-05-28 11:39:24 +02:00 committed by GitHub
parent 7c9bd1157c
commit 4d45100a63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 4 deletions

View File

@ -236,7 +236,8 @@ pub fn merge(
.scheduler_mut()
.on_remove(&mut state, idx, &Some(testcase))?;
} else {
#[allow(clippy::needless_borrows_for_generic_args)] // False-positive: file_path is used just below
// False-positive: file_path is used just below
#[allow(clippy::needless_borrows_for_generic_args)]
rename(&file_path, &new_file_path)?;
*file_path = new_file_path;
}

View File

@ -100,6 +100,7 @@ libafl_qemu_build = { path = "./libafl_qemu_build", version = "0.12.0" }
pyo3-build-config = { version = "0.21", optional = true }
rustversion = "1.0"
bindgen = "0.69"
cc = "1.0"
[lib]
name = "libafl_qemu"

View File

@ -6,6 +6,13 @@ use std::{
use libafl_qemu_build::maybe_generate_stub_bindings;
static LIBAFL_QEMU_RUNTIME_TEST: &str = r#"
#include <stdio.h>
#include "libafl_qemu.h"
int main() {}
"#;
#[allow(clippy::too_many_lines)]
pub fn build() {
// Note: Unique features are checked in libafl_qemu_sys
@ -42,6 +49,17 @@ pub fn build() {
let libafl_runtime_dir = src_dir.join("runtime");
let libafl_qemu_hdr = libafl_runtime_dir.join(libafl_qemu_hdr_name);
let libafl_runtime_testfile = out_dir.join("runtime_test.c");
fs::write(&libafl_runtime_testfile, LIBAFL_QEMU_RUNTIME_TEST).expect("Could not write runtime test file");
let mut runtime_test_cc_compiler = cc::Build::new();
runtime_test_cc_compiler.cpp(false)
.include(&libafl_runtime_dir)
.file(&libafl_runtime_testfile);
runtime_test_cc_compiler.try_compile("runtime_test").unwrap();
let runtime_bindings_file = out_dir.join("libafl_qemu_bindings.rs");
let stub_runtime_bindings_file = src_dir.join("runtime/libafl_qemu_stub_bindings.rs");

View File

@ -87,7 +87,7 @@ typedef enum LibaflQemuEndStatus {
libafl_word ret; \
__asm__ volatile ( \
"mov %1, %%rax\n" \
".dword " XSTRINGIFY(opcode) "\n" \
".4byte " XSTRINGIFY(opcode) "\n" \
"mov %%rax, %0\n" \
: "=g"(ret) \
: "g"(action) \
@ -102,7 +102,7 @@ typedef enum LibaflQemuEndStatus {
__asm__ volatile ( \
"mov %1, %%rax\n" \
"mov %2, %%rdi\n" \
".dword " XSTRINGIFY(opcode) "\n" \
".4byte " XSTRINGIFY(opcode) "\n" \
"mov %%rax, %0\n" \
: "=g"(ret) \
: "g"(action), "g"(arg1) \
@ -118,7 +118,7 @@ typedef enum LibaflQemuEndStatus {
"mov %1, %%rax\n" \
"mov %2, %%rdi\n" \
"mov %3, %%rsi\n" \
".dword " XSTRINGIFY(opcode) "\n" \
".4byte " XSTRINGIFY(opcode) "\n" \
"mov %%rax, %0\n" \
: "=g"(ret) \
: "g"(action), "g"(arg1), "g"(arg2) \