Commit Graph

6113 Commits

Author SHA1 Message Date
Alessandro Di Federico e6928e34c1 Minor changes 2019-03-06 09:04:58 +01:00
Pietro Fezzardi 6f7d0e49c5 ASTBuildAnalysis: fix emission of short literals 2019-03-01 18:13:49 +01:00
Pietro Fezzardi 5b885d7eb4 Link libEnforceCFGCombingPass to librevng-c 2019-03-01 17:38:48 +01:00
Pietro Fezzardi a5ae26a7a9 EnforceCFGCombingPass depends on RemoveDbgMetadata
Before this change, `EnforceCFGCombingPass` was occasionally failing on
`verifyModule` if called from Caliban, with mismatches in the
`llvm.dbg.cu` debug metadata.
This metadata is a list of `DICompileUnit`, and `verifyModule` was
failing inside `verifyCompileUnits` because some of the visited compile
unit during the verify were not listed in `llvm.dbg.cu`.

One of the reasons of this problem might be that during
the enforcing we clone many things in the enforced function, and this
may cause the cloned stuff not to update the metadata accordingly.
I couldn't track down if this was caused by my misuse of LLVM's API for
cloning, of to some actual bug in LLVM.

In the end I couldn't find out the exact cause and fix it, so this
commit is a workaround. It adds a dependency on `RemoveDbgMetadata`, so
that the debug metadata causing `verifyModule` to fail are removed
before the enforcing, hence preventing things going astray during the
enforcing, and fixing the failure.

This workaround should be fine, because this is one of the last steps
before generating C code, and debug info are note serialized to C
anyway.
2019-03-01 15:55:04 +01:00
Pietro Fezzardi 84ca9f7b74 Fix computation of PHI nodes variable assignments 2019-02-26 10:36:31 +01:00
Pietro Fezzardi 3b2dac4e85 Enforce clang-format 2019-02-25 12:29:15 +01:00
Pietro Fezzardi b44c0dd71d Fix emission of negated if conditions 2019-02-25 11:58:19 +01:00
Alessandro Di Federico 72c34efc57 revng_add_analyses_library: add EXPORT_NAME 2019-02-22 11:36:36 +01:00
Alessandro Di Federico a75c75c305 Make install_pattern available in CMake package 2019-02-22 11:33:28 +01:00
Alessandro Di Federico 94a99fe57c Force linking of all the original libraries
Certain libraries linked to the input executable sometimes are not
required by the executable or other dynamic libraries. Therefore, the
`ld -l` switch ignores them.

This commit forces linking of all the required libraries, no matter
what, by wrapping the list of dynamic libraries in `-Wl,--no-as-needed`
and `-Wl,--as-needed`.
2019-02-19 18:23:29 +01:00
Alessandro Di Federico 00b9ade51f Handle libraries not ending with .so
Sometimes dynamic libraries linked to executables do not end in
`.so`. Previously, we assumed that a version of the library ending in
`.so` was available on the system. However, this is not always the
case. In particular, Ubuntu 16.04 links `ls` to `libselinux.so.1` but no
`libselinux.so` file is available. This can lead to a linking failure.

This commit, correctly handles libraries whose name doesn't end in `.so`
by using the `-l:` linker option (e.g., `-l:libselinux.so.1`).
2019-02-19 17:57:28 +01:00
Pietro Fezzardi 63c8e164dd Create only a single Load for the removed PHI 2019-02-18 19:21:30 +01:00
Alessandro Di Federico 35ff5a4ce4 Add lib/revng/analyses to RPATH
When installing programs we used to add to `RPATH` the `../lib`
directory. However, this is not enough, since the analysis libraries
reside in `../lib/revng/analyses`. This commit fixes the issue.
2019-02-18 07:50:34 +01:00
Pietro Fezzardi 632020ab9b Properly decompile return values 2019-02-13 16:01:25 +01:00
Pietro Fezzardi 49da34f6a6 Fix print of function arguments 2019-02-13 15:27:59 +01:00
Andrea Gussoni af258c6e66 Fix double inserting for check nodes
Avoid double insertion of a predecessor for a check node when also using
`insertBulkNodes`.

