Skip to content

Releases

Relic 1.7.0

Choose a tag to compare

@github-actions github-actions released this 24 Nov 13:00
96bc147

Relic 1.7.0

The decompiler's output now compiles again and computes what the program computes more often
than Ghidra's, angr's or RetDec's, measured by running it. Function detection is exact or close
to it on every benchmark build. Most of what changed was found by the new benchmarks.

Download

System File
Windows (x86-64) relic-1.7.0-windows-x86_64.exe
Linux (x86-64) relic-1.7.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.7.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.7.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+). SHA256SUMS lists the hashes of every file.

Benchmarks

docs/benchmarks.md now scores decompiler output on more than "is it C":

  • Behavioural equivalence: 42 functions (tools/bench/equiv.c) decompiled from stripped
    builds, compiled again and run against the original on 40 inputs each: Relic 81 of 84, Ghidra
    75, angr 67, RetDec 37.
  • Control-flow and data-flow similarity to the source (graph-kernel similarity of gcc's CFG
    and SSA def-use graphs), and types against DWARF: Relic gets the kind and size of 81.5% of
    parameters and results right (angr 71.8%, Ghidra 40.9%) and the number of parameters for
    95.4% of functions.
  • Function detection: F1 1.000 at -O0 and on AArch64, 0.996 at -O2, 0.995 without
    .eh_frame (Ghidra 0.73–0.98, angr 0.89–0.97).

tools/decomp_quality.py and compare_decompilers.py --save run it; tests/test_equiv.py
runs the equivalence test on every change.

