KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to understand the assembly level code for a simple C program by inspecting it with gdb's disassembler. Following is the C code: #include <stdio.h> void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; } void main() { function(1,2,3); } Following is the disassembly code for both main and function gdb) disass main Dump of assembler code for function main: 0x08048428 <main+0>: push %ebp 0x08048429 <main+1>: mov %esp,%ebp 0x0804842b <main+3>: and $0xfffffff0,%esp 0x0804842e <main+6>: sub $0x10,%esp 0x08048431 <main+9>: movl $0x3,0x8(%esp) 0x08048439 <main+17>: movl $0x2,0x4(%esp) 0x08048441 <main+25>: movl $0x1,(%esp) 0x08048448 <main+32>: call 0x8048404 <function> 0x0804844d <main+37>: leave 0x0804844e <main+38>: ret End of assembler dump. (gdb) disass function Dump of assembler code for function function: 0x08048404 <function+0>: push %ebp 0x08048405 <function+1>: mov %esp,%ebp 0x08048407 <function+3>: sub $0x28,%esp 0x0804840a <function+6>: mov %gs:0x14,%eax 0x08048410 <function+12>: mov %eax,-0xc(%ebp) 0x08048413 <function+15>: xor %eax,%eax 0x08048415 <function+17>: mov -0xc(%ebp),%eax 0x08048418 <function+20>: xor %gs:0x14,%eax 0x0804841f <function+27>: je 0x8048426 <function+34> 0x08048421 <function+29>: call 0x8048340 <__stack_chk_fail@plt> 0x08048426 <function+34>: leave 0x08048427 <function+35>: ret End of assembler dump. I am seeking answers for following things : how the addressing is working , I mean (main+0) , (main+1), (main+3) In the main, why is $0xfffffff0,%esp being used In the function, why is %gs:0x14,%eax , %eax,
Tags (comma-separated)
Save Edits
Cancel