NationalSecurityAgency / ghidra

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

Tricore mfcr/mtcr not showing in decompilation #1630

Open ABratovic opened 4 years ago

ABratovic commented 4 years ago

Describe the bug mfcr/mtcr instructions show in disassembly but not in the decompilation.

To Reproduce

  1. Open attached sample created by free gcc toolchain for tc1767
  2. Go to isync instruction at '0x80000098'
  3. note previous mtcr instructions are not shown in decompile window

Expected behavior read/write from Special Function Register should be shown in decompile window.

Screenshots 2020-03-13 09_44_43-CodeBrowser_ test_tc1767__test_tc1767 elf

Attachments test_tc1767.zip

Environment (please complete the following information):

Additional context if I change mtcr sleigh from [register]:4 const1227Z = Rd0811; to [ram]:4 const1227Z = Rd0811; then I get output in decompile window, but alas without the write volatile prefix or register name.

ABratovic commented 4 years ago

I note the change from [register] to [ram] is same as my workaround. If this is is the desired resolution then all the text at beginning of tricore.sinc that populates the [register] space should also be deleted. I would consider #1640 (plus removing the redundant register defines currently in tricore.sinc) is the correct solution based on this note in SLEIGH doco _

A space of type register_space is intended to model the processor’s general-purpose registers. In terms of accessing and manipulating data within the space, SLEIGH and p-code make no distinction between the type ram_space or the type register_space. But there are still some distinguishing properties of a space labeled with register_space.

It is read/write.
It is not part of the standard memory map of the processor.
In terms of GHIDRA, there will not be separate windows for the space and references into the space will not be stored.
Named symbols within the space will have Register objects associated with them in GHIDRA.
It is not addressable. Data-flow analysis will assume that data within the space cannot be manipulated indirectly via pointer, so there is no pointer aliasing. Make sure this is true!

_