Fixed: pseudocode that computed the wrong thing

  • Signed 64-bit / and % (cqo; idiv) printed as a 128-bit division of an unsigned
    dividend, wrong for negative values: now a / b.
  • Large negative constants in signed comparisons printed unsigned (0xffffffff80000000),
    which made the comparison unsigned: now -0x80000000LL. Unsigned operands of signed
    operations are cast to signed.
  • int * arithmetic added a byte offset as elements (an overrun); a struct pointer moved by its
    size printed p += 8 (8 structs): now p++.
  • A struct field overlapping an earlier one was used by name but not declared (the function
    didn't compile).
  • Rotates and add/subtract overflow flags print as C, not __rol() / __sborrow().

New

  • Parameters: one after an unused parameter is no longer lost (lua_typename(L, t) had
    none and read rsi); registers handed to a callee count; a parameter only passed on gets the
    type the callee gives it (char * when it reaches strlen).
  • Variadic functions (x86-64): int sum(int a1, ...), and calls to them pass the extra
    arguments (sum(3, a1, 2, 3)), where luaL_error used to take 14 parameters.
  • Computed goto (GNU C goto *table[op], Lua's interpreter loop): the labels belong to
    their function, which decompiles whole as a switch, on x86-64 and AArch64. They used to be
    84 separate functions.
  • Switch lookup tables gcc makes (CSWTCH) are declared with their contents
    (static const int tbl_30e0[7] = { 2, 1, 1, 1, 1, 3, 2 };) instead of read by address.
  • libgcc's 128-bit helpers (__umodti3, __udivti3, __multi3 ...), when the symbol table
    or library signatures name them, are the operators they implement.

Also fixed

  • A switch's bounds check with moves between the cmp and the branch was missed, so the table
    was read to its 512-entry cap and one function swallowed the eleven after it (zstd).
  • Big functions decompile faster: Lua's ~700-block interpreter loop in 18 s instead of 47 s,
    same output.

Versioning

A MINOR release: new features and fixes, nothing removed or changed incompatibly.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

2a431f9a476698d69b3a47d4b18100d93e6ce59d6d7174f72c4270f7d62fa766  relic-1.7.0-linux-x86_64.tar.gz
e6c98fbee83dfb3fdd15f1e4d75db4938da88f2e4a05d0a68be339961448eebd  relic-1.7.0-macos-arm64.zip
d4a304f0dbbb7db488908531f60ad8719d817467fbd8d3fd70f421d57fb34779  relic-1.7.0-macos-x86_64.zip
e5d1b25c25f990456bf9add1985ce91dde734dd7b24ea4df464d1987dc73c979  relic-1.7.0-windows-x86_64.exe
f93563299c4b8cec210d40d5a777cf7f517e4765d6d14a1598387e027029f0fe  relic_re-1.7.0-py3-none-any.whl
06c30564b980829c4a3f64ef5460e5c9a087ab1981e45ee23a229c5efc881a9e  relic_re-1.7.0.tar.gz

Relic 1.6.0

Choose a tag to compare

@github-actions github-actions released this 18 Nov 03:14
a93a18b

Relic 1.6.0

Relic measured against Ghidra, angr, RetDec, radare2 and LIEF, with the pseudocode bugs that
comparison turned up fixed. Structs whose fields share a register now read like the source.

Download

System File
Windows (x86-64) relic-1.6.0-windows-x86_64.exe
Linux (x86-64) relic-1.6.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.6.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.6.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+). SHA256SUMS lists the hashes of every file.

Benchmarks

Stripped builds of brotli, Lua and zstd (-O0, -O2, -O2 without .eh_frame, AArch64), against
the other open-source tools. Everything, with the method and caveats, is in
docs/benchmarks.md; the scripts are in tools/ (compare_tools.py,
compare_formats.py, compare_decompilers.py, bench_charts.py).

  • Function detection: Relic has the best F1 of the code analysers in every build
    (0.963–0.986; Ghidra 0.73–0.98, angr 0.89–0.97, radare2 0.73–0.90), with or without unwind
    tables, and is 3–5× faster than angr and 4–27× faster than Ghidra.
  • Decompiler output that is valid C: zstd 92% (RetDec 83%, Ghidra 69%, angr 41%), brotli 82%
    (RetDec 82%, Ghidra 69%, angr 49%), lua 98–99% (Ghidra 95–97%, RetDec 92–97%, angr 88–91%).
    Ghidra's decompiler is faster per function; Relic is 3.5–8.5× faster than angr's.

New

Structs whose fields share a register. struct pair { int a, b; } travels in one register;
it now shows as the struct, on x86-64 and AArch64, in parameters and results:

struct pair swap(struct pair a1)
{
    return (struct pair){ a1.b, a1.a + 1 };
}

Floats packed in one register still show as before.

AArch64 struct results without a header. A function writing where x8 pointed on entry
returns a big struct: it takes that pointer as a first parameter result, and its callers pass
one buffer for it (make(buf_30, argc, 7)), where it used to read *x8 = a1;.

x86 shrd / shld read as the shifts they are, (a >> n) | (b << (64 - n)), not an
__shrd() call no compiler knows.

Fixed

Pseudocode that gcc rejected, found by the benchmark (valid C on zstd went from 122 to 275 of 290
functions, on Lua from 249 to 293 of 294):

  • Arithmetic C allows only on integers (p * 8, p & 7, two pointers of different types
    subtracted) casts the pointers to int64_t.
  • A struct pointer read from an integer array or an unnamed global is cast before ->
    (((struct s_18 *)a1[3])->f_18, which Lua's lua_State accesses are full of).
  • An offset added to a char * prints as a number, never as a string literal at that address.
  • A call through a local that isn't typed as a function pointer gets a cast.
  • A recovered struct no longer declares a flexible array member alone ([0]) or in the middle
    (its length runs up to the next field).

Versioning

A MINOR release: new features and fixes, nothing removed or changed incompatibly.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

7482096f6c6d46b480dc917581e09c109fcbb0505be85aa1f6233ead9c94be9b  relic-1.6.0-linux-x86_64.tar.gz
fb42bdc24013482744e4eb1898d72d17bbfc7203f6817816e62fbf8d6e408f34  relic-1.6.0-macos-arm64.zip
bf7e4ed2102b97f792ac9712d627c1f9a5b07faed63ba597a093539a3dced7f5  relic-1.6.0-macos-x86_64.zip
2abb10874342eea472e8551c3961f290732844c61e88a6e769a9d7ee7a74c0c0  relic-1.6.0-windows-x86_64.exe
c63b78cd43d0ec19e96df2f41307ff342528a7718e99c54419e536daf99b1053  relic_re-1.6.0-py3-none-any.whl
47fc5cd477ca762e72ed39c06fddbf361a5ddfe79e15095518d8e31995655c55  relic_re-1.6.0.tar.gz

Relic 1.5.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 07:33
b1c7161

Relic 1.5.0

Structs passed and returned by value now show up in the pseudocode, on x86-64 Linux and on
AArch64. Several older decompiler bugs that this work turned up are fixed too.

Download

System File
Windows (x86-64) relic-1.5.0-windows-x86_64.exe
Linux (x86-64) relic-1.5.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.5.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.5.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+). SHA256SUMS lists the hashes of every file.

New

Structs passed and returned by value. Import a header with the prototypes (relic types,
File > Import C header) and a function that takes or returns structs by value reads like the
source:

struct pt add(struct pt a1, struct pt a2)
{
    return (struct pt){ a2.x + a1.x, a1.y * a2.y };
}

struct big make(long a1)
{
    struct big *result = &(struct big){0};  // the result (the caller's, passed as a hidden first argument)
    result->a = a1;
    ...
    return *result;
}

Its callers pass compound literals or local structs and read the result as one variable:
r1 = add((struct pt){ v2, 2 }, (struct pt){ 3, v2 });, buf_48 = make(v2);,
total(buf_48), r1.x.

  • x86-64 Linux (System V): structs of up to 16 bytes in integer and SSE registers (also mixed),
    bigger ones and ones that no longer fit in the registers on the stack, big results through a
    hidden pointer.
  • AArch64: structs of up to 16 bytes in x registers, structs of up to four doubles one per
    v register, bigger ones by reference (they still read as a1.b), big results through x8.

The test programs are decompiled at -O0, -O1 and -O2, the pseudocode is compiled again (and run
under qemu for AArch64), and it prints what the original program prints.

Not covered yet: structs whose fields share a register (struct { int a, b; }, two floats),
other ABIs (Windows, 32-bit ARM, MIPS, RISC-V, PowerPC). Those keep the usual parameters, and a
header no longer puts types on registers it can't place.

Header types guide the pseudocode. A parameter typed by a header decides which side of
p + i is the pointer: a1[i], where -O0 code used to read count[a1]. Signatures keep the
header's const (const char *a1).

Fixed

  • Bytes of one stack slot read as separate variables. A value stored whole and read back in
    parts (a struct copied a word at a time, a register spilled and read a byte at a time) became
    several variables, so what was written to one wasn't seen in the others. Those reads are now
    parts of that one slot. This fixed buffers in grep's main (what wcrtomb writes) and in gzip
    (a strcpy target split into an int and a byte).
  • A double constant stored into a local struct's field printed as an integer read from the
    constant's address (var_b8.x = *(int64_t *)0x2050). It now reads 1.0.
  • A vtable read one slot too far on PowerPC64 ELFv2, into the typeinfo after it, made up a
    method at 0x10 that couldn't be decompiled.

Versioning

Releases now follow Semantic Versioning on purpose: the commands and their
options, the --json output, the scripting and plugin API and project files are the public
interface (see Versioning in the README). The Release workflow refuses a version that isn't
MAJOR.MINOR.PATCH, isn't newer than every release so far, or is marked a pre-release without a
-rc.1-style part (or the other way round). 1.5.0 is a MINOR release: new features, nothing
removed or changed incompatibly.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

844c640e4ecc81f94455c386d7326cc3c2a501325e544eca4b148d7616f5314e  relic-1.5.0-linux-x86_64.tar.gz
a95c6b8a27b49f7cd5ea893ae091a9aef3c52cb32c64dd6ad1020e3841f56084  relic-1.5.0-macos-arm64.zip
5048f9b907726a27a3169bfa54d6c72bab0ffbd8dc18911c6c73b1396836436a  relic-1.5.0-macos-x86_64.zip
c99a783e7cd5846d1a47ee25e6e9b653bfee073dec57dc22f5df928d9d5fb74e  relic-1.5.0-windows-x86_64.exe
23444e9ef8308608e783945f5a731e24c98c44d9533ddfa899fd7c886531c23a  relic_re-1.5.0-py3-none-any.whl
d86713892ca017ad3dfafc022183009e38a6ad77189b9c652da086c9805d7c4c  relic_re-1.5.0.tar.gz

Relic 1.4.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 01:51
afcfadb

Relic 1.4.0

C++ virtual calls are now resolved on ARM, MIPS, RISC-V and PowerPC, not just x86 and
AArch64. The GUI gets a window for comparing two builds, and stripped programs for those
processors get their main found more often.

Download

System File
Windows (x86-64) relic-1.4.0-windows-x86_64.exe
Linux (x86-64) relic-1.4.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.4.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.4.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+). SHA256SUMS lists the hashes of every file.

