ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

MAP FILE(GCC)

2021-09-28 11:34:22  阅读:561  来源: 互联网

标签:files MAP GCC file information section program FILE memory


文章转载自:MAP File_weixin_30632899的博客-CSDN博客

https://warpproject.org/trac/wiki/howto/Linker_scripts_MAP_files

 

Description

  • 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.

标签:files,MAP,GCC,file,information,section,program,FILE,memory
来源: https://www.cnblogs.com/yeshenmeng/p/15347047.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有