Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In testing, I found that retdec doesn't handle endbr64.
To reproduce this issue, I used the standard
gcc
on Ubuntu 20.04. Here is the version information:I then wrote the following program and named it
test.c
:And compiled it:
Looking at the
test
in objdump, we can see the very first instruction inmain
is endbr64:However, after pushing
test
through retdec-decompiler (compiled from master on 10/30/2020) like so:The resulting
test.c
,test.ll
, andtest.dsm
all contain erroneous (empty) main functions.test.c
test.ll
test.dsm
I assumed this was a capstone issue, and I found that they fixed endbr64 in 4.0.1 and further enhanced handling in the latest version 4.0.2.
I also found that retdec downloads an archive from the Capstone repository that dates back to November 2017 (nearly three years old now). By switching the CMake deps to download the most recent release (4.0.2), retdec now produces proper output. Sample output from an updated retdec/capstone:
test.c
test.ll
test.dsm
In #557 @PeterMatula seems to indicate he isn't sure if an updated Capstone is possible, so my change here may have broken things I'm unaware of. Although it does fix my issues with default
gcc
output (on Ubuntu at least).