New

Virtual calls on ARM, MIPS, RISC-V and PowerPC. Relic follows a C++ object from where it is
made (a constructor, a vtable stored in place, dynamic_cast, a function that returns it, an
argument) to the call through its vtable, and lists the methods that call can reach. This
covers ARM and Thumb, MIPS in both byte orders and MIPS64, RISC-V, and 32-bit and 64-bit
PowerPC (ELFv1 and ELFv2), at -O0 and -O2. The targets go into cross references and the call
graph, and argument recovery uses them.

File > Compare with older build. relic diff in the GUI. It lists the functions that
changed (most changed first), were added, were removed or stayed the same. Pick one to see
its diff in instructions or pseudocode, double-click to go to it, or port the older build's
names and comments with one button.

Fixed

  • C++ classes on other processors. On ARM, vtable entries kept the Thumb bit, so virtual
    methods got no names. Big-endian PowerPC64 (ELFv1) vtables point to function descriptors, so
    they were read only partway. On 32-bit PowerPC without PIC, libstdc++'s typeinfo vtables are
    copied into the program, and three of the five test classes were missed.
  • Big-endian PowerPC64 (ELFv1) glibc programs. Their call stubs weren't recognised, so no
    imported function had a name, and a stripped program had no main.
  • main in static, stripped programs when there are no signatures for that C library: MIPS
    (both byte orders), RISC-V, ARM, 32-bit PowerPC and PowerPC64 (ELFv1 and ELFv2) now find it.
  • relic diff --port --overwrite counted comments that were already the same as ported.

