Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

QinlinChen
Copy link
Contributor

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.

…rtial linking

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant