1

I am using CentOS 6.02 64 bit. I want to see the information and used compiler flags in .o files. Is there any command or way to see that? I have seen the architecture of .a file by using objdump. But couldn't seen the information for .o files.

4

1 回答 1

0

没有从目标文件中提取编译器标志的通用方法。您可以通过使用和不使用诸如 -fverbose-asm (仅影响 asm 生成的 gcc 标志)之类的无操作开关进行两次编译并比较对象来看到这一点 - 它们将是相同的。然而,有一些编译器特定的扩展允许您在编译期间插入它们,例如-frecord-gcc-switches在较新版本的 gcc 中,它将使用的标志放在 section 中.GCC.command.line。不同的编译器还向 .comment 部分插入了各种信息,例如我使用 gcc 4.7.2 进行的编译显示:

$objdump -s -j.comment <objfile>

objfile:     file format elf64-x86-64

Contents of section .comment:
 0000 00474343 3a202847 4e552920 342e372e  .GCC: (GNU) 4.7.
 0010 3200                                 2.

当然,您可以使用与 .a 文件相同的方式获取体系结构,使用objdump -f.

于 2013-02-14T07:59:01.190 回答