Faster

To find a callee's long double stack parameters, the decompiler looked into that callee's
callees too, which lifted most of the call graph for a single function. It now only looks at
functions that can take one (they use 80-bit values, or call one that does). The output is the
same; opening bash's main for the first time went from 34.8 to 27.8 seconds.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

181065768827b809a0f1ddce651b2b881e0073fa24fcfb98e6f34ff94566cbc3  relic-1.4.0-linux-x86_64.tar.gz
7f5f441d77ad236a9797706202708431774d9af9aba2f7d3cc8f24de14fe6fcf  relic-1.4.0-macos-arm64.zip
e8fd9b649d061d3f0b230f0569beaddbbb0e3fe396d18346f42e6b0601b7fcd9  relic-1.4.0-macos-x86_64.zip
003bbc6a0cd5dfd99ce1ea389a6d6b5047e56d807e6cbb6bc114a145bf38821b  relic-1.4.0-windows-x86_64.exe
bb218299b44906f782594b6e0e437ae85ab5420171b584e93adf05f4905fc364  relic_re-1.4.0-py3-none-any.whl
e26fe651ce6d3a599ba90b9728380e2ab08a3f6871af6e70f126e96bd36cb36b  relic_re-1.4.0.tar.gz

Relic 1.3.0

Choose a tag to compare

