SlideShare a Scribd company logo
1 of 18
Download to read offline
Wen Liao
GNU AS 簡介
台南市,虎尾寮
Disclaimer
投影片資料為作者整理資料及個人意見,沒有經
過嚴謹確認,請讀者自行斟酌
目標
介紹GNU AS以及binutils的用法
測試環境:Guest OS
測試環境:Qemu
關於GNU AS
● 簡稱gas,或是直接as
● 組合語言是也
○ 把組合語言轉成binary的object file
gas原始碼組成
● Symbol
○ label也是一個symbol
● directive
○ .開頭的字
○ 有些通用,有些和CPU平台相關
● Expression
● Instruction
○ 最後會轉成機械碼的東西
今天不會提到的
● 巨集
● 條件式directive
● 除錯相關directive
● 硬體架構相關
還記得linker script嘛?
● Sections
○ .text
○ .bss
○ .data
○ .rodata
○ …
● 進入點
● 這些全部要自行處理
還記得ABI嘛?
● 一樣要自己處理
○ Call convention
○ Frame pointer
○ Call stack
在組合語言中一切自己來
● printf?沒這東西
● 開檔案?寫東西,請愛用system call
兩光的Hello World
directives
兩光的Hello World
section
兩光的Hello World
symbol
兩光的Hello World
system
call
r0 = write(1, hello_str, hello_len)
exit(r0)
兩光的Hello World
expression
上面是爛程式碼示範
● 好的程式碼示範 ( 感謝Scott Tasi大大)
回家作業:九九乘法表
● 檔案結構
○ Makefile
○ main.S
○ multi_table.S
● 執行
● nm 觀察
● objdump 反組譯比對。看Symbol
● gdb
○ Hint
■ --gstabs+ 參數

More Related Content

Viewers also liked

GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介Wen Liao
 
Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Wen Liao
 
Testing in python 2.7.3
Testing in python 2.7.3Testing in python 2.7.3
Testing in python 2.7.3Wen Liao
 
GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例Wen Liao
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard StallmanWen Liao
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryWen Liao
 
開放街圖 自助旅行的好幫手
開放街圖   自助旅行的好幫手開放街圖   自助旅行的好幫手
開放街圖 自助旅行的好幫手Wen Liao
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)William Lee
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataAlket Cecaj
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcationNir Cohen
 
Git flow for daily use
Git flow for daily useGit flow for daily use
Git flow for daily useMediacurrent
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationWilliam Lee
 
從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理Wen Liao
 
Git Workflow With Gitflow
Git Workflow With GitflowGit Workflow With Gitflow
Git Workflow With GitflowJosh Dvir
 
軟體組裝心得分享
軟體組裝心得分享軟體組裝心得分享
軟體組裝心得分享Wen Liao
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web PageWilliam Lee
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 

Viewers also liked (20)

GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10
 
Testing in python 2.7.3
Testing in python 2.7.3Testing in python 2.7.3
Testing in python 2.7.3
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
 
開放街圖 自助旅行的好幫手
開放街圖   自助旅行的好幫手開放街圖   自助旅行的好幫手
開放街圖 自助旅行的好幫手
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk Data
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcation
 
Git flow for daily use
Git flow for daily useGit flow for daily use
Git flow for daily use
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log Rotation
 
從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理
 
Git Workflow With Gitflow
Git Workflow With GitflowGit Workflow With Gitflow
Git Workflow With Gitflow
 
20140409
2014040920140409
20140409
 
軟體組裝心得分享
軟體組裝心得分享軟體組裝心得分享
軟體組裝心得分享
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web Page
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 

GNU AS簡介