Part Number:TMS320F28335
定义一个初始化的全局变量 占用initialized data :4 占用uninitialized data:1
定义一个未初始化的全局变量 占用initialized data :0 占用uninitialized data:1
这怎么解释??????
Yale Li:
左边这一列截图是从哪里看到的?方便上传一下完整的吗?
另外再方便上传一下map文件吗?
,
zhognjin zhang:
无法上传文件啊
初始化的,以上
——————————————————————–
未初始化的 以下
,
Yale Li:
然后选择本地文件上传即可
,
zhognjin zhang:
******************************************************************************TMS320C2000 Linker PC v21.6.0****************************************************************************** >> Linked Wed Dec6 08:43:45 2023OUTPUT FILE NAME:<test.out> ENTRY POINT SYMBOL: "_c_int00"address: 0000a000MEMORY CONFIGURATIONnameoriginlengthusedunusedattrfill ------------------------------------------------------------------- PAGE 0:BEGIN00000000000000020000000000000002RWIXRAMM000000052000003ae00000000000003aeRWIXRAML000008000000020000000001e00001fe2RWIXRAML10000a00000002000000000e000001f20RWIXZONE7A002000000000fc00000000000000fc00RWIXRAMH000300000000080000000000000008000RWIXRAMH100308000000080000000000000008000RWIXRAMH200310000000080000000000000008000RWIXCSM_RSVD0033ff80000000760000000000000076RWIXCSM_PWL_PROG0033fff8000000080000000000000008RWIXIQTABLES003fe00000000b500000000000000b50RWIXIQTABLES2003feb500000008c000000000000008cRWIXFPUTABLES003febdc000006a000000000000006a0RWIXBOOTROM003ff27c00000d440000000000000d44RWIXRESET003fffc0000000020000000000000002RWIXPAGE 1:BOOT_RSVD00000002000000500000000000000050RWIXRAMM100000400000004000000030000000100RWIXRAML20000c000000020000000000b00001ff5RWIXRAML30000e000000020000000000000002000RWIXRAML400010000000020000000000000002000RWIXRAML500012000000020000000000000002000RWIXRAML600014000000020000000000000002000RWIXRAML700016000000020000000000000002000RWIXZONE7B0020fc00000004000000000000000400RWIXRAMH300318000000080000000000000008000RWIXRAMH400320000000080000000000000008000RWIXRAMH500328000000080000000000000008000RWIXSECTION ALLOCATION MAPoutputattributes/ sectionpageoriginlengthinput sections ------------------------------------------------ .cinit0000080000000001e000080000000000erts2800_fpu32.lib : exit.c.obj (.cinit)0000800e00000005: _lock.c.obj (.cinit:__lock)0000801300000005: _lock.c.obj (.cinit:__unlock)0000801800000004main.obj (.cinit)0000801c00000002--HOLE-- [fill = 0].text00000a000000000e00000a00000000056rts2800_fpu32.lib : boot28.asm.obj (.text)0000a05600000029: exit.c.obj (.text)0000a07f00000024: cpy_tbl.c.obj (.text)0000a0a30000001d: memcpy.c.obj (.text)0000a0c000000012: args_main.c.obj (.text)0000a0d200000009: _lock.c.obj (.text)0000a0db00000002main.obj (.text)0000a0dd00000002rts2800_fpu32.lib : pre_init.c.obj (.text)0000a0df00000001: startup.c.obj (.text).pinit00000800000000000UNINITIALIZED.stack10000040000000300UNINITIALIZED0000040000000300--HOLE--.ebss10000c0000000000bUNINITIALIZED0000c00000000006rts2800_fpu32.lib : exit.c.obj (.ebss)0000c00600000002: _lock.c.obj (.ebss:__lock)0000c00800000002: _lock.c.obj (.ebss:__unlock)0000c00a00000001main.obj (.ebss).reset0003fffc000000002DSECT003fffc000000002rts2800_fpu32.lib : boot28.asm.obj (.reset)csm_rsvd00033ff8000000000DSECTcsmpasswds*00033fff800000000DSECTMODULE SUMMARYModulecodeinitialized datauninitialized data--------------------------------------------.\main.obj241+--+-----------------+------+------------------+--------------------+Total:241C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_21.6.0.LTS\lib\rts2800_fpu32.libboot28.asm.obj8600exit.c.obj41146cpy_tbl.c.obj3600memcpy.c.obj2900_lock.c.obj9104args_main.c.obj1800pre_init.c.obj200startup.c.obj100+--+-----------------+------+------------------+--------------------+Total:2222410Stack:00768+--+-----------------+------+------------------+--------------------+Grand Total:22428779GLOBAL DATA SYMBOLS: SORTED BY DATA PAGEaddressdata pagename ---------------------------- 0000040010 (00000400)__stack0000c000300 (0000c000)___TI_enable_exit_profile_output 0000c002300 (0000c000)___TI_cleanup_ptr 0000c004300 (0000c000)___TI_dtors_ptr 0000c006300 (0000c000)__lock 0000c008300 (0000c000)__unlock 0000c00a300 (0000c000)_aaGLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Namepageaddressname---------------00000a000.text00000a056C$$EXIT100000700__STACK_ENDabs00000300__STACK_SIZE10000c002___TI_cleanup_ptr10000c004___TI_dtors_ptr10000c000___TI_enable_exit_profile_output absffffffff___TI_pprof_out_hndlabsffffffff___TI_prof_data_sizeabsffffffff___TI_prof_data_startabsffffffff___binit__absffffffff___c_args__000008000___cinit__00000a0e0___etext__absffffffff___pinit__00000a000___text__00000a0c0__args_main10000c006__lock00000a0da__nop00000a0d6__register_lock00000a0d2__register_unlock100000400__stack00000a0df__system_post_cinit00000a0dd__system_pre_init10000c008__unlock10000c00a_aa00000a056_abort00000a000_c_int0000000a07f_copy_in00000a058_exit00000a0db_main00000a0a3_memcpyabsffffffffbinit000008000cinit00000a0e0etextabsffffffffpinitGLOBAL SYMBOLS: SORTED BY Symbol Addresspageaddressname---------------000008000___cinit__000008000cinit00000a000.text00000a000___text__00000a000_c_int0000000a056C$$EXIT00000a056_abort00000a058_exit00000a07f_copy_in00000a0a3_memcpy00000a0c0__args_main00000a0d2__register_unlock00000a0d6__register_lock00000a0da__nop00000a0db_main00000a0dd__system_pre_init00000a0df__system_post_cinit00000a0e0___etext__00000a0e0etext100000400__stack100000700__STACK_END10000c000___TI_enable_exit_profile_output 10000c002___TI_cleanup_ptr10000c004___TI_dtors_ptr10000c006__lock10000c008__unlock10000c00a_aaabs00000300__STACK_SIZEabsffffffff___TI_pprof_out_hndlabsffffffff___TI_prof_data_sizeabsffffffff___TI_prof_data_startabsffffffff___binit__absffffffff___c_args__absffffffff___pinit__absffffffffbinitabsffffffffpinit[36 symbols]******************************************************************************TMS320C2000 Linker PC v21.6.0****************************************************************************** >> Linked Wed Dec6 08:49:17 2023OUTPUT FILE NAME:<test.out> ENTRY POINT SYMBOL: "_c_int00"address: 0000a000MEMORY CONFIGURATIONnameoriginlengthusedunusedattrfill ------------------------------------------------------------------- PAGE 0:BEGIN00000000000000020000000000000002RWIXRAMM000000052000003ae00000000000003aeRWIXRAML000008000000020000000001a00001fe6RWIXRAML10000a00000002000000000e000001f20RWIXZONE7A002000000000fc00000000000000fc00RWIXRAMH000300000000080000000000000008000RWIXRAMH100308000000080000000000000008000RWIXRAMH200310000000080000000000000008000RWIXCSM_RSVD0033ff80000000760000000000000076RWIXCSM_PWL_PROG0033fff8000000080000000000000008RWIXIQTABLES003fe00000000b500000000000000b50RWIXIQTABLES2003feb500000008c000000000000008cRWIXFPUTABLES003febdc000006a000000000000006a0RWIXBOOTROM003ff27c00000d440000000000000d44RWIXRESET003fffc0000000020000000000000002RWIXPAGE 1:BOOT_RSVD00000002000000500000000000000050RWIXRAMM100000400000004000000030000000100RWIXRAML20000c000000020000000000b00001ff5RWIXRAML30000e000000020000000000000002000RWIXRAML400010000000020000000000000002000RWIXRAML500012000000020000000000000002000RWIXRAML600014000000020000000000000002000RWIXRAML700016000000020000000000000002000RWIXZONE7B0020fc00000004000000000000000400RWIXRAMH300318000000080000000000000008000RWIXRAMH400320000000080000000000000008000RWIXRAMH500328000000080000000000000008000RWIXSECTION ALLOCATION MAPoutputattributes/ sectionpageoriginlengthinput sections ------------------------------------------------ .cinit0000080000000001a000080000000000erts2800_fpu32.lib : exit.c.obj (.cinit)0000800e00000005: _lock.c.obj (.cinit:__lock)0000801300000005: _lock.c.obj (.cinit:__unlock)0000801800000002--HOLE-- [fill = 0].text00000a000000000e00000a00000000056rts2800_fpu32.lib : boot28.asm.obj (.text)0000a05600000029: exit.c.obj (.text)0000a07f00000024: cpy_tbl.c.obj (.text)0000a0a30000001d: memcpy.c.obj (.text)0000a0c000000012: args_main.c.obj (.text)0000a0d200000009: _lock.c.obj (.text)0000a0db00000002main.obj (.text)0000a0dd00000002rts2800_fpu32.lib : pre_init.c.obj (.text)0000a0df00000001: startup.c.obj (.text).pinit00000800000000000UNINITIALIZED.stack10000040000000300UNINITIALIZED0000040000000300--HOLE--.ebss10000c0000000000bUNINITIALIZED0000c00000000006rts2800_fpu32.lib : exit.c.obj (.ebss)0000c00600000002: _lock.c.obj (.ebss:__lock)0000c00800000002: _lock.c.obj (.ebss:__unlock)0000c00a00000001main.obj (.ebss).reset0003fffc000000002DSECT003fffc000000002rts2800_fpu32.lib : boot28.asm.obj (.reset)csm_rsvd00033ff8000000000DSECTcsmpasswds*00033fff800000000DSECTMODULE SUMMARYModulecodeinitialized datauninitialized data--------------------------------------------.\main.obj201+--+-----------------+------+------------------+--------------------+Total:201C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_21.6.0.LTS\lib\rts2800_fpu32.libboot28.asm.obj8600exit.c.obj41146cpy_tbl.c.obj3600memcpy.c.obj2900_lock.c.obj9104args_main.c.obj1800pre_init.c.obj200startup.c.obj100+--+-----------------+------+------------------+--------------------+Total:2222410Stack:00768+--+-----------------+------+------------------+--------------------+Grand Total:22424779GLOBAL DATA SYMBOLS: SORTED BY DATA PAGEaddressdata pagename ---------------------------- 0000040010 (00000400)__stack0000c000300 (0000c000)___TI_enable_exit_profile_output 0000c002300 (0000c000)___TI_cleanup_ptr 0000c004300 (0000c000)___TI_dtors_ptr 0000c006300 (0000c000)__lock 0000c008300 (0000c000)__unlock 0000c00a300 (0000c000)_aaGLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Namepageaddressname---------------00000a000.text00000a056C$$EXIT100000700__STACK_ENDabs00000300__STACK_SIZE10000c002___TI_cleanup_ptr10000c004___TI_dtors_ptr10000c000___TI_enable_exit_profile_output absffffffff___TI_pprof_out_hndlabsffffffff___TI_prof_data_sizeabsffffffff___TI_prof_data_startabsffffffff___binit__absffffffff___c_args__000008000___cinit__00000a0e0___etext__absffffffff___pinit__00000a000___text__00000a0c0__args_main10000c006__lock00000a0da__nop00000a0d6__register_lock00000a0d2__register_unlock100000400__stack00000a0df__system_post_cinit00000a0dd__system_pre_init10000c008__unlock10000c00a_aa00000a056_abort00000a000_c_int0000000a07f_copy_in00000a058_exit00000a0db_main00000a0a3_memcpyabsffffffffbinit000008000cinit00000a0e0etextabsffffffffpinitGLOBAL SYMBOLS: SORTED BY Symbol Addresspageaddressname---------------000008000___cinit__000008000cinit00000a000.text00000a000___text__00000a000_c_int0000000a056C$$EXIT00000a056_abort00000a058_exit00000a07f_copy_in00000a0a3_memcpy00000a0c0__args_main00000a0d2__register_unlock00000a0d6__register_lock00000a0da__nop00000a0db_main00000a0dd__system_pre_init00000a0df__system_post_cinit00000a0e0___etext__00000a0e0etext100000400__stack100000700__STACK_END10000c000___TI_enable_exit_profile_output 10000c002___TI_cleanup_ptr10000c004___TI_dtors_ptr10000c006__lock10000c008__unlock10000c00a_aaabs00000300__STACK_SIZEabsffffffff___TI_pprof_out_hndlabsffffffff___TI_prof_data_sizeabsffffffff___TI_prof_data_startabsffffffff___binit__absffffffff___c_args__absffffffff___pinit__absffffffffbinitabsffffffffpinit[36 symbols]左侧为初始化变量的map, 右侧为未初始化变量的map
,
Yale Li:
主要的区别在这里,.cinit段。
对于COFF格式,未初始化的全局变量分配在.ebss段(全局变量是运行时初始化,所以编译之后全局变量属于未被初始化的部分),而初始化值储存在.cinit段用于初始化全局变量的表中。在器件上电后,由 _c_int00 函数将初始化值从.cinit段复制到.ebss,完成全局变量的运行时初始化。
可以看到,左侧有为.cinit分配相应的空间。
,
zhognjin zhang:
map文件中统计的大小是按字节8位算的,还是按字16位算的?
我定义了一个 int a; 占用uninitialized data:1 可以理解位一个16位的字
而我定义一个 int a = 1; 占用ninitialized data:1 ,initialized data :4,您的意思这个初始化的数字1这个数也占一个内存,我理解initialized data 也应该为1才对,为什么会是4呢?占用四倍的内存?
,
Yale Li:
1. 16位,C2000的一个地址上都是16位;
2. 因为.cinit段中包含的不仅仅只有需要拷贝的值,还有一些其它信息,比如一些标志位,以及值与全局变量之间的映射(这个是我的推测),来控制拷贝的过程。比如,请看一下zhcu875z_TMS320C28x 汇编语言工具 v22.6.0.LTS (Rev. Z)第42、43页:
它是有自己的格式的。
更多的信息,汇编手册中也没有描述了,这些都是与更底层的编译器相关的东西了。如果感兴趣的话你可以查一下相关方面的资料;也可以结合目标文件中相关位置的内容来看一下。
,
zhognjin zhang:
感谢!
1、这里提到EABI与COFF,这两种格式较老的C2000 处理器(如F28335,C28346)支持EABI格式吗?
2、EABI 格式的就不会存在讨论初始化和未初始化占用字节不一致的问题,但是较老的C2000的一些库都是COFF格式的不支持设置成EABI格式共同编译,fatal error #16000: object files have incompatible formats ("C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_21.6.0.LTS/lib/rts2800_fpu32.lib<boot28.asm.obj>" = TI-COFF, "./main.obj" = ELF)
,
Yale Li:
没有,较老的器件只有COFF格式的;对于新的器件,正在逐步迁移到EABI格式。
另外COFF格式的文档也供参考:spraao8_Common Object File Format (COFF