• 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. CodeBlocks无法调试的解决方法

    闲话: 万万没想到我也会写这个东西.一开始软件工程课的时候老师要求我们写博客园,一直都是被动地在写博客.刚刚在重温C语言的时候发现的各种各样问题觉得还是写下来比较好,一旦以后自己又忘了呢……(摊手 顺 ...

  2. 【oracle入门】数据库系统范式

    为了规范关系数据模型,关系型数据库系统在设计时必须遵守一定的规则,这种规则成为关系型数据库范式. 1.第一范式1NF 如果字段中的值已经是无法再分割的值,则符合第一范式,即1NF. 2.第二范式2NF ...

  3. SpringJPA主键生成采用自定义ID,自定义ID采用年月日时间格式

    自定义主键生成策略 在entity类上添加注解 @Id @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom ...

  4. @NotNull和@NotEmpty和@NotBlank 区别

    1.@NotNull:不能为null,但可以为empty:用在基本类型上. 2.@NotEmpty:不能为null,而且长度必须大于0:用在集合类上面. 3.@NotBlank:只能作用在String ...

  5. vue-cli搭建项目模拟后台接口数据,webpack-dev-conf.js文件配置

    webpack.dev.conf.js 首先第一步 const express = require('express');const app = express();var appData = req ...

  6. NABCD(团队项目)

    N (Need 需求) 随着时代的进步和手机迅速发展,各种软件充斥这我们的生活,在学校里,我们总为一些各种各样的群所困扰,我们需要一件工具整合信息,让我们的生活更加便利. A (Approach 做法 ...

  7. java的初学感想

    了解了JAVA的来源后,翻阅了一点关于java特性的书籍,众所周知,安全性和可移植性是java得以成功的前提,对此我想发表一点看法. 1.安全性:任何东西的安全性都是相对的,虽然java编译生成的字节 ...

  8. js的组成部分

    ECMAScript js基本语法与标准 DOM Document Object Model文档对象模型 BOM Browser Object Model浏览器对象模型

  9. django模型二

    django模型二 常用模型字段类型 IntegerField   →    int CharField   →   varchar TextField  →    longtext DateFiel ...

  10. Java I/O输入输出流

    IO流的复习总结 ------注:蓝色背景段落是例子:红色背景的字段IO流的功能类. 编码问题 String s = "威力锅ABC";  //utf-8编码中文占用三个字节,英文 ...