Understanding Map Files in Keil

Follow+Star Public Account, don’t miss the wonderful content
Understanding Map Files in Keil
Author | strongerHuang
WeChat Official Account | Embedded Column

What is a map file?

In simple terms: a map file is a mapping file that integrates the program, data, and IO space after compilation by the compiler.

Many technically skilled engineers first think of analyzing the map file when encountering memory overflow or out-of-bounds situations. The map file provides important information such as function sizes and entry addresses.
The most common occurrence in Keil is that after compilation, the compilation window displays a message similar to the following regarding the sizes of the program and data:

Program Size: Code=1112 RO-data=320 RW-data=0 ZI-data=1632

This message actually summarizes the information about the program and data, which is compiled from individual modules, and there is a detailed list in the map file.

About the map file in Keil

The map file in Keil software is crucial for analyzing bugs in projects; many memory-related bugs can be shared through the map file.

How to open a map file

The most direct and simplest way: double-click the project target to open the map file (note to double-click the project target, not the project or file group). See the image below:

Understanding Map Files in Keil

Of course, you can find the map file location (in the Listings folder) and open it with an editor tool.

Map file output content configuration

The configuration for the output information of the map file is located at: Project -> Options for Target -> Listing, as shown in the image below:

Understanding Map Files in Keil

Main configurations include:

Memory Map:Memory Mapping

Callgraph:Graph Mapping

Symbols:Symbols

Cross Reference:Cross References

Size Info:Size Information

Totals Info:Total Information

Unused Section Info:Unused Module Information

Veneers Info:Veneer Information

We can select the corresponding information based on our needs.

Note:

A.By default, all information is output;

B.These configurations are a combination relationship;

Classification of map file content

From the above output configuration, we can see what information the map file roughly contains. The map file is divided into the following five categories:

1.Section Cross References:Module and section (entry) cross-references

2.Removing Unused input sections from the image:Removing Unused Modules

3.Image Symbol Table:Mapping Symbol Table

4.Memory Map of the image:Memory (Mapping) Distribution

5.Image component sizes:Storage Composition Sizes

The following sections will elaborate on the five categories of content generated by the map file of Keil MDK and ARM Compiler 5 components in detail.

Descriptions of Each Module

1、Section Cross ReferencesModule and section (entry) cross-references

Configuration needs to check: Cross Reference

Understanding Map Files in Keil

Section Cross References:Module and section (entry) cross-references refer to the relationship of mutual references between the modules and sections generated by various source files.

For example:

main.o(i.System_Initializes) refers to bsp.o(i.BSP_Initializes) for BSP_Initializes

Means:

The System_Initializes function (i.System_Initializes) in the main module (main.o) calls the BSP_Initializes function in the bsp module (bsp.o).

Note:

A.main.o is the target file module generated from the main.c source file;

B.I.System_Initializes is the entry of the System_Initializes function.

2、Removing Unused input sections from the imageRemoving Unused Modules

Configuration needs to check: Unused Sections Info

Understanding Map Files in Keil

This category is easy to understand; it generates a list in the map file of modules (or functions) in our code that are not called.

For example:

Removing stm32f10x_gpio.o(i.GPIO_AFIODeInit), (20 bytes).

Means:

The GPIO_AFIODeInit module (function) in the stm32f10x_gpio.c file is not called and its code size is 20 bytes.

Lastly, there is a statistic:

52 unused section(s) (total 2356 bytes) removed from the image.

1.A total of 52 sections were not called;

2.The total size of the unused sections is 2356 bytes;

3、Image Symbol Table:Mapping Symbol Table

Configuration needs to check: Symbols

Understanding Map Files in Keil

Image Symbol Table:Mapping Symbol Table, which is a table that stores the corresponding addresses of each section (the image has removed part of the content).

Symbols are divided into two main categories

1.Local Symbols:Local

2.Global Symbols:Global

Key Points of Symbol Content

1.Symbol Name:Symbol Name

For naming and classification, please refer to the official reference document provided at the end.

2.Value:Stores the corresponding address

You will find addresses like 0x0800xxxx and 0x2000xxxx.

0x0800xxxx refers to code, variables, etc., stored in FLASH.

0x2000xxxx refers to variables Data, etc., stored in RAM.

3.Ov Type:Type of the symbol

There are several types of symbols: Number, Section, Thumb Code, Data, etc.;

Careful readers will notice that global and static variables are located in the 0x2000xxxx memory RAM.

4.Size:Storage Size

This is easy to understand; it refers to the size occupied by the current row of Symbol.

5.Object(Section):Section Target

This generally refers to the module (source file) in which it is located.

4、Memory Map of the imageMemory (Mapping) Distribution

Configuration needs to check: Memory Map

Understanding Map Files in Keil

Memory Map of the image:Memory (Mapping) Distribution, the content is relatively more and is quite important.

Main Introduction

Image Entry point : 0x08000131:refers to the mapping entry address.

Load Region LR_IROM1 (Base: 0x08000000, Size: 0x00000598, Max: 0x00080000, ABSOLUTE):

Refers to the loading region starting at LR_IROM1 address 0x08000000, size 0x00000598, with a maximum of 0x00080000.

Execution Regions:

A.Execution Region ER_IROM1

B.Execution Region RW_IRAM1

This region corresponds to the regions in our target configuration, as shown below:

Understanding Map Files in Keil

Key Points of Content

1.Base Addr:Storage Address

0x0800xxxx FLASH address and 0x2000xxxx memory RAM address.

2.Size:Storage Size

3.Type:Type

Data: Data Type

Code: Code Type

Zero: Uninitialized Variable Type

PAD: This type is placed in this position in the map file; it cannot be counted as a type here. If translated, it can only be described as “padding type”.

ARM processors are 32-bit; if an 8-bit or 16-bit variable is defined, there will be a remainder; this refers to the “padding” part, and you will find that the other options do not have corresponding values.

4.Attr:Attributes

RO: Stored in ROM segments

RW: Stored in RAM segments

5.Section Name:Section Name

This can also be referred to as entry classification name, similar to the modules and sections referred to in the first chapter “Section Cross References”.

It generally includes: RESET, .ARM, .text, i, .data, .bss, HEAP, STACK, etc.

6.Object:Target

5、Image component sizesStorage Composition Sizes

Configuration needs to check: Size Info

Understanding Map Files in Keil

Image component sizes:Storage Composition Sizes, mainly summarizes the storage size information of the modules.

This chapter’s content is believed to be understandable; after compiling the project, we generally see a message similar to the following in the compilation window:

Program Size: Code=1112 RO-data=320 RW-data=0 ZI-data=1632

Code:Refers to the size of the code;

Ro-data:Refers to constant data excluding inline data;

RW-data:Refers to readable and writable (RW), initialized variable data;

ZI-data:Refers to uninitialized (ZI) variable data;

Reminder:

A.Code, Ro-data:Located in FLASH;

B.RW-data, ZI-data:Located in RAM;

C.RW-dataInitialized data will be stored in Flash and moved to RAM on power-up.

The relationships are as follows:

RO Size = Code + RO Data

RW Size = RW Data + ZI Data

ROM Size = Code + RO Data + RW Data

The above map information is a comprehensive summary. If you do not want to see the details of those modules, but only the summary statistics, you can select only “Totals Info” in the configuration to compare the information:

Understanding Map Files in Keil

———— END ————
Understanding Map Files in Keil
●Column “Embedded Tools
●Column “Embedded Development”
●Column “Keil Tutorial”
●Selected Tutorials from the Embedded Column
Follow the public accountReply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.
Click “Read the original text” to see more shares.

Leave a Comment