You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to understand how the decompiler names it's variables. Specifically for a case of a function call return value that being stored in a stack allocated local variable.
I have a very simple Aarch64 program which malloc's some memory for a struct, stores the returned pointer in a stack allocated pointer var and then proceeds to assign values to the struct members via the pointer.
In the disassembly listing the malloc call's return value goes into register x0 (00100768) and I've got a register write reference at that location, which I've named malloc_ret. Immediately after the returned pointer from malloc is stored in a stack allocated var which I've named struct_ptr_stackvar (00100770). There is both a register read reference for malloc_ret and a memory write reference for struct_ptr_stackvar there.
When I look at the decompiler output it's a completely accurate representation of the high-level logic however I end up with two stack vars, one named for the register reference and the other for the actual stack allocated local variable. And it's the var named after the register reference (i.e. malloc_ret) that is used throughout the rest of the decompiler listing's code.
Could you help me understand why the decompiler ends up with two vars like this ... and opts to use the register reference's name throughout it's listing? Ideally I'd want the decompiler's to use struct_ptr_stackvar throughout it's code to match the disassembly.
See disassembly & decompiler listings below.
Note that I've disabled the option Edit -> Tool Options -> Listing Fields -> Operand Field -> Markup Register Variable References because I'm still wrapping my head around how to use register references effectively. I found the markup of register names more confusing than helpful. If you happen to know of some good docs / tutorials on using register references effectively that would be great too!
This discussion was converted from issue #4359 on March 21, 2023 15:01.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm trying to understand how the decompiler names it's variables. Specifically for a case of a function call return value that being stored in a stack allocated local variable.
I have a very simple Aarch64 program which malloc's some memory for a struct, stores the returned pointer in a stack allocated pointer var and then proceeds to assign values to the struct members via the pointer.
In the disassembly listing the malloc call's return value goes into register x0 (00100768) and I've got a register write reference at that location, which I've named malloc_ret. Immediately after the returned pointer from malloc is stored in a stack allocated var which I've named struct_ptr_stackvar (00100770). There is both a register read reference for malloc_ret and a memory write reference for struct_ptr_stackvar there.
When I look at the decompiler output it's a completely accurate representation of the high-level logic however I end up with two stack vars, one named for the register reference and the other for the actual stack allocated local variable. And it's the var named after the register reference (i.e. malloc_ret) that is used throughout the rest of the decompiler listing's code.
Could you help me understand why the decompiler ends up with two vars like this ... and opts to use the register reference's name throughout it's listing? Ideally I'd want the decompiler's to use struct_ptr_stackvar throughout it's code to match the disassembly.
See disassembly & decompiler listings below.
Note that I've disabled the option Edit -> Tool Options -> Listing Fields -> Operand Field -> Markup Register Variable References because I'm still wrapping my head around how to use register references effectively. I found the markup of register names more confusing than helpful. If you happen to know of some good docs / tutorials on using register references effectively that would be great too!
Thanks in advance for your help!
Disassembly Partial Listing
Decompiler Full Listing - I realize I didn't free() ;)
Beta Was this translation helpful? Give feedback.
All reactions