More Related Content Similar to Hello world在那邊?背景說明 (20) Hello world在那邊?背景說明9. 仔細看看男人
$ man man
The table below shows the section numbers of
the manual followed by the types of pages they
contain.
1 Executable programs or shell
commands
2 System calls (functions provided by the
kernel)
...
18. 回到ABI
● Application Binary Interface的縮寫
● 規範binary,也就是你的執行程式和函式庫
○ 呼叫函數行為
■ 機械碼執行的時候哪些暫存器放參數,哪些暫存器
放回傳值...
○ Data type alignment
○ System call呼叫規範
○ ...
● 理想的世界
○ 同樣的硬體條件和同樣的ABI,不同compiler編出來的
binary甚至在不同OS都可以互通
○ 現實上...嘛。看起來太多細節需要處理,所以看運氣。
21. demo會用到的objdump指令
● objdump -d objfile
○ 反組譯binary檔案
● objdump -t objfile
○ 列出binary檔案的symbol table
■ 不知道symbol table?問估狗囉
● objdump -h objfile
○ 列出binary的section資訊
■ 不知道section,請找我以前linker script的投影片或
文章
● objdump -s -j section名稱 objfile
○ 列出section的內容 資料
22. 補充無關的資料
● function prolog
○ 函數被呼叫的時候,實際上機械碼準備的事
■ 儲存相關status
■ 處理和設定call stack
■ 處理要用的暫存器
● function epilogue
○ 離開函數的時候,實際上機械碼準備的事
■ 恢復和設定call stack
■ 恢復用過的暫存器
■ 恢復前面儲存的status