0X7FFFFFFFDB58:0X004005BA 0x000000000x00000000 0x00000000 <-----FUNCB stack frame [0x7fffffffdb60, 0x7fffffffdb80], where a=0x1a, where the stack bottom is the return address 4005d
0x7fffffffdb68:0x00000000 0x0000001a 0x00000000 0x00000000 0x4005d8, is the return address of the function Funca, and then upward is gradually a variety of local variables /c1>
0x7fffffffdb78: 0x004005d8 0x00000000 0x00400470 0x00000000
0x7fffffffdb88:0xffffdd90 0x00000019 0x00000000 0x00000000 <-----Funca stack frame, this stack frame [0x7fffffffdb80, 0x7f FFFFFFDBA0], where a=0x19
0x7fffffffdb98: 0x0040060d 0x00000000 0x00000000 0x00000000 <----add stack frame stack frames [0x7fffffffdba0,0x7ffffffdbd0], where a=0x18,b=0x27
0x7fffffffdba8: 0x00000028 0x00000018 0x00000001 0x00000000
0x7fffffffdbb8:0x00000040 0x00000000 0x6562b026 0x00000000
0x7fffffffdbc8: 0x0040069f 0x00000000 0xffffdd60 0X00007FFF
0x7fffffffdbd8:0xf7dee923 0x00000002 0x00000000 0x00000017
0x7fffffffdbe8:0x00000027 0x00000000 0x00000000 0x00000000
0x7fffffffdbf8:0x00000003 0x00000000 0xffffdda8 0x00007fff
0x7fffffffdc08:0x00000000 0x00000000 0x00400750 0x00000000
0x7fffffffdc18:0xf7de7ab0 0x00007fff 0x000000ff 0x00000000
0x7fffffffdc28:0xff000000 0x00000000 0x00000000 0x00000000
0x7fffffffdc38:0x00000000 0x00000000 0x00000000 0x00000000
So that the stack frame of a stack, which starts with the return address of the previous function, and the stack frame displayed in the Stacks
gdb of this function, "stack frame at 0x7fffffffdb80" refers to the base address of the stack frame.
(GDB) Info frame 1Stack frame at 0x7fffffffdb80:rip = 0x4005ba in FUNCB (sleep.c:15); Saved rip = 0x4005d8 called by frame at 0X7FFFFFFFDBA0, caller of frame at 0x7fffffffdb60 source language c. Arglist at 0x 7fffffffdb58, args:a=26 Locals at 0x7fffffffdb58, Previous frame ' s sp was 0x7fffffffdb80 Saved Registers:rip at 0X7FFFFF ffdb78 (GDB) Info frame 2Stack frame at 0x7fffffffdba0:rip = 0x4005d8 in Funca (sleep.c:19); Saved rip = 0x40060d called by frame at 0x7fffffffdbd0, caller of frame at 0x7fffffffdb80 source language c. Arglist at 0x 7fffffffdb78, args:a=25 Locals at 0x7fffffffdb78, Previous frame ' s sp was 0x7fffffffdba0 Saved Registers:rip at 0X7FFFFF Ffdb98 (GDB) Info frame 3Stack frame at 0x7fffffffdbd0:rip = 0x40060d in Add (sleep.c:27); Saved rip = 0x40069f called by frame at 0x7fffffffdcb0, caller of frame at 0x7fffffffdba0 source language c. Arglist at 0x 7fffffffdb98, args:a=24, b=40 Locals at 0x7fffffffdb98, Previous frame ' s sp was 0x7fffffffdbd0 Saved Registers:rip at 0x7fffffffdbc8 (GDB) Info frame 4Stack frame at 0x7fffffffdcb0:rip = 0x40069f in print (sleep.c:35); Saved rip = 0x4006c7 called by frame at 0X7FFFFFFFDCC0, caller of frame at 0x7fffffffdbd0 source language c. Arglist at 0x 7fffffffdbc8, args:i=2 Locals at 0x7fffffffdbc8, Previous frame ' s sp was 0x7fffffffdcb0 Saved Registers:rip at 0X7FFFFFF Fdca8
Take a look at the function funca->funcb the calling procedure of a function
00000000004005A2 <funcb>: 4005a2:48-EC-sub $0X18,%RSP RSP This time the value is determined 4005a6:89 7c 24 0c mov%edi,0xc (%rsp) 4005aa:83 0c addl $0x1,0xc (%RSP) 4005af:8b 0c mov 0xc (%RSP),%eax 4005b3:89 C7 mov%eax,%edi 4005b5:e8 AC FF FF FF CALLQ 400566 <funcc> 4005ba:90 nop 4005bb:48 c4 add $0x18,%rsp 4005bf: C3 retq 00000000004005c0 <funca>: 4005c0:48-EC-sub $0X18,%RSP 40 05c4:89 7c 0c mov%edi,0xc (%RSP) 4005c8:83 (0c) Addl $0x1,0xc (%RSP) 4005CD: 8b 0c mov 0xc (%RSP),%eax 4005d1:89 C7 mov%eax,%edi 4005d3:e8 CA ff FF F F callq 4005a2 <funcb> callq is push ip;rsp++ 4005d8:90 NOP 4005d9:48 c4 18 Add $0x18,%RSP 4005dd:c3 RETQ
What does the information stored in the
dwarf look like?
< 1><0x000000ca> Dw_tag_subprogram dw_at_external Yes (1) Dw_at_name "FUNCB" Dw_at_decl_file 0X00000001/HOME/HON/CODEBOX/GCC /SLEEP.C dw_at_decl_line 0x0000000d dw_at_prototyped Yes ( 1) dw_at_type <0x00000049> dw_at_low_pc 0x 004005A2 dw_at_high_pc <offset-from-lowpc>30 Dw_at_frame_bas E len 0X0001:9C:DW_OP_CALL_FRAME_CFA dw_at_gnu_all_tail_call_sitesyes (1) Dw_at_sibling <0x000000f8>< 2><0x000000eb> Dw_tag_formal_parameter Dw_at_name "a" dw_at_decl_file 0x00000001/home/hon/codebox /gcc/sleep.c Dw_at_decl_line 0x0000000d Dw_at_type <0x00000049> Dw_at_location Len 0x0002:916c:dw_op_fbreg-20
What does the information in the
funca look like?
< 1><0x000000f8> Dw_tag_subprogram dw_at_external Yes (1) Dw_at_name "Funca" Dw_at_decl_file 0X00000001/HOME/HON/CODEBOX/GCC /SLEEP.C dw_at_decl_line 0x00000011 dw_at_prototyped Yes ( 1) dw_at_type <0x00000049> dw_at_low_pc 0x 004005C0 dw_at_high_pc <offset-from-lowpc>30 Dw_at_frame_bas E len 0X0001:9C:DW_OP_CALL_FRAME_CFA dw_at_gnu_all_tail_call_sitesyes (1) Dw_at_sibling <0x00000126>< 2><0x00000119> Dw_tag_formal_parameter Dw_at_name "a" dw_at_decl_file 0x00000001/home/hon/codebox /gcc/sleep.c Dw_at_decl_line 0x00000011 Dw_at_type <0x00000049> Dw_at_location Len 0x0002:916c:dw_op_fbreg-20
When using GDB to view the stack frame, there is no EBP