google / AFL

american fuzzy lop - a security-oriented fuzzer
https://lcamtuf.coredump.cx/afl/
Apache License 2.0
3.56k stars 625 forks source link

afl-clang-fast: modify edit_params() to handle '-r/--relocatable' parameters for partial linking #142

Closed QinlinChen closed 3 years ago

QinlinChen commented 3 years ago

There is a case that AFL cannot compile busybox. It is because the building system of busybox uses the partial linking feature of ld while the afl-clang-fast cannot handle such case.

More specifically, the building system of busybox first merges several relocatable object file into a new relocatable file using the '-r' option, where the afl-llvm-rt.o added by afl-clang-fast is also merged, so the new relocatable file contains the symbols from afl-llvm-rt.o. At the final linking step, the new relocatable file is linked with afl-llvm-rt.o (added again by afl-clang-fast) into the executable file, but both files contain the definitions of the symbols from afl-llvm-rt.o. As a result, the compiler complains that and stop the building process.

I fix this by restraining afl-clang-fast from adding the 'afl-llvm-rt.o' parameter when seeing the '-r/--relocatable' parameter in the cmd line.

QinlinChen commented 3 years ago

The fix has an obvious improvement, so I close this PR.