Also added assertions to better detect this situation.
2019-02-13 14:44:52 +01:00
Andrea Gussoni 4319ba4e59 HACK: avoid a double insertion of predecessor
Hack to circumvent a probable problem of `setFalse` during
`insertBulkNodes` which causes a `set` node to have a repeated
predecessor.
2019-02-13 10:14:16 +01:00
Andrea Gussoni 6e2f087583 Track IfNode condition negation
Added a method to check if the `then` and `else` branches of an `IfNode`
have been inverted.
2019-02-13 10:06:38 +01:00
Pietro Fezzardi 15bc2768d0 Fix empty and redundant scopes 2019-02-13 09:52:12 +01:00
Pietro Fezzardi e522d12d23 Properly decompile conditions of if statements 2019-02-13 09:26:57 +01:00
Andrea Gussoni 9b5607ab29 Fix check node false reassignment 2019-02-12 23:28:59 +01:00
Pietro Fezzardi cb08b4ac31 tmp 2019-02-12 20:55:28 +01:00
Alessandro Di Federico 543ab2253d revng-merge-dynamic: improve is_rela detection 2019-02-12 18:40:30 +01:00
Alessandro Di Federico 4b9123fce8 Induction variable name used in range 2019-02-12 18:40:30 +01:00
Alessandro Di Federico 2b99f8e811 Use LD_PRELOAD instead of opt -load
In `opt -load`, the order in which the libraries are provided
matters. Using `LD_PRELOAD` circumvents this issue.
2019-02-12 18:40:30 +01:00
Alessandro Di Federico 6ae0610e2d Force Python versions
This commit switches all scripts to Python 3, except for
`revng-merge-dynamic` which requires Python 2 due to a limitation of
pyelftools.
2019-02-12 18:40:24 +01:00
Alessandro Di Federico 53db84f7d6 s/revamb/revng/g 2019-02-11 16:09:23 +01:00
Pietro Fezzardi 188d8fbdbb Make DecompilationPass an llvm::FunctionPass 2019-02-11 15:10:27 +01:00
Andrea Gussoni 3e2751866e Improve ordering performances
The algorithm that order nodes following the (reverse)post-order now has
a complexity of NLog(N) instead of N^2.
2019-02-11 14:44:14 +01:00
Andrea Gussoni ec7f0f68e2 Disassemble switch in right order
Add the switch successor to the nested `if` tree in the right order.
2019-02-11 14:41:26 +01:00
Andrea Gussoni f790e308e1 Add ID for AST nodes
Added a unique ID to AST nodes, which is useful for serialization
purposes after flattening.
2019-02-11 14:15:07 +01:00
Pietro Fezzardi c5df55dedc Expose DecompilationPass.h header for public use 2019-02-11 14:01:40 +01:00
Pietro Fezzardi f4d5fec5bc First fully functional EnforceCFGComingPass 2019-02-11 12:18:44 +01:00
Pietro Fezzardi b9d04e502c Remove unreachable blocks after RemoveSwitchPass 2019-02-11 12:18:44 +01:00
Pietro Fezzardi b436465921 Apply enforcing on AST 2019-02-11 12:18:44 +01:00
Pietro Fezzardi f0b9648d4a Remove checks that are now redundant 2019-02-11 12:18:44 +01:00
Pietro Fezzardi 1d49d61302 Fix assertion 2019-02-11 12:18:44 +01:00
Pietro Fezzardi 463c40a9cf Add ASTNode children BreakNode and ContinueNode 2019-02-11 12:18:44 +01:00
Pietro Fezzardi 2b1843d898 Fix AST in EnforceCFGCombingPass 2019-02-11 12:18:44 +01:00
Andrea Gussoni 02e1b94daa Added RemoveSwitchPass
Added a new `FunctionPass` which converts `switch` instructions in a
nested chain of `if` checks.
2019-02-11 12:18:44 +01:00
Andrea Gussoni 1297f9645b Disable short-circuit simplification
Disable temporarly short-circuit simplification
2019-02-11 12:18:44 +01:00
Andrea Gussoni 929c0c4cdf Flattening for AST
Implemented the flattening also for the AST trees, taking also care of
adjusting the pointers to the new BBNode in the `root` `RegionCFG`.
2019-02-11 12:18:44 +01:00
Andrea Gussoni dbffa54124 Handle check BBNode in inflate
Considering the `check` BBNode during the `inflate` procedure, and
fixing the functions handling edges and nodes successors accordingly.
2019-02-11 12:18:44 +01:00
Alessandro Di Federico aee194be4a Create revngc CMake package 2019-02-10 16:20:42 +01:00
Alessandro Di Federico d00bf31bca Reorganize the build system 2019-02-10 16:20:24 +01:00
Alain Carlucci b2629efd05 Avoid useless computations when decompiling a single function 2019-02-08 11:44:17 +01:00
Alain Carlucci 2cda9be797 Decompile one function + write on raw_ostream 2019-02-08 11:44:17 +01:00
Andrea Gussoni eba245d35e RemoveBadPC pass
Added a pass that removes the `bad_return_pc` check, which is useful
only when we want to preserve semantics, but it is useless and harmful
for decompilation.
2019-02-07 19:27:08 +01:00
Pietro Fezzardi 7fc7ac4c7b Finish EnforceCFGCombingPass 2019-02-07 19:26:37 +01:00
Pietro Fezzardi c455b516d2 Add Liveness again 2019-02-07 14:44:32 +01:00