lifting-bits / remill

Library for lifting machine code to LLVM bitcode
Apache License 2.0
1.29k stars 145 forks source link

Look for semantics in a relative directory #431

Closed artemdinaburg closed 4 years ago

artemdinaburg commented 4 years ago

Currently remill only looks for semantics in a hardcoded absolute path; it would be nicer to look for them in a path relative to the remill execuable or one specified via flags.

Strace output:

access("/remill/build/remill/Arch/X86/Runtime//aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
access("/remill/build/remill/Arch/AArch64/Runtime//aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
access("/opt/trailofbits/remill/share/remill/8.0/semantics///aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/share/remill/8.0/semantics/aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/remill/8.0/semantics/aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
access("/share/remill/8.0/semantics/aarch64.bc", F_OK) = -1 ENOENT (No such file or directory)
TheGreatRambler commented 4 years ago

Same problem

TheGreatRambler commented 4 years ago

This makes mcsema entirely unusable on Windows. It would be great if somebody fixed this. I tried compiling it myself but I couldn't get the toolchain working.

artemdinaburg commented 4 years ago

I think this may be a relatively easy fix. I am currently thinking to set up both a relative directory (maybe to installation artifacts if I can wrangle enough CMake) and also a path that can be passed as a command line argument.

pgoodman commented 4 years ago

I can make a quick fix with a command line flag :-)

artemdinaburg commented 4 years ago

@TheGreatRambler Looking at the current code, it should also look in the REMILL_INSTALL_SEMANTICS_DIR directory:

https://github.com/lifting-bits/remill/blob/3a16ad4a822e6a379e8f9d82b2d263dda25472e0/remill/BC/Util.cpp#L461-L470

Placing things there may work for you now.

TheGreatRambler commented 4 years ago

All these paths are defined for linux, so I can't be at all sure what these paths translate to on Windows. I'm looking for a portable solution too, an install path is a dangerous thing

pgoodman commented 4 years ago

@TheGreatRambler you can now specify one or ore search directories with --semantics_search_paths /path/to:/other/path/to. Directories are colon-separated. The directory should contain the semantics file associated with your architecture, e.g. aarch64.bc. You should be able to find these files inside both the build directory and the install directory.

TheGreatRambler commented 4 years ago

Great, thank you