gcc:
-c 編譯後彙編,不連接配接
-S 編譯後停止,不進行彙編
-o 編譯,彙編,連接配接
-g 生成調試資訊
-gstabs
辨別符 main
gdb
break *辨別符 :設定斷點
info register :參看寄存器
run :運作
list :列出函數行
objdump:
一般常用的是
objdump -x 顯示檔案頭資訊
objdump -d 反彙編代碼段代碼
objdump -D 反彙編所有代碼
用法:objdump <選項> <檔案>
顯示來自目标 <檔案> 的資訊。
至少必須給出以下選項之一:
-a, –archive-headers Display archive header information
-f, –file-headers Display the contents of the overall file header
-p, –private-headers Display object format specific file header contents
-P, –private=OPT,OPT… Display object format specific contents
-h, –[section-]headers Display the contents of the section headers
-x, –all-headers Display the contents of all headers 顯示頭資訊
-d, –disassemble Display assembler contents of executable sections 顯示代碼段代碼
-D, –disassemble-all Display assembler contents of all sections 顯示所有段代碼
-S, –source Intermix source code with disassembly
-s, –full-contents Display the full contents of all sections requested
-g, –debugging Display debug information in object file
-e, –debugging-tags Display debug information using ctags style
-G, –stabs Display (in raw form) any STABS info in the file
-W[lLiaprmfFsoRt] or
–dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
=frames-interp,=str,=loc,=Ranges,=pubtypes,
=gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
=addr,=cu_index]
Display DWARF info in the file
-t, –syms Display the contents of the symbol table(s)
-T, –dynamic-syms Display the contents of the dynamic symbol table
-r, –reloc Display the relocation entries in the file
-R, –dynamic-reloc Display the dynamic relocation entries in the file
@ Read options from
-v, –version Display this program’s version number
-i, –info List object formats and architectures supported
-H, –help Display this information
以下選項是可選的:
-b, –target=BFDNAME 将标的目标檔案格式指定為 BFDNAME
-m, –architecture=MACHINE 将标的體系結構指定為 MACHINE
-j, –section=NAME 隻顯示 NAME 節的資訊
-M, –disassembler-options=OPT 将文本傳遞到 OPT 反彙程式設計式
-EB –endian=big 反彙編時假定高位位元組在前
-EL –endian=little 反彙編時假定低位位元組在前
–file-start-context 從檔案的起點引入上下文 (帶有 -S)
-l, –line-numbers 在輸出中給出行号和檔案名
-C, –demangle[=STYLE] 對修飾過的 (mangled) 符号名進行解碼
如果給出了 STYLE,STYLE 可能為“auto”、“gnu”、
“lucid”、“arm”、“hp”、“edg”或“gnu-new-abi”
-w, –wide 以多于 80 列的寬度對輸出進行格式化
-z, –disassemble-zeroes 反彙編時不要跳過為零的塊
–start-address=ADDR 隻有程序資料的位址 >= ADDR
–stop-address=ADDR 隻有程序資料的位址 <= ADDR
–prefix-addresses 同反彙編代碼并列顯示完整的位址
–[no-]show-raw-insn 同符号反彙編并列顯示十六進制值
–adjust-vma=OFFSET 為所有顯示的節位址增加 OFFSET
--dwarf-depth=N Do not display DIEs at depth N or greater
--dwarf-start=N Display DIEs starting with N, at the same depth
or deeper
--dwarf-check Make additional dwarf internal consistency checks.
objdump:支援的目标: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
objdump:支援的體系結構: i386 i386:x86-64 i386:x64-32 i8086 i386:intel i386:x86-64:intel i386:x64-32:intel i386:nacl i386:x86-64:nacl i386:x64-32:nacl iamcu iamcu:intel l1om l1om:intel k1om k1om:intel plugin
下列 i386/x86-64 特定的反彙編器選項在使用 -M 開關時可用(使用逗号分隔多個選項):
x86-64 Disassemble in 64bit mode
i386 Disassemble in 32bit mode
i8086 在 16 位模式下反彙編
att 用 AT&T 文法顯示指令
intel 用 Intel 文法顯示指令
att-mnemonic
Display instruction in AT&T mnemonic
intel-mnemonic
Display instruction in Intel mnemonic
addr64 假定 64 位位址大小
addr32 假定 32 位位址大小
addr16 假定 16 位位址大小
data32 假定 32 位資料大小
data16 假定 16 位資料大小
suffix 在 AT&T 文法中始終顯示指令字尾
amd64 Display instruction in AMD64 ISA
intel64 Display instruction in Intel64 ISA