gcc生成含有C信息的汇编


title: gcc生成含有C信息的汇编
tags: gcc
date: 2018-10-24 23:40:19

https://www.cnblogs.com/fengkang1008/p/4652193.html

Gas的在线文档url:http://sourceware.org/binutils/docs-2.20/as/

Gas的命令行参数:http://sourceware.org/binutils/docs-2.20/as/Invoking.html#Invoking

命令如下:

  1. 反汇编o文件

    arm-linux-gcc -g -c  interrupt.c
    arm-linux-objdump -S interrupt.o > ls.s
    
  2. 使用GNU C Assembler的列表功能来完成

gcc -c -g -Wa,-adlhn ee.c >  ee.anno.s

这个命令的说明如下:
-Wa,option :把选项option传递给汇编器.如果option含有逗号,就在逗号处分割成多个选项.也就是Gas,至于Gas的命令参数,可以查看相应的文档,其中-a[cdghlns]参数的作用是打开列表功能。

这种方式可以显示足够的信息,但是命令稍微复杂,参数比较多,不太容易选择。

Gas的命令行参数概要信息摘录如下:

 1:  a: -a[cdghlns] enable listings 
 2:  alternate: --alternate enable alternate macro syntax 
 3:  D: -D for compatibility 
 4:  f: -f to work faster 
 5:  I: -I for .include search path 
 6:  K: -K for difference tables 
 7:  L: -L to retain local symbols 
 8:  listing: --listing-XXX to configure listing output 
 9:  M: -M or --mri to assemble in MRI compatibility mode 
10:  MD: --MD for dependency tracking 
11:  o: -o to name the object file 
12:  R: -R to join data and text sections 
13:  statistics: --statistics to see statistics about assembly 
14:  traditional-format: --traditional-format for compatible output 
15:  v: -v to announce version 
16:  W: -W, --no-warn, --warn, --fatal-warnings to control warnings 
17:  Z: -Z to make object file even after errors 
原文地址:https://www.cnblogs.com/zongzi10010/p/10023617.html