Mon*_*nku 10 linker gcc g++ linker-flags
gcc/g ++链接器选项"-Map"用于生成什么".map"文件?以及如何阅读它们?
Gar*_*rey 11
我建议生成一个地图文件并保留您投入生产的任何软件的副本.
它可用于解密崩溃报告.根据系统的不同,您可能会从崩溃中获得堆栈转储.堆栈转储将包括存储器地址,其中一个寄存器将包括指令指针.这告诉你内存地址代码正在执行.在某些系统上,代码地址可以移动(当加载动态库时,因此,动态),但低阶字节应保持不变.
映射文件是来自内存位置的MAP - >代码位置.它为您提供给定内存地址处的函数名称.由于优化,它可能不是非常准确,但它为您提供了寻找导致崩溃的错误的起点.
现在,在编写商业软件的30年中,这是我唯一使用地图文件的东西.两次成功.
gcc/g ++链接器选项"-Map"用于生成什么".map"文件?
没有'gcc linker'这样的东西 - GCC和链接器是独立的和独立的项目.
通常,地图用于理解ld链接二进制文件时所做的决策.来自man ld:
-M
--print-map
Print a link map to the standard output.
A link map provides information about the link, including the following:
· Where object files are mapped into memory.
· How common symbols are allocated.
· All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in.
· The values assigned to symbols.
...
Run Code Online (Sandbox Code Playgroud)
如果你不明白这意味着什么,你可能还没有(还)有这个输出答案的问题,因此没有必要阅读它.