@github-actions github-actions released this 16 Nov 22:15
5f2b187

Relic 1.3.0

This release carries your work over to a new build: the names, comments and variable names you
gave the old one go to the functions relic diff matches in the new one.

Download

System File
Windows (x86-64) relic-1.3.0-windows-x86_64.exe
Linux (x86-64) relic-1.3.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.3.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.3.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+). SHA256SUMS lists the hashes of every file.

New

Port annotations from an older build (relic diff OLD NEW --port, File > Port from older
build, port_from() in scripts). When a new version of something you already reversed comes
out, every function relic diff matches gets:

  • its name: yours, or the old build's symbol when the new build is stripped;
  • the comments, bookmarks and number formats on the instructions that didn't change (the code
    of the two functions is lined up line by line; what was on changed code is counted, not
    guessed at);
  • its repeatable comment;
  • the names and types of its decompiler variables: all of them when the code is identical,
    only the arguments when it changed (v3 in one build need not be v3 in the other).

Globals that unchanged instructions refer to get their old names too. What the new build already
has (your names and comments, its own symbols) is kept unless you pass --overwrite, and a name
already used in the new build isn't given to a second function. The CLI saves the result to the
new build's project file (--no-save only lists it); in the GUI it is one undo step and the old
build is analysed in the background.

$ relic diff chall chall_fixed --port
0x40133b  add_note
0x401539  hash_string
0x40160c  read_name
0x4040a0  notes  (global)
ported 3 function name(s), 1 global(s), 2 comment(s), 1 on changed code not placed
saved chall_fixed.relic.json

On bash against itself, porting the annotations of 2,296 matched functions takes a quarter of a
second after the diff.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

a55fdd99031d5d6a403abb8e0a460f12bfb314b4535b942c03eeb0b86a818b85  relic-1.3.0-linux-x86_64.tar.gz
e0efeaf5bb92e23d4a1c0f03f068eda658a871f24721500c659e17d91fb51cbb  relic-1.3.0-macos-arm64.zip
7831465d281ada30de4043968860e4562403971f8c1c5e9c35752e0c0737d6d2  relic-1.3.0-macos-x86_64.zip
a40a3cf9e0c82a3590cfd5accbe883a60bcf8306644b30d4155779d8c43cabc3  relic-1.3.0-windows-x86_64.exe
5b7bf5e485a943fc89b413d7b8c21ef433525b3e93d230ca45ea6a753043a841  relic_re-1.3.0-py3-none-any.whl
4e2981c61b61d26f0dce0aa83f0c654a63d0185efd9ab32cef07ed67273af112  relic_re-1.3.0.tar.gz

Relic 1.2.1

Choose a tag to compare

@github-actions github-actions released this 09 Nov 17:12
911276e

Relic 1.2.1

This release fixes bugs in relic diff, which came out in 1.2.0.

Download

System File
Windows (x86-64) relic-1.2.1-windows-x86_64.exe
Linux (x86-64) relic-1.2.1-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.2.1-macos-arm64.zip: Relic.app
macOS, Intel relic-1.2.1-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+).

Fixed

A block added near the start of a function made all of it look changed. Code is compared
block by block, and adding one block (an early if (x < 0) return -1;, say) renumbered every
block after it. Each branch to one of those blocks then looked different too. A function with
that one-line change scored 58% alike, and -f listed almost every line as removed and added
again. Block numbers are now left out when functions are compared and when the diff lines up
their lines. The same function now scores 94% alike, and -f shows just the six lines that
were added.

relic diff -f FUNC -d crashed when a function couldn't be decompiled. It printed a Python
traceback. Now that side of the diff shows // not decompiled (...), and the other side's
pseudocode is still shown.

Matches found by similarity alone didn't lead anywhere. The callees and callers of a
matched function are tried next, but only for matches found by identical code or by name.
Matches found in the last, similarity-only pass are now followed through the call graph too.

