Linux內核分析.:反編譯簡單c程序


作者:xujianguo 原創作品轉載請注明出處
《Linux內核分析》MOOC課程http://mooc.study.163.com/course/USTC-1000029000


 

c程序部分代碼如下:

int g(int x)

{

  return x + 5;

}

int f(int x)

{

  return g(x);

}

int main(void)

{

  return f(9) + 1;

}

實驗分析如下:

 

 實驗樓沒法用,晚點分析,抱歉@!

 

.file

   "main.c"
.text
.globl g
.type g, @function
g:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
movl 8(%ebp), %eax
addl $5, %eax
popl %ebp
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE0:
.size g, .-g
.globl f
.type f, @function
f:
.LFB1:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $4, %esp
movl 8(%ebp), %eax
movl %eax, (%esp)
call g
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE1:
.size f, .-f
.globl main
.type main, @function
main:
.LFB2:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $4, %esp
movl $9, (%esp)
call f
addl $1, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE2:
.size main, .-main
.ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
.section .note.GNU-stack,"",@progbits

 

 

課程總結:

    計算機是由軟件和硬件組成, 計算機硬件是由CPU、輸入輸出設備、存儲設備等組成,軟件分為系統軟件和應用軟件。系統軟件是計算機系統的骨架,而應用軟件是它的枝葉。計算機通過執行指令完成基本工作.計算機能夠識別機器語言和匯編語言,機器語言類似1和0組合起來的數據流,而匯編語言更加接近底層。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM