I have a static library archive which I try to understand.
First I use 'ar' to extract the object files.
The object files ar "ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped"
Then I use 'objdump -D' to get the assembly instructions.
Now I'm observing the assembly listing and find some curious (to me) instructions.
Apparently, after a branch with link (bl), R0 is moved into R3, and the next instruction moves R3 to R0.
23c: e1a00003 mov r0, r3
240: ebfffffe bl 0 <atoi>
244: e1a03000 mov r3, r0
248: e1a00003 mov r0, r3
This happens multiple times in different object files within the archive.
In the end both R0 and R3 are set to the value of R0 when returning from the branch.
What could be a good explanation for this behaviour?
r0
to contain the data to process, and it returns its result inr0
as well. The compiler doesn't know (or doesn't care), so it sets up the call, calls the library function, then restores the registers to resume what it was doing. It's just some not optimized stuff.