Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[X86] Incorrect Reference to Switch Statement Value Table #6695

Open
widberg opened this issue Jul 5, 2024 · 2 comments
Open

[X86] Incorrect Reference to Switch Statement Value Table #6695

widberg opened this issue Jul 5, 2024 · 2 comments
Assignees
Labels
Feature: Analysis Status: Triage Information is being gathered

Comments

@widberg
Copy link

widberg commented Jul 5, 2024

Describe the bug
In the attached test.zip there is an x86_32 Windows executable Test.exe compiled and linked with the Visual Studio 2005 Professional Edition toolchain. For the instruction at 0x00401029, MOVZX EDX,byte ptr [EAX + 0x4010d8], Ghidra generates a reference to 0x004010d3 when it should be to 0x4010d8. This instruction is a lookup into the value table for a switch statement. The reference to the jump table from the indirect jump instruction at 0x00401030 for the same switch statement is correctly marked.

To Reproduce

  1. Open Test.exe in Ghidra and let the analysis complete.
  2. Jump to the instruction at 0x00401029
  3. Observe that the reference is to 0x004010d3

Expected behavior
The instruction at 0x00401029 references 0x004010d8.

Screenshots
image

Attachments
test.zip

Environment:

  • OS: Windows 10 Home 22H2 19045.4529
  • Java Version: 20.0.1
  • Ghidra Version: 11.1.1
  • Ghidra Origin: official GitHub distro releases

Additional Context
This was discovered in boricj/ghidra-delinker-extension#6.

@LukeSerne
Copy link
Contributor

The wrong reference is created by the x86 Constant Reference Analyzer, implemented in the class X86Analyzer. As a workaround, you can disable this analysis during auto analysis and the correct reference is created instead.

The image below shows the listing view of the MOVZX instruction after auto analysis has been run with the x86 Constant Reference Analyzer turned off.

image

And here's the listing view of the region in which the jump tables are stored.

image

@widberg
Copy link
Author

widberg commented Jul 6, 2024

Thank you for tracking this down! Turing that analyzer off did fix the issue. The work around should be good enough for now.

@ryanmkurtz ryanmkurtz added Feature: Analysis Status: Triage Information is being gathered labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Analysis Status: Triage Information is being gathered
Projects
None yet
Development

No branches or pull requests

4 participants