gcc - how to create a mapfile of the object file
Asked Answered
A

1

19

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:

.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:\Temp\2qccTulUdb\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?

Assonance answered 15/8, 2016 at 19:24 Comment(0)
C
44

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

If you want to see the symbols and relocation of an object file, you can use the objdump tool:

objdump -x an_object_file.o
Computer answered 15/8, 2016 at 19:29 Comment(9)
The linker is not running: .cpp -> compiler -> .obj, .map fileAssonance
The example you provided looks like it is the result of the linker, not just compiling to a ,o fileComputer
An object file has to have a memory map too, right?Assonance
You could try objdump : objdump -x test.oComputer
It has a symbol table and a relocation table - many of the symbols will be unresolved until linked.Computer
It still has some initial mapping. There one byte in my .obj that I need to know what it is.Assonance
objdump is probally the tool to use thenComputer
You're right it's objdump. Modify your answer to reflect this and I'll accept it.Assonance
Is there any way to generate map file without specifying name (output.map) of it i.e. automatic name assignment?Colvin

© 2022 - 2024 — McMap. All rights reserved.