系列文章目录
提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加
例如:第一章 Python 机器学习入门之pandas的使用
提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
提示:这里可以添加本文要记录的大概内容:
I’m trying to learn advanced embedded software debugging techniques, and I can see one good way to do this is to be able to read ELF, MAP and HEX files. Are there any good tutorials for this? What other good advanced debugging techniques have really helped you? Thanks
提示:以下是本篇文章正文内容,下面案例可供参考
The only one intended for “human consumption” is the .map file, which lets you see the address assigned to each symbol (function, global variable) etc in your code. It also gives the size of each function, which can be useful when optimizing for space. You can directly read a .map file with any text editor / viewer and they are quite simple to understand
The other file types aren’t intended to be directly read by humans but as input to other tools.
.hex files basically consist of a set of address/data blocks and say “this data goes here, that data goes there” the data just being hex values with no context. They are textual so you can read them at a pinch but that’s not very useful.
They are normally used as input to various flashing / update tools and are generated as one of the final steps of the build process. Because they contain the destination addresses they are standalone and can be used to program a device without prior knowledge of the load address and can also be used where there are several non contiguous chunks of data, unlike .bin files which are straight binary dumps from an assumed start address.
.elf files are the result of the compile and link phase and contain lots of information, such as code, data, load addresses, debug information. They are complex structured binary formats. Understanding the format itself is not very important unless you are writing tools to consume on generate them (and there are libraries that can help with that) but it is useful to know the tools that can be used eith them and the type of information inside.
A .bin or .hex file can be generated from an .elf file as can more elaborate programming formats like .dfu
.elf files are are, of course, used by debuggers but simpler tools like addr2line use them too (this tool finds the function / line number corresponding to an address, which can be useful if you have a crash dump from the field when no debugger was in use)
objdump and readelf are good tools for exploring .elf files.
参考:
原文链接