A function called from everywhere could make the diff very slow. Comparing the callers of
a hub like xmalloc against each other is now capped. The last pass finds those callers
anyway.

Releases

Every release now comes with SHA-256 hashes: a SHA256SUMS file among the downloads, and the
same list at the end of the release notes. To check what you downloaded, run
sha256sum -c SHA256SUMS --ignore-missing (on macOS, shasum -a 256 -c SHA256SUMS).

The Release workflow has a new add missing option. It rebuilds an existing release from
its tag and uploads only the files the release is missing. 1.2.0 went out without its macOS
Apple-silicon build because that runner never started; this option adds it, along with
hashes for every 1.2.0 file.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

cab9c2a1cd6b795a2e03b5c27abcfd40e20f49b560199453be3a1d31a89116b2  relic-1.2.1-linux-x86_64.tar.gz
1914d7f140806cca96aa3c445b5dc2b82ac0d94f514af69bc751e3da65f26e3f  relic-1.2.1-macos-arm64.zip
5498591de0626b439751582fd75b2e3bd6a17ab418f03975e92add69f39c35db  relic-1.2.1-macos-x86_64.zip
7f72a87249c0a785d2c667a4f2ee28de03f180538ef87381691f23847027cbf8  relic-1.2.1-windows-x86_64.exe
a43754a76c00528fa1101186882f396f37c4a2c5c322695d2a5d0ddc0a4618d8  relic_re-1.2.1-py3-none-any.whl
8c6a0656dc20f4ea28d7bc9c78b2fef97e7737e7647e5c2876186a7e8585d069  relic_re-1.2.1.tar.gz

Relic 1.2.0

Choose a tag to compare

@github-actions github-actions released this 09 Nov 16:20
e3481f7

Relic 1.2.0

This release adds binary diffing. relic diff OLD NEW matches the functions of two builds of a
program, the way BinDiff and Diaphora do, and tells you which functions changed, which were
added and which were removed. That's where you start when you want to know what a vendor's
patch fixed, or when you want to carry your work over to a new build.

Download

System File
Windows (x86-64) relic-1.2.0-windows-x86_64.exe
Linux (x86-64) relic-1.2.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.2.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.2.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+).

relic diff

Take tests/src/vuln.c, replace its gets with fgets, add a function, and build both versions
stripped:

$ relic diff chall chall_fixed
17 matched (16 identical, 1 changed), 1 added, 0 removed

similar         old         new  how      name
  92.0%      40160c      40160c  calls    sub_40160c

added:
      401708  sub_401708  (25 bytes)

-f shows how one function changed. Add -d to compare the pseudocode instead of the
instructions:

$ relic diff chall chall_fixed -f sub_40160c -d
sub_40160c: 0x40160c -> 0x40160c, 92% alike (matched by calls)
--- old:sub_40160c @ 0x40160c
+++ new:sub_40160c @ 0x40160c
@@ -1,8 +1,8 @@
 void sub_40160c(void)
 {
-    char buf_48[64];  // ret-0x48
+    char line[64];  // ret-0x48
 
     puts("name?");
-    gets(buf_48);
-    printf("hello %s (%d)\n", buf_48, sub_401539(buf_48));
+    fgets(line, 64, stdin);
+    printf("hello %s (%d)\n", line, sub_401539(line));
 }

