avast / avast/retdec

llvmir2hll:Array pointer in structure problem

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

Description

```
if (it != e) {
ShPtr base;
auto index = getConverter()->convertValueToExpression(it.getOperand());
auto cInt = cast(index);
//printf("%d,%d\n",index,cInt);
//if (cInt && cInt->isZero()) {
if (cInt && cInt->isZero()) {
printf("1\n");
base = getConverter()->convertValueToExpressionDirectly(pointedValue);
++it;

} else {
printf("2\n");
base = getConverter()->convertValueToExpression(pointedValue);
}

return convertGEPIndices(base, it, e);
}
```
change:
`if (cInt && cInt->isZero()) {`
to
`if (cInt && it.isStruct()) {`
the result will be:
```
void test_fn(struct struct_A * var1) {
var1[0].e0[0] = 0;
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the shown LLVM IR-to-HLL pointer conversion code, especially convertGEPIndices and the getConverter() calls. Compare the current struct-index condition with the proposed it.isStruct() condition, then verify that the resulting output matches the shown test_fn example.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.