avast / avast/retdec

[capstone2llvmir]: Missing type for register number: 244

Open
#1,228 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

## Environment
- retdec version: v5.0
- OS: Windows 11
- Target binary: MSVC 6.0 / 32-bit PE (x86)

## Command
```
retdec-decompiler YDKJ6.exe
```

## Output
```
Running phase: Unpacking ( 0.08s )
No matching plugins found for 'Microsoft Linker 6.0'
No matching plugins found for 'MSVC 6.0'
No matching plugins found for 'Microsoft'
Running phase: Initialization ( 0.22s )
Running phase: Providers initialization ( 0.26s )
Running phase: Input binary to LLVM IR decoding ( 0.78s )
[capstone2llvmir]: Missing type for register number: 244
```

### Analysis
Register 244 corresponds to `X86_REG_PF` (Parity Flag), defined in `include/retdec/capstone2llvmir/x86/x86_defs.h`:

```cpp
enum x86_reg_rflags
{
X86_REG_CF = X86_REG_ENDING + 1, // = 243
// reserved 1
X86_REG_PF, // = 244
...
};
```

The error originates from `getRegisterType()` in `src/capstone2llvmir/capstone2llvmir_impl.cpp`:

```cpp
llvm::Type* getRegisterType(uint32_t r) const
{
auto fIt = _reg2type.find(r);
if (fIt == _reg2type.end())
{
throw GenericError(
"Missing type for register number: " + std::to_string(r));
}
return fIt->second;
}
```

`X86_REG_PF = 244` is missing from the `_reg2type` map populated by `initializeRegTypeMap()` in the version I am using. Note: checking the current `master`, `X86_REG_PF` appears to already be present in `_reg2type` — so this bug may have been fixed after the release I am using. The version field above should help identify whether this is a regression or a known fixed issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/capstone2llvmir/capstone2llvmir_impl.cpp, inspect initializeRegTypeMap(), and compare the v5.0 code with the current master entry for X86_REG_PF. Reproduce retdec-decompiler YDKJ6.exe if the sample is available, then confirm whether the release needs the missing register mapping and a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.