• 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. [转]CentOS7利用systemctl添加自定义系统服务

    原文:https://www.cnblogs.com/saneri/p/7778756.html CentOS7自定义系统服务 CentOS7的服务systemctl脚本存放在:/usr/lib/sy ...

  2. google Kickstart Round F 2017 四道题题解

    Problem A. Kicksort 题意抽象一下为: 对于一个每次都从数列正中间取划分数的快速排序,给定一个1-n的排列,问快排的复杂度对于这个排列是否会退化为最坏复杂度. 数据范围: 测试组数1 ...

  3. 在word中批量更改Mathtype公式的格式

    方法参照下面这个链接 还有这个方法

  4. Unity攻略

    Unity开发VR之Vuforia 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  5. s21day21 python笔记

    s21day21 python笔记 一.内容回顾及补充 内置函数补充 type():查看数据类型 class Foo: pass obj = Foo() if type(obj) == Foo: pr ...

  6. Redis须知重点

    一.为什么使用 Redis? 我觉得在项目中使用 Redis,主要是从两个角度去考虑:性能和并发. 当然,Redis 还具备可以做分布式锁等其他功能,但是如果只是为了分布式锁这些其他功能,完全还有其他 ...

  7. 64位ubuntu16.04系统安装tensorflow_cpu

    ubuntu16.04安装tensorflow_cpu 一.安装anaconda: ①.下载anaconda包:Anaconda3-5.2.0-Linux-x86_64.sh 这是python3.6. ...

  8. cocos creator 刚体卡顿问题(边界会卡住)

    **问题描述:**在项目开发中,使用到了刚体, 在搭建地图过程中,发现两个相邻的砖块,即使贴合的再紧密,但星星人在上面走动的时候还是会有很大概率发生卡顿(被两个刚体的边界处卡住).为了解决这个问题,我 ...

  9. 我的代码-flask

    import pickleimport flaskimport pandas as pdimport jsonfrom flask import Flaskfrom flask import requ ...

  10. Javascript 4.3 事件处理函数

    鼠标指针悬停在某个元素上时触发一个动作:onmouseover事件处理函数 鼠标指针离开某个元素时触发一个动作:onmouseout事件处理函数 点击某个链接时触发一个动作:onclick事件处理函数 ...