什么是gcc链接器映射文件用于? [英] What are gcc linker map files used for?

查看:153
本文介绍了什么是gcc链接器映射文件用于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是由gcc / g ++连接器选项-Map生成的.map文件?
以及如何阅读它们?

What are the ".map" files generated by gcc/g++ linker option "-Map" used for ? And how to read them ?

推荐答案

我建议您生成一个地图文件,投入生产。

I recommend generating a map file and keeping a copy for any software you put into production.

它可以用于破译崩溃报告。根据系统的不同,您可能会从崩溃中获取堆栈转储。堆栈转储将包含内存地址,其中一个寄存器将包含指令指针。这告诉你内存地址代码正在执行。在某些系统上,代码地址可以移动(加载动态库时,因此是动态的),但低位字节应该保持不变。

It can be useful for deciphering crash reports. Depending on the system, you likely can get a stack dump from the crash. The stack dump will include memory addresses and one of the registers will include the Instruction Pointer. That tells you the memory address code was executing at. On some systems, code addresses can be moved around (when loading dynamic libraries, hence, dynamic), but the lower order bytes should remain the same.

映射文件是来自内存位置的MAP - >代码位置。它给你一个给定内存地址的函数名称。由于优化,它可能不是非常准确,但它可以让你从寻找导致崩溃的错误开始。

The map file is a MAP from memory location -> code location. It gives you the name of the function at a given memory address. Due to optimizations, it may not be extremely accurate, but it gives you a place to start in terms of looking for bugs that cause the crash.

现在,在30年编写商业软件,这是我使用地图文件的唯一方法。两次成功。

Now, in 30 years of writing commercial software, this is the only thing I've used the map files for. Twice successfully.

这篇关于什么是gcc链接器映射文件用于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