• A MAP file is an output of the Linker.
  • gives information about the symbols, addresses, allocated memory in the generated ELF file.
  • It is extremely useful when trying to understand and debug linker issues related to code size.
 
Structure
  • Archive member included to satisfy reference by file (symbol)
  • Allocating common symbols
  • Memory Configuration
  • Linker script and memory map
  • Cross Reference Table
 
Archive files
  • An archive file is a file that is composed of one or more computer files along with metadata.
  • Archive files are used to collect multiple data files together into a single file for easier portability and storage, or simply to compress files to use less storage space.
  • Archive files often store directory structureserror detection and correction information, arbitrary comments, and sometimes use built-in encryption.
  • This section details all of the members included from the various archive files in the system. This information is not especially useful, but lets you see all the system functions.
 
Allocating common symbols
  • This section shows the names and sizes of global symbols (ie global variables) that have been allocated in the program.
  • This is a good place to check that all global variables have expected sizes.
  • A common mistake can be to unknowingly allocate a large global variable that consumes a lot of memory space.
Memory Configuration 
  • The next section show the memory configuration.
  • This should be the same as in the Linker Command File.
 
Linker script and memory map
  • START GROUP & ENDGROUP

    • --start-group archives --end-group
    • The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line.
    • If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference.
    • By grouping the archives, they all be searched repeatedly until all possible references are resolved.
    • Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.
  • Gives a wealth of information about where everything is mapped in the program.
  • Each top level section, such as .text or .heap has both the starting address in the memory map as well as the size (in bytes) listed.
  • Then each section is broken down into the individual object files and both the starting address and size is listed.
  • Finally, each object file is broken down into the individual functions within the object file and the starting address for each function is listed.
  • This allows you to understand which object files might contain large functions which are not necessary for your program execution.
  • It can also give context when looking at pointer addresses within the program.
  • MAP files are a great source of information when debugging your program.
  • NOTE:

    • .text This section contains only executable instructions.
    • .sdata This section holds initialized short data that contribute to the program memory image.
    • .sbss This section holds uninitialized short data that contribute to the program memory image. By definition, the system initializes the data with zeros when the program begins to run.
    • .lit4 This section holds 4 byte read-only literals that contribute to the program memory image. Its purpose is to provide a list of unique 4-byte literals used by a program. Although this section has the SHF_WRITE attribute, it is not expected to be written. Placing this section in the data segment mandates the SHF_WRITE attribute.
    • .lit8 This section holds 8 byte read-only literals that contribute to the program memory image. Its purpose is to provide a list of unique 8-byte literals used by a program. Although this section has the SHF_WRITE attribute, it is not expected to be written. Placing this section in the data segment mandates the SHF_WRITE attribute.
    • .reginfo This section provides information on the program register usage to the system.
    • .liblist This section contains information on each of the libraries used at static link.
    • .conflict This section provides additional dynamic linking information about symbols in an executable file that conflict with symbols defined in the dynamic shared libraries with which the file is linked.
    • .gptab This section contains a global pointer table. The global pointer table is described in "Global Data Area" in this chapter. The section is named .gptab.sbss,.gptab.sdata, gptab.bss,or .gptab.data depending on which data section the particular .gptab refers.
    • .ucode This section name is reserved and the contents of this type of section are unspecified. The section contents can be ignored
    • .comment This section holds version control information.
    • .debug This section holds information for symbolic debugging. The contents are unspecified. All section names with the prefix .debug are reserved for future use.
  • Function

    • LOADADDR(section)

      • Return the absolute LMA of the named section. This is normally the same as ADDR, but it may be different if the AT attribute is used in the output section definition
    • ASSERT(exp, message)
      • Ensure that exp is non-zero. If it is zero, then exit the linker with an error
      • code, and print message.
Cross Reference Table
  • The format of the table is intentionally simple, so that it may be easily processed by a script if necessary.
  • The symbols are printed out, sorted by name. For each symbol, a list of file names is given. If the symbol is defined, the first file listed is the location of the definition. The remaining files contain references to the symbol.
  • all symbol in this table, seems no use for us.

