最近在用 debug 有關 GCC 編出來的程式,以往用微軟的編譯器時可以用 /Fa$* /FAsc 來產生 cod 檔,很好追原因。

換成 GCC 之後突然發現需要這個功能啊啊啊啊啊…

拜神之後發現 GCC 也是有這個功能,但是是透過 GCC 把參數送給 ar,所以應該查 ar 的 man page 才對,難怪 GCC 手冊看了老半天看不出所以然。

以下是直接抄來的:

gcc test.c -o test -Wa,-adhln=test.s -g -fverbose-asm -masm=intel
-a[sub-option...]    turn on listings
                             Sub-options [default hls]:
                             c      omit false conditionals
                             d      omit debugging directives
                             g      include general info
                             h      include high-level source
                             l      include assembly
                             m      include macro expansions
                             n      omit forms processing
                             s      include symbols
                             =FILE  list to FILE (must be last sub-option)

 

參考網頁:Coding Tricks 101: How to Save the Assembler Code Generated by GCC

arrow
arrow
    全站熱搜

    zxlin 發表在 痞客邦 留言(0) 人氣()