So, say that I have the following code, which gives three examples of what I believe to be unnecessary copies of values.
mov QWORD PTR [rbp-0x18],rdi mov rdx,QWORD PTR [rbp-0x18] lea rax,[rbp-0x10] mov rsi,rdx mov rdi,rax call 4003e0 <strcpy@plt>
Why is the value in
rdi copied to memory at
rbp-0x18, then copied back to
rdx ? It's then copied to
rsi (2 extra copies).
Finally, why the
lea + mov for
rax, then to
rdi ? Is there any reason the following code wasn't generated ?
mov rsi,rdi lea rdi,[rbp-0x10] call 4003e0 <strcpy@plt>
(My guess is that this is just an artifact of the code generation in the compiler, but I'm making sure there's not some rules of x86-64 that I'm missing.)