Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support transformations on intermediate LLVM code (.ll) #127

Closed
vfoltsgt opened this issue Dec 23, 2021 · 3 comments
Closed

Support transformations on intermediate LLVM code (.ll) #127

vfoltsgt opened this issue Dec 23, 2021 · 3 comments

Comments

@vfoltsgt
Copy link

Is there a possibility to make custom changes to the generated .ll code and continue with the producing final binary? Specifically, I'm interested in applying AFL instrumentation. I tried to compile/link produced .ll with clang and got linker errors.
I looked at the source code and it seems like the original binary is used to merge .ll into the final binary (.ll alone cannot be used to produce the final binary). Could you please clarify how does this work or maybe point me to some documentation?

@pnwamk
Copy link
Contributor

pnwamk commented Dec 23, 2021

You are correct: the original binary is used to generate the final binary with the lifted .ll.

As a quick hack that might work, the combination of reopt's -O1 --opt=PATH flags will cause reopt to call PATH -O1 as a subprocess, to which it will write the generated LLVM over the process's STDIN (in binary mode) and then read back the result over the process's STDOUT.

Would using that with an appropriately chosen PATH allow you to perform the LLVM -> LLVM transformation you're aiming for?

@vfoltsgt
Copy link
Author

Thanks for the suggestion. This might work if I can apply AFL instrumentation to .ll having .ll as an output. I'll experiment with this. So far I've been using afl-clang on .ll getting rewritten binary as a result but this approach won't work here.

@vfoltsgt
Copy link
Author

Closing this issue: seems like afl-clang cannot produce transformed .ll as output and researching/modifying afl-clang is out of the scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants