I've just been working through some Ghidra examples, the input files being ELF. Immediately after analysis I see this:
main XREF[4]: Entry Point(*),
_start:0010059d(*), 001008f4,
001009a0(*)
0010068a 55 PUSH RBP
0010068b 48 89 e5 MOV RBP,RSP
0010068e 48 83 ec 20 SUB RSP,0x20
00100692 89 7d ec MOV dword ptr [RBP + local_1c],EDI
00100695 48 89 75 e0 MOV qword ptr [RBP + local_28],RSI
00100699 83 7d ec 03 CMP dword ptr [RBP + local_1c],0x3
0010069d 74 16 JZ LAB_001006b5
0010069f 48 8d 3d LEA RDI,[s_Please_provide_two_values_to_gen_001007 = "Please provide two values to
42 01 00 00
001006a6 e8 a5 fe CALL ::puts int puts(char * __s)
as the start of the assembler code and this
undefined8 main(int param_1,long param_2)
{
int iVar1;
int iVar2;
undefined8 uVar3;
as the main() function definition.
If I use "Edit Function Signature" to change the type of the second parameter to look like this
undefined8 main(int param_1,char **param_2)
{
int iVar1;
int iVar2;
undefined8 uVar3;
all instances of RSI and RDI in the assembler listing get changed to param_1 and param_2, e.g.
main XREF[4]: Entry Point(*),
_start:0010059d(*), 001008f4,
001009a0(*)
0010068a 55 PUSH RBP
0010068b 48 89 e5 MOV RBP,RSP
0010068e 48 83 ec 20 SUB RSP,0x20
00100692 89 7d ec MOV dword ptr [RBP + local_1c],param_1
00100695 48 89 75 e0 MOV qword ptr [RBP + local_28],param_2
00100699 83 7d ec 03 CMP dword ptr [RBP + local_1c],0x3
0010069d 74 16 JZ LAB_001006b5
0010069f 48 8d 3d LEA param_1,[s_Please_provide_two_values_to_gen_00 = "Please provide two values to
42 01 00 00
001006a6 e8 a5 fe CALL ::puts int puts(char * __s)
noting the instruction at 0010069f.
At present it appears that there is absolutely no concept of a scope (or, loosely, namespace) applied to register aliases.
Is this expected behaviour? Is there a workaround?
I believe this is related to Why does it seem as though the compiler is repurposing Argc and Argv in my function?, although in that case the names were allocated wrong and didn't need user intervention.
Ghidra is currently 11.2.1, running as a Snap package on Debian 12.