This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
i am trying to make a COFF file parser based on the SPRAAO8:
http://www.ti.com/lit/an/spraao8/spraao8.pdf
I have a question about how the pointer in "Character" bits of Section Header structure be interpreted:
For example when i try to parse the following COFF out data for MSP430:
for the first section i got the following data:
Sect Hdr 0:
00 00 00 00 7D 02 00 00 00 00 00 00 00 00 00 00 6F 00 00 00 22 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 08 00 00 00
Chars : 00 00 00 00 7D 02 00 00
Phy addr : 00 00 00 00
Virtual addr : 00 00 00 00
Size : 6F 00 00 00
Raw data ptr : 22 07 00 00
Reloc entry ptr : 00 00 00 00
Reserved : 00 00 00 00
Num of reloc ent : 00 00 00 00
Num of line ent : 00 00 00 00
Flags : 10 00 00 00
Reserved : 08 00
Mem page num : 00 00
The question is how shall i interpret the 00 00 00 00 7D 02 00 00 in the Character field?
If i parse through the COFF file, the string table will look like this (byte count - content):
{'0x2dca': '$C$DW$L$main$3$B',
'0x2dec': '$C$DW$L$main$4$B',
'0x2f87': '_c_int00_noinit_noexit',
'0x2ed1': '_lock.asm',
'0x2dad': '.debug_line',
'0x2ead': 'pre_init.asm',
'0x2fc7': '__TI_args_main',
'0x2fb6': '_system_pre_init',
'0x2ff7': '.debug_abbrev',
'0x2db9': '$C$DW$L$main$2$B',
'0x2e0e': '$C$DW$L$main$4$E',
'0x2edb': '.text:_nop',
'0x2f44': '__STACK_END',
'0x2e96': '.text:abort',
'0x2f65': '__edata__',
'0x2e78': 'copy_zero_init.asm',
'0x2e2a': '.text:_c_int00_noinit_noexit',
'0x2d86': '.mspabi.extab',
'0x2f5b': '__etext__',
'0x2f7a': '_cleanup_ptr',
'0x2f23': '__pinit__',
'0x2fac': '__TI_exit',
'0x2e8b': 'epilog.asm',
'0x2f37': '__STACK_SIZE',
'0x2ea2': 'memcpy.asm',
'0x2f6f': '_dtors_ptr',
'0x2ef4': 'autoinit.asm',
'0x2ee6': 'args_main.asm',
'0x2f9e': '_reset_vector',
'0x2fe5': '$build.attributes',
'0x2da0': '.debug_frame',
'0x2dfd': '$C$DW$L$main$3$E',
'0x2eba': '.text:_system_pre_init',
'0x2e1f': '.text:main',
'0x2f50': '__c_args__',
'0x2e60': 'copy_decompress_rle.asm',
'0x2f0d': 'CALBC1_1MHZ',
'0x2f2d': '__binit__',
'0x2d6c': '.init_array',
'0x2f19': '__cinit__',
'0x2d78': '.mspabi.exidx',
'0x2d94': '.debug_info',
'0x2fd6': '__TI_auto_init',
'0x2ddb': '$C$DW$L$main$2$E',
'0x2f01': 'CALDCO_1MHZ',
'0x2e47': 'copy_decompress_none.asm'}
I can't anyhow relate the data in the Character field above to any byte count here in the string table list.
Thanks for the help.
To repeat, the eight bytes are: 00 00 00 00 7D 02 00 00
As the first character is a NUL, this is clearly not a string, so it is an offset into the string table. The first four byte are padding. The last four bytes are a 32-bit little-endian value, so the offset is 0x27d. The address of the string table is 0x2d68, and 0x27d+0x2d68=0x2fe5, so the section is "$build.attributes"
You should double-check your results with the output of "ofd430 -v BLINK.out"
Why are you making a COFF parser? Does the output of "ofd430 -x" not give you everything you need?
Hi,
thanks for the answer and the hint. I didn't know that this is possible (at least i didn't find any information until now).
however one thing i notice is that i want to see the raw data section in hex format, and i see that this is not supported by using the ofd430.
Btw, is there any reference to know what are the files in the compiler bin directory and what can they be used for?
C:\ti\CCS\CCS_v5_2_069\ccsv5\tools\compiler\msp430_4.1.0\bin>dir
Volume in drive C is OSDisk
Volume Serial Number is EA4C-F81C
Directory of C:\ti\CCS\CCS_v5_2_069\ccsv5\tools\compiler\msp430_4.1.0\
21.06.2012 12:12 <DIR> .
21.06.2012 12:12 <DIR> ..
20.03.2012 17:24 688.128 abs430.exe
20.03.2012 17:24 1.987.584 acp430.exe
20.03.2012 17:24 2.007.040 acpia430.exe
20.03.2012 17:24 645.632 ar430.exe
20.03.2012 17:24 1.297.408 asm430.exe
20.03.2012 17:24 1.973.760 cg430.exe
20.03.2012 17:24 1.061.376 cl430.exe
20.03.2012 17:24 73.728 clist430.exe
20.03.2012 17:24 171.008 dem430.exe
20.03.2012 17:24 702.976 dis430.exe
20.03.2012 17:24 686.080 embed430.exe
20.03.2012 17:24 886.272 hex430.exe
20.03.2012 17:24 690.688 ilk430.exe
20.03.2012 17:24 767.488 libinfo430.exe
20.03.2012 17:24 1.973.248 lnk430.exe
20.03.2012 17:24 90.112 mk430.exe
20.03.2012 17:24 705.536 nm430.exe
20.03.2012 17:24 906.240 ofd430.exe
20.03.2012 17:24 2.231.296 opt430.exe
20.03.2012 17:24 684.544 strip430.exe
20.03.2012 17:24 693.248 xref430.exe
21 File(s) 20.923.392 bytes
2 Dir(s) 124.358.217.728 bytes free
Perhaps dis430 might be what you're looking for?
Most of those executables are not meant to be invoked directly and are not documented. The rest are documented in the MSP430 Optimizing C/C++ Compiler User's Guide http://www.ti.com/lit/pdf/slau132 and MSP430 Assembly Language Tools User's Guide http://www.ti.com/lit/pdf/slau131