AFLplusplus / AFLplusplus/LibAFL

[librasan]: link libqasan statically with baremetal application

Aperta
#3,103 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
2.6k
Fork
481
Merge medio
2g 30m
PR unite (30g)
16

Descrizione

#### Description
I am experimenting on writing a fuzzer for a cross compiled application on aarch64.
For now, if I understand correctly, `libqasan` can only get linked dynamically with `LD_LIBRARY_PATH` and override function symbols (`malloc`, `free` etc).
I am not sure `libqasan.so` can be linked with a baremetal application, though

#### Questions
1. Is there a way to link `libqasan.so` to a baremetal app?
2. If not, would statically linking `libqasan.a` (`.renamed`) archive file, be a possible solution?
3. I already have experimented with linking `libqasan.a` (`libqasan.renamed` actually), and the final question is, what header file should be imported to the baremetal target in order to build it with `malloc`, `free` etc defined in `libqasan`? As I can see, the old implementation `qasan` has a `libqasan.h` file for importing it to the target. How can I override `malloc` with a potential static link with `libqasan`?

#### Examples
For example building the `fuzzers/full_system/qemu_baremetal` example with `libqasan.a`.
**NOTE: it is not a working example, I just put it here to show a simple use case**
```bash
arm-none-eabi-gcc -ggdb -ffreestanding -nostartfiles -lgcc \
-T example/mps2_m3.ld \
-mcpu=cortex-m3 \
-D "TARGET_{{ uppercase(flavor) }}" \
-I {{BUILD_DIR / "include"}} \
example/main.c \
libqasan.a \
example/startup.c \
-o {{TARGET_DIR}}/example.elf
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.