Skip to content

LLVM 11#85

Merged
mboehme merged 9 commits into
aflgo:masterfrom
Liblor:llvm-11
Mar 19, 2021
Merged

LLVM 11#85
mboehme merged 9 commits into
aflgo:masterfrom
Liblor:llvm-11

Conversation

@Liblor

@Liblor Liblor commented Jan 30, 2021

Copy link
Copy Markdown

Work in progress: Port AFLGo to LLVM 11.

TODO:

  • Update build script
  • Make afl-llvm-pass.so.cc compile
  • Update gen_distance_fast.py
  • Update genDistance.sh
  • Have a look at build process as clang fails in compiling afl-gcc which isn't used anyway (afaik). Building with make clean && AFL_NO_X86=1 make works
  • Update README.md
  • Maybe something else
  • Testing

@Liblor

Liblor commented Feb 11, 2021

Copy link
Copy Markdown
Author

Just a quick update: I haven't forgotten this pull request, I'm just busy with other stuff.

Liblor added 4 commits March 1, 2021 12:23
```
./distance.py_:17: DeprecationWarning: Using or importing the ABCs from
'collections' instead of from 'collections.abc' is deprecated since
Python 3.3, and in 3.10 it will stop working
  if not isinstance(args, collections.Hashable):
```
@mboehme

mboehme commented Mar 5, 2021

Copy link
Copy Markdown
Collaborator

Have a look at build process as clang fails in compiling afl-gcc which isn't used anyway (afaik). Building with make clean && AFL_NO_X86=1 make works.

Hmm. That's weird. afl-gcc doesn't use the LLVM pass. Does it work with vanilla AFLGo?

Make tests using ./test-instr use paths that are less likely to be
optimized out.
@Liblor

Liblor commented Mar 8, 2021

Copy link
Copy Markdown
Author

Yes, the same happens with mirrorer/afl, however it doesn't happen with google/AFL. I found that the problem was patched here. The Makefile in llvm_mode has the appropriate patch, but the Makefile in the root dir of AFLGo didn't have it. So this issue is now also resolved. Now, I'll have only to recompile everything from scratch to see if it works.

@Liblor Liblor marked this pull request as ready for review March 8, 2021 10:57
@Liblor

Liblor commented Mar 8, 2021

Copy link
Copy Markdown
Author

I did some brief tests, and it seems to work as expected :)
Before merging, it might be a good idea to create a tag llvm-4.0.0 on the current master branch. That way it's easy to navigate to the older version that uses llvm 4.0.0.

@mboehme mboehme left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Liblor! This is awesome. I'll tag the current version as LLVM-4.0.

I've left a few minor comments. Apart from that could I ask you to make the error messages a bit more expressive? You are welcome to accomodate here or or raise another PR for this.

For instance, it would be good if we got the stderr from distance_calculator here:


In distance_calculator, under open_file can you add which file could not be opened and add a newline:
std::ifstream open_file(const std::string &filename) {

Comment thread scripts/build/aflgo-build.sh Outdated

# Build clang & LLVM
LLVM_DEP_PACKAGES="build-essential make cmake ninja-build git subversion python2.7 binutils-gold binutils-dev curl wget"
LLVM_DEP_PACKAGES="build-essential make cmake ninja-build git binutils-gold binutils-dev curl wget python3-distutils"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is python3-distutils really needed? On Ubuntu 16.04 and earlier, you need to first add the apt-repo ppa:deadsnakes/ppa before you can install python3-distutils. On my machine, it seemed to build fine without.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only tried it with Ubuntu 20.04 and 18.04. I didn't check on 16.04, but I remember that there was an issue, if I didn't add python3-distutils. And indeed, I retried it and got the following error during the build process of llvm when the package is not installed.

Traceback (most recent call last):
  File "/root/build/llvm_tools/llvm-11.0.0.src/projects/libcxx/utils/merge_archives.py", line 12, in <module>
    import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'

it probably works for 16.04 because of an older python version, but that's just a guess. If you tell me that it works without this package on Ubuntu 16.04, I will add a check such that it is only installed when the Ubuntu version is >= 18.04.

Comment thread scripts/genDistance.sh
Comment on lines +64 to +65
prefix="$TMPDIR/dot-files/$(basename $binary)"
while ! opt -dot-callgraph $binary.0.0.*.bc -callgraph-dot-filename-prefix $prefix >/dev/null 2> $TMPDIR/step${STEP}.log ; do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this address #87?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. The output directory and name of the created file have changed for the -dot-callgraph flag, the -callgraph-dot-filename-prefix flag makes sure, that the callgraph dot file still lands in the dot-files directory.

I'd have an idea how to address #87, but currently I don't have time. I'll pitch the idea in the issue report later on

Comment thread scripts/build/aflgo-build.sh
@Liblor Liblor mentioned this pull request Mar 18, 2021
@Liblor

Liblor commented Mar 18, 2021

Copy link
Copy Markdown
Author

I think this should address the raised points. I fixed the error handling in a separate pull request (#91). Thanks for your feedback, @mboehme!

@mboehme mboehme merged commit cf5c7ab into aflgo:master Mar 19, 2021
@mboehme

mboehme commented Mar 19, 2021

Copy link
Copy Markdown
Collaborator

Awesome! Thanks @Liblor. LGTM.

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

Successfully merging this pull request may close these issues.

2 participants