Documentation for extract_sections.pl |
extract_sections.pl
Generates a C array of the data in an initialized section e.g. will generate an array const unsigned char _cinit[0x7fc] = { 0x12, 0x34, 0x56... } A pragma CODE_SECTION or DATA_SECTION is added for link placeability
extract_sections --sect=.initSect1 --sect=.initSect2 --pragma=.xyz:initSect1 --pragma=.xyz:initSect2 filename.xml
Note that --sect can be shortform replaced with -s. Likewise for --pragma as -p
The --pragma (-p) is optional.
Example : - from a DOS prompt: -
[>] <ccstudiodir>\dosrun.bat
[>] ofd6x -x -o=irom.xml irom.out
[>] perl extract_sections.pl --sect=.const --pragma=.constrom irom.xml
If you need more initialized sections to be generated, just add them via additional '--sect', '--pragma' entries e.g. '--sect=.text'
Alternatively, pipe the output from OFD into the script ...
ofd6x -x irom.out | perl extract_sections.pl --sect=.const --pragma=.constrom
If you pass in a garbage section (ie one that does not exist in the COFF file, the script will skip it and move on. However, it might be easiest to run 'sectti app.out' simply to see the list of sections in your output file.
Make sure to match up the number of --sect entries with --pragma entries else results are undefined.
Output of above commands would be 2 files :- irom.out.c, irom.out.h
Note that internally, this script still needs the .out file because it has to seek & read the raw data from the COFF file (since the data itself is not in the .xml). It gets the .out COFF filename internally from a field in the .xml.
None
None except that you need to first run OFD which is only available in Codegen Tools >= v5.0 for c6000, v3.0 for C55, v4.0 for C54
Generates a C array of the data in an initialized section e.g. will generate an array _const[] = {0x12, 0x34, 0x56...}
Useful in cases such as ROMing where you e.g. want to get LOG_printf result data from ROM'ed code, hence need to preserve the .const contents which hold the string data, when you build the final application
Uses ofd<ARCH> XML output's raw_data_ptr, raw_data_size fields in each output section to achieve this.
At a push, this could be used to generate a complete bootimage if you passed in all initialized sections via '--sect=.const --sect=.text' etc However you'd be better served using bootimage.pl which does this for you.
OFD stands for Object File Display utility. Examples include ofd6x for C6000 and ofd55 for C5500.
This script was written using Perl version 5.8.3. It may not work with earlier revisions of Perl.
Recent releases of OFD support options for filtering the XML output down to what is strictly of interest. The best options to use in combination with this script are:
-x --xml_indent=0 --obj_display=none,sections
Filtering the XML in this way reduces the amount of data processed by this script, thus making it run faster.
You may see diagnostics similar to ...
Warning: <symbol> element has non-unique value in 'name' key attribute:
.text at extract_sections.pl line 154.
Warning: <symbol> element has non-unique value in 'name' key attribute:
.bss at extract_sections.pl line 154.
Warning: <symbol> element has non-unique value in 'name' key attribute:
.data at extract_sections.pl line 154.
These diagnostics do not result in the script failing or producing incorrect output.
Fixing this problem requires a significant rewrite of this script. Since it is likely this script is no longer used, the work will not be done. If this judgement proves wrong, it will be revisited.
Documentation for extract_sections.pl |