微软的官方说明
/MAP(生成映射文件) | Microsoft Learn
设置步骤
1. 右键项目属性, 连接器 -> 常规 -> 启用增量链接,设置为否。如下图:
2. 连接器 -> 调试
生成调试信息 设置为 生成调试信息 (/DEBUG)
生成程序数据库文件 设置为 指定路径文件名,默认系统会自动设置
生成映射文件 设置为 是 (/MAP)
映射文件名 设置为 指定的完整路径, 例如 aaa/Debug/test.map
具体如下图:
重新生成项目,成功生成,如下图所示:
部分.map文件示例内容如下所示:
demo_ccwindows
Timestamp is 64eed0a8 (Wed Aug 30 13:16:24 2023)
Preferred load address is 0000000140000000
Start Length Name Class
0001:00000000 00003290H .text$mn CODE
0001:00003290 00000040H .text$mn$00 CODE
0001:000032d0 00000090H .text$x CODE
0002:00000000 00000240H .idata$5 DATA
0002:00000240 00000038H .00cfg DATA
0002:00000278 00000008H .CRT$XCA DATA
0002:00000280 00000008H .CRT$XCAA DATA
0002:00000288 00000008H .CRT$XCZ DATA
0002:00000290 00000008H .CRT$XIA DATA
0002:00000298 00000008H .CRT$XIAA DATA
0002:000002a0 00000008H .CRT$XIAC DATA
0002:000002a8 00000008H .CRT$XIZ DATA
0002:000002b0 00000008H .CRT$XPA DATA
0002:000002b8 00000008H .CRT$XPZ DATA
0002:000002c0 00000008H .CRT$XTA DATA
0002:000002c8 00000008H .CRT$XTZ DATA
0002:000002d0 00000000H .gehcont$y DATA
0002:000002d0 00000000H .gfids$y DATA
0002:000002d0 00000ab0H .rdata DATA
0002:00000d80 00000080H .rdata$CastGuardVftablesA DATA
0002:00000e00 00000080H .rdata$CastGuardVftablesC DATA
0002:00000e80 00000080H .rdata$voltmd DATA
0002:00000f00 00000360H .rdata$zzzdbg DATA
0002:00001260 00000008H .rtc$IAA DATA
0002:00001268 00000008H .rtc$IMZ DATA
0002:00001270 00000008H .rtc$IZZ DATA
0002:00001278 00000008H .rtc$TAA DATA
0002:00001280 00000008H .rtc$TMZ DATA
0002:00001288 00000008H .rtc$TZZ DATA
0002:00001290 0000042cH .xdata DATA
0002:000016bc 00000000H .edata DATA
0002:000016bc 0000003cH .idata$2 DATA
0002:000016f8 00000018H .idata$3 DATA
0002:00001710 00000240H .idata$4 DATA
0002:00001950 0000059eH .idata$6 DATA
0003:00000000 00020060H .data DATA
0003:00020060 00000620H .bss DATA
0004:00000000 00000468H .pdata DATA
0005:00000000 00000060H .rsrc$01 DATA
0005:00000060 00000180H .rsrc$02 DATA
Address Publics by Value Rva+Base Lib:Object
0000:00000000 __AbsoluteZero 0000000000000000 <absolute>
0000:00000000 ___safe_se_handler_count 0000000000000000 <absolute>
0000:00000000 ___safe_se_handler_table 0000000000000000 <absolute>
0000:00000000 __arm64x_extra_rfe_table 0000000000000000 <absolute>
0000:00000000 __arm64x_extra_rfe_table_size 0000000000000000 <absolute>
0000:00000000 __arm64x_native_entrypoint 0000000000000000 <absolute>
有了这些信息,之后就可以通过.map文件查看编译生成的代码细节,以及分析相关程序问题。
关于.map文件结构的细节示例说明
Start | Length | Name | Class | |
0001: | 00000000 | 00000304H | .text | CODE |
1. MAP File Contents - Debugging Applications - Visual Basic Planet
2. Finding Crash Information Using the MAP File - CodeProject
...