NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.6k stars 5.87k forks source link

Extra local variable #2539

Open rfalke opened 3 years ago

rfalke commented 3 years ago

Describe the bug In a simple function an extra variable is generated

To Reproduce Steps to reproduce the behavior:

  1. https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/change_local_via_function/ia32_elf/subject.exe

Expected behavior Output may look like

undefined4 main(void)

{
  undefined4 local_14 [2];

  local_14[0] = 0x29;
  inc(local_14);
  printf("The answer should be 42 and is %d\n",local_14[0]);
  return 0;
}

Even better would be:

undefined4 main(void)

{
  undefined4 local_14;

  local_14 = 0x29;
  inc(&local_14);
  printf("The answer should be 42 and is %d\n",local_14);
  return 0;
}

It currently is:

undefined4 main(void)

{
  undefined4 local_14 [2];
  undefined *local_c;

  local_c = &stack0x00000004;
  local_14[0] = 0x29;
  inc(local_14);
  printf("The answer should be 42 and is %d\n",local_14[0]);
  return 0;
}

Environment (please complete the following information):

gtackett commented 3 years ago

šŸ˜„ Why 42? (as Douglas Adams was often asked)

Of much less universal importance, I (like probably many others) have observed this behavior, and I'd like to second the request for improvement. šŸ‘

rfalke commented 1 year ago

Issue is still in version ghidra_10.3.2_PUBLIC.