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.
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`.
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`).
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.
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.