fix Rust linking
This commit is contained in:
parent
cb9a2a2b68
commit
ecf311310d
@ -581,6 +581,16 @@ static int parse_args(int argc, char **argv)
|
||||
r++;
|
||||
}
|
||||
|
||||
if (!strncmp(r, "libafl", 6)) {
|
||||
if (optind >= argc) {
|
||||
(void) fprintf(stderr,
|
||||
"qemu: missing argument for option '%s'\n", r);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
optind++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
|
||||
if (!strcmp(r, arginfo->argv)) {
|
||||
if (arginfo->has_arg) {
|
||||
|
14
qemu_libafl_bridge/.gitignore
vendored
Normal file
14
qemu_libafl_bridge/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "qemu_libafl_bridge"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
|
||||
description = "QEMU and LibAFL bridge lib"
|
||||
repository = "https://github.com/AFLplusplus/qemu-libafl-bridge/"
|
||||
@ -13,3 +13,6 @@ edition = "2018"
|
||||
[dependencies]
|
||||
num = "0.4"
|
||||
num_enum = "0.5.1"
|
||||
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0" }
|
||||
|
17
qemu_libafl_bridge/build.rs
Normal file
17
qemu_libafl_bridge/build.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
let out_dir = out_dir.to_string_lossy().to_string();
|
||||
let src_dir = Path::new("src");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/weaks.c");
|
||||
|
||||
cc::Build::new()
|
||||
.file(src_dir.join("weaks.c"))
|
||||
.compile("weaks");
|
||||
|
||||
println!("cargo:rustc-link-search=native={}", &out_dir);
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
@ -89,4 +89,8 @@ impl QemuEmulator {
|
||||
pub fn h2g(&self, addr: isize) -> *mut u8 {
|
||||
unsafe { transmute(addr - guest_base) }
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
30
qemu_libafl_bridge/src/weaks.c
Normal file
30
qemu_libafl_bridge/src/weaks.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__attribute__((weak)) int libafl_qemu_write_reg(int reg, uint8_t* val) {
|
||||
(void)reg;
|
||||
(void)val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int libafl_qemu_read_reg(int reg, uint8_t* val) {
|
||||
(void)reg;
|
||||
(void)val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int libafl_qemu_num_regs(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int libafl_qemu_set_breakpoint(uint64_t addr) {
|
||||
(void)addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int libafl_qemu_remove_breakpoint(uint64_t addr) {
|
||||
(void)addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) size_t guest_base = 0;
|
Loading…
x
Reference in New Issue
Block a user