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' parameters for partial linking #143

Open QinlinChen opened 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', '-Wl,-r', or '-Wl,-i' in the cmd line.

I see that AFLplusplus handles partial linking just now, but it ignores the '-r' parameter though handling the '-Wl,-r' and '-Wl,-i'. Therefore, it still cannot compile the busybox.