I was just reading through a Phrack article which had disassembly in HP-UX. I read that there are two classes of functions which are possible under HP-UX and SPARC; leaf and non-leaf functions. Following is a section of the disassembly I have taken from here.
(gdb) disass leaf
Dump of assembler code for function foo:
0x3280 <leaf>: copy r3,r1
0x3284 <leaf+4>: copy sp,r3
0x3288 <leaf+8>: stw,ma r1,40(sr0,sp)
0x328c <leaf+12>: stw r26,-24(sr0,r3)
0x3290 <leaf+16>: stw r0,8(sr0,r3)
0x3294 <leaf+20>: ldi 1,r19
0x3298 <leaf+24>: stw r19,8(sr0,r3)
0x329c <leaf+28>: ldo 40(r3),sp
0x32a0 <leaf+32>: ldw,mb -40(sr0,sp),r3
0x32a4 <leaf+36>: bv,n r0(rp)
End of assembler dump.
(gdb)
Usually when a function is called, the return address is pushed onto the stack so that the program knows where to return the control to, once the function has finished executing. How does that work in the case of these leaf functions?
I dont have any access of HP-UX/SPARC machines so have no way to try this out by myself(and I dont understand the assembly in this case very well either, because of the same reason).
Could someone explain how control returns to the callee function in this case?