How it works:

  • Comparing. Functions are compared by their code with everything that depends on where
    they're linked taken out (the same normalization as the Lumina fingerprints). Calls to imported
    and library functions are kept by name. A function that only moved, or lost its symbol, counts
    as identical.
  • Matching. Matches are found from the surest evidence to the weakest: code that appears
    once in each build and is identical in both, then a name that appears once in each build (a
    symbol, a library signature's name or your own, never a generated sub_...), then the call
    graph (the callees and callers of functions already matched), and last, whatever is left that
    is clearly the same function.
  • Output. Changed functions are listed most changed first. --all lists the unchanged ones
    too, and --json gives a script the whole result. From Python, use
    relic.analysis.bindiff.diff(old_analysis, new_analysis).

It's quick enough for real programs: diffing bash against itself takes 9 seconds, and diffing
two unrelated programs of that size takes about 17.

Under the hood

  • The decompiler's prepare step was a single 140-line function. It's now split into named
    stages: joining values the ABI splits, the result, the parameters, the result's width, and
    the clean-up passes. The pseudocode for every test binary comes out byte-for-byte the same.
  • The Lumina fingerprint's normalization is now a function of its own, which relic diff uses
    too. Fingerprints haven't changed, so existing stores still match.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

1123c7d6cfa27e239a5a37168799b133cb17913814726ae07a18993acdaebb0c  relic-1.2.0-linux-x86_64.tar.gz
985600a4a2da66e16cbf3c45d380e2abc32ff38daa86d8cdeae2116fa3d8a688  relic-1.2.0-macos-arm64.zip
45171c07f23c9d12a386bf76ec2eb1dce5e888850074e542d937c6a31280579f  relic-1.2.0-macos-x86_64.zip
a12222c9234edb9ed126a1203561d041909a7587b230d19c6e228af52f9f43d7  relic-1.2.0-windows-x86_64.exe
87884a62f0ac729fe883339cedd735b8a813c6268eeb4b8093ee7e971b81b3e7  relic_re-1.2.0-py3-none-any.whl
5b9d1fe99d4c22094ea14ad9ffc60f796fb087d8e90b935626c0174e662dc9a5  relic_re-1.2.0.tar.gz

Relic 1.1.4

Choose a tag to compare

@github-actions github-actions released this 01 Nov 03:56
17815a8

Relic 1.1.4

This release adds long double, which until now was the one gap in the decompiler's x87
support. Code that uses long double, on 32-bit x86 or on x86-64, used to come out as
__asm("fld xword ptr [...]") lines. On x86-64 a function returning a long double could even
come out empty. Now you get C you can read and compile again.

Download

System File
Windows (x86-64) relic-1.1.4-windows-x86_64.exe
Linux (x86-64) relic-1.1.4-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.1.4-macos-arm64.zip: Relic.app
macOS, Intel relic-1.1.4-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+).

long double

long double ld_scale(long double x, int k) { return x * k + g_ld; }

compiled for 32-bit x86 used to decompile to

double scale(int a1, int a2, int a3, int a4)
{
    double v1;

    v1 = (double)a4;
    __asm("fld xword ptr [esp + 4]");
    __asm("fld xword ptr [eax + 0x38]");
    return v1 * x87_1 + x87_1;
}

and now decompiles to

long double ld_scale(long double a1, int a2)
{
    return (double)a2 * a1 + g_ld;
}

What's covered, on both x86 and x86-64:

  • Values in memory. Globals, locals, pointers and arrays of long double get that type.
    Stepping through an array moves by whole elements (12 bytes on x86, 16 on x86-64).
  • Parameters and results. A long double parameter takes its 12- or 16-byte stack slot as
    one parameter, not two or three integers. A long double result comes back on the x87 stack,
    and on x86-64 that is how Relic tells it apart from a double in xmm0. On 32-bit x86, a
    float, a double and a long double all come back on the x87 stack, so the type is worked
    out from how callers store the result and from the function's own code.
  • Calls. printf("%Lf", x) and other %L conversions take one long double argument from
    the stack. Arguments that unoptimized code copies over word by word (push qword twice, or
    push dword three times) become a single argument. A parameter that a function only passes
    on to another function is still recognized as a long double.
  • Math and constants. sqrtl, fabsl and the other l functions, and constants like
    0.25L.

The test sample, built at -O0 and -O2 for both x86 and x86-64, recompiles from its
pseudocode and gives the same results as the original.

One limit: when the decompiler simplifies constant expressions itself, it works with double
precision. In practice this matters only for constants that a double can't represent exactly.