MAP File的更多相关文章

  1. 对Link Map File的初步认识

    什么是Link Map File Link Map File中文直译为链接映射文件,它是在Xcode生成可执行文件的同时生成的链接信息文件,用于描述可执行文件的构造部分,包括了代码段和数据段的分布情况 ...

  2. make&&gcc/g++ 生成 map file

    map file 对于嵌入式开发是非常有用的,尤其是当你开发的module引起了 kernel panic 的时候. 仅写作Mark用 make: $vim makefile (add  " ...

  3. DNS map file in windows

    Edit "C:\WINDOWS\system32\drivers\etc\hosts", add the IP to DNS name mapping.

  4. auto make System.map to C header file

    #!/bin/bash # auto make System.map to C header file # 说明: # 该脚本主要是将Linux内核生成的System.map文件中的符号.地址存入结构 ...

  5. Python解析器源码加密系列之(二):一次使用标准c的FILE*访问内存块的尝试

    摘要:由于近期打算修改Python解释器以实现pyc文件的加密/解密,出于保密的要求,解密之后的数据只能放在内存中,不能写入到文件中.但是后续的解析pyc文件的代码又只能接受FILE*作为入参,所以就 ...

  6. JAVA实现File类中的遍历操作并输出内容

    package shb.java.testIo; import java.io.BufferedReader; import java.io.BufferedWriter; import java.i ...

  7. Delphi通过Map文件查找内存地址出错代码所在行

    一 什么是MAP文件 什么是 MAP 文件?简单地讲, MAP 文件是程序的全局符号.源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方.任何时候使用,不需要有额外的程序进行支持.而且,这是唯 ...

  8. VS2005(vs2008,vs2010)使用map文件查找程序崩溃原因

    VS 2005使用map文件查找程序崩溃原因 一般程序崩溃可以通过debug,找到程序在那一行代码崩溃了,最近编一个多线程的程序,都不知道在那发生错误,多线程并发,又不好单行调试,终于找到一个比较好的 ...

  9. 问题-[Delphi]通过Map文件查找内存地址出错代码所在行

     一 什么是MAP文件       什么是 MAP 文件?简单地讲, MAP 文件是程序的全局符号.源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方.任何时候使用,不需要有额外的程序进行支持 ...

随机推荐

  1. 从零开始写自己的PHP框架系列教程(二)[App.php]

    从这一个文件开始以后加载的均以类加载,请注意命名空间和所在文件的路径 APP.php的这个类所在路径:根目录\framework\App.php 直接上代码 namespace framework; ...

  2. H5中用postMessage传递数据,解决localStorage不能跨域问题

    localStorage不能跨域,所以在A域名下用localStorage.YourKey方式存储的值,在B域名下是不能取到的. 所以需要转变思路,目前主要使用的两种方式: 一种方式:在A.B两个页面 ...

  3. mybatis 源码分析二

    1.SqlSession下的四大对象 Executor.StatementHandler.ParameterHandler.ResultSetHandler StatementHandler的作用是使 ...

  4. cocoa-charts 导入其依赖库TABlib 报UIKit Foundation找不到的问题

    对于应用到项目中的一些第三方类库,尤其是C/C++ 写的,里面的大部分类文件的后缀都是 .C. 解决办法: 在 build setting 里按照如图所示,进行设置: 这说明以后只要是第三方类库中使用 ...

  5. 学习笔记:spark Streaming的入门

    spark Streaming的入门 1.概述 spark streaming 是spark core api的一个扩展,可实现实时数据的可扩展,高吞吐量,容错流处理. 从上图可以看出,数据可以有很多 ...

  6. 不使用循环或递归判断一个数是否为3的幂(leetcode 326)

    326. Power of ThreeGiven an integer, write a function to determine if it is a power of three. Follow ...

  7. CSS学习笔记_day2

    目录 一. css初识 二. 在HTML里面引入css的几种方式 1. 外部引入式 2.文档内嵌式 3. 行内式(元素内嵌式) 三. 选择器 四.盒模型 五.文档标准流 六.浮动 一. css初识 1 ...

  8. Java基于opencv—矫正图像

    更多的时候,我们得到的图像不可能是正的,多少都会有一定的倾斜,就比如下面的 我们要做的就是把它们变成下面这样的 我们采用的是寻找轮廓的思路,来矫正图片:只要有明显的轮廓都可以采用这种思路 具体思路: ...

  9. less--入门

    Less(Learner Style Sheets)是向后兼容css扩展语言. 变量(Variables) @width: 10px; @height: @width + 10px; header{ ...

  10. Vue双向数据绑定原理

    https://www.cnblogs.com/kidney/p/6052935.html?utm_source=gold_browser_extension