C++ gcc - 如何创建目标文件的映射文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38961649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gcc - how to create a mapfile of the object file
提问by Bob
I have a .map
file called a.out.map
that was created from a .cpp
/.obj
file but I don't remember how. I've included a snippet:
我有一个从/文件创建的.map
名为的文件,但我不记得是如何创建的。我已经包含了一个片段:a.out.map
.cpp
.obj
.plt 0x0000380c 0x848
*(.plt)
.plt 0x0000380c 0x848 C:/QNX650/target/qnx6/armle-v7/lib/crti.o
.text 0x00004054 0x5448
0x00004054 _btext = .
*(.text .stub .text.* .gnu.linkonce.t.*)
.text 0x00004054 0x0 C:/QNX650/target/qnx6/armle-v7/lib/crti.o
.text 0x00004054 0xf4 C:/QNX650/host/win32/x86/usr/lib/gcc/arm-unknown-nto-qnx6.5.0eabi/4.4.2/pic//crtbegin.o
.text 0x00004148 0x1b3c C:\TempqccTulUdb\eventlookupmodel.o
0x00004b80 AL2HMIBridge::EventLookupModel::data(QModelIndex const&, int) const
0x000054f8 AL2HMIBridge::EventLookupModel::rowCount(QModelIndex const&) const
0x000046a8 AL2HMIBridge::EventLookupModel::getNameFromId(unsigned int, unsigned int)
0x00004148 AL2HMIBridge::EventLookupModel::EventLookupModel(AL2HMIBridge::CsvImporter&, QObject*)
0x00004738 AL2HMIBridge::EventLookupModel::getElementFromId(unsigned int, unsigned int)
0x00004ab4 AL2HMIBridge::EventLookupModel::getElementFromName(QString const&)
0x00005548 AL2HMIBridge::EventLookupModel::appendElement(AL2HMIBridge::EventLookupModel::EventElement const&)
0x00005804 AL2HMIBridge::EventLookupModel::appendElement(QString const&, unsigned int, unsigned int, QList<
What's the gcc command to produce the .map
file?
生成.map
文件的 gcc 命令是什么?
回答by lostbard
If you are linking the program and want to generate map output add:
如果您正在链接程序并希望生成地图输出,请添加:
-Xlinker -Map=output.map
to the gcc command in order to make it create the map file output.map
到 gcc 命令以使其创建映射文件 output.map
If you want to see the symbols and relocation of an object file, you can use the objdump tool:
如果要查看目标文件的符号和重定位,可以使用 objdump 工具:
objdump -x an_object_file.o