avast / avast/retdec

Turned off unknown architecture detection when asking for byte length

Open
#245 0 comments 0 reactions 0 assignees View on GitHub
C-fileformat C-utils enhancement
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

In [commit 9c5b5ab243](https://github.com/avast-tl/retdec/commit/9c5b5ab243c4f7550f6b179e96938127b846a994) unknown architecture detection in `FileFormat::getNibbleLength` and `FileFormat::getByteLength` was turned off. Detection was problematic because it only accepted currently supported architectures by decompiler (`fileformat::Architecture` enum) as known architectures, so for example for IA-64 architecture those functions would return 0, breaking many other functions using them.

After discussion with @s3rvac, we decided to always assume 8-bit byte for now. This will not work with very exotic architectures (old 6/12-bit byte architectures or 16-bit byte TI), but those would not work correctly anyway. Also return value of those functions were often not checked by functions using them leading to incorrect results without any error report.

To do this correctly in the future:
1. We will have to make unknown architecture detection much more accurate (to differentiate unknown architectures from unsupported ones).
2. Other functions using this functionality will have to check that returned value is non-zero and report problem if it is zero.

(Change is currently applied in `elf-core-support` branch, but it will be eventually merged to master.)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading FileFormat::getNibbleLength and FileFormat::getByteLength and the callers that depend on their return values, then compare the current code with the elf-core-support branch. Done means unknown architectures no longer produce incorrect zero lengths, while genuinely unsupported cases are handled without silent errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.