Fixed

x86-64: calls returning a double were taken to leave it on the x87 stack. That only
mattered in functions that also use the x87 (that is, long double code), where it threw off
everything that came after such a call.

Relic 1.1.2

Choose a tag to compare

@github-actions github-actions released this 24 Oct 15:32
82dcd66

Relic 1.1.2

A faster release. Opening a large binary and decompiling a whole program take a quarter to
nearly half less time. The results are exactly the same as 1.1.1: the same functions, names,
cross references and pseudocode.

Download

System File
Windows (x86-64) relic-1.1.2-windows-x86_64.exe
Linux (x86-64) relic-1.1.2-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.1.2-macos-arm64.zip: Relic.app
macOS, Intel relic-1.1.2-macos-x86_64.zip: Relic.app

The macOS app is not signed: the first time, right-click it and choose Open. The wheel is also
attached, for installing with pip (Python 3.10+).

Faster

1.1.1 1.1.2
Opening stripped gdb (the analysis) 28.9 s 21.3 s
relic decompile --all on make 44.6 s 29.4 s
relic decompile --all on a MinGW program 27.0 s 14.5 s
relic decompile --all on find 28.9 s 19.6 s
relic decompile --all on ls 22.1 s 16.7 s

Decompiling one function in the GUI is about a fifth faster.

  • Finding functions that are only called indirectly was the slowest part of opening a large
    stripped program. Each time it found one, it went back over every gap between functions it had
    already looked at. It now looks only where something could have changed.
  • Decompiling a whole program (relic decompile --all, or -o to write a C file) prepared
    many functions twice: once to see which structs their callers and callees use, and again for
    their own pseudocode. Each is now prepared once.
  • The decompiler's own steps do less repeated work: dominance between blocks, finding where
    the two sides of an if meet, removing stack writes nobody reads, and copying and walking the
    intermediate code.

Fixed

  • relic decompile --all stopped with a Python traceback on MinGW programs, at
    __CTOR_LIST__: a name on data inside the code, which has no instructions to decompile. That
    place now says so (// __CTOR_LIST__ @ 0x14000ec10: not decompiled (...)) and the listing goes
    on, as the C export already did. Asking for that function alone gives a one-line error.

Relic 1.1.1

Choose a tag to compare

@github-actions github-actions released this 23 Oct 01:10
d32b3ee

Relic 1.1.1

A bug-fix release. Automatic names no longer slow down opening large binaries, a few names they
suggested were wrong, and pseudocode with two structs pointing at each other could crash.

Download

System File
Windows (x86-64) relic-1.1.1-windows-x86_64.exe
Linux (x86-64) relic-1.1.1-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.1.1-macos-arm64.zip: Relic.app
macOS, Intel relic-1.1.1-macos-x86_64.zip: Relic.app

The macOS app is not signed: the first time, right-click it and choose Open. The wheel is also
attached, for installing with pip (Python 3.10+).

Fixed

  • Opening a large stripped binary is fast again. To name a function from its assert(),
    1.1.0 decompiled the whole function, together with every function it calls. On gdb that added
    over half a minute to the analysis. The name is now read from the instructions just before the
    assert() call. Full decompilation is used only when that does not find it, for example on
    32-bit x86. The names given are the same.
  • Variables named after the function that set them could get a broken name.
    initialize_table() gave ialize_table, and calculate_sum() gave ulate_sum. A prefix
    such as get, init or calc now counts only as a word of its own, as in get_config or
    readHeader.
  • A variable no longer gets the same name as an automatically named function, for example
    usage or xmalloc.
  • The pseudocode no longer crashes when two recovered structs point at each other, for
    example a list node pointing to its list and the list back to the node. Some functions of
    bash showed a "maximum recursion depth exceeded" error instead of their code.
  • The GUI now follows RELIC_AUTO_NAMES=0, as the command line does, until View > Automatic
    names is used. Before, the GUI turned automatic names on regardless.