Magic File for TMS320 series DSP object files

Why should I care?

If you have not discovered the file command yet, you're missing out on a handy tool for identifying all sorts of binary files. Check the man pages-- it's installed on most Unix-like systems.

To illustrate the power of file, I ran file on a random collection of TI DSP object files lying around on my hard drive:

$ file -m ti-coff.magic *.o*
crt0_3sr.o:        COFF v2 executable, TI TMS320C30/C31, relocatable, local symbols
crt0_4sr.o:        COFF v2 executable, TI TMS320C40/C44, relocatable, local symbols
daa.obj:           COFF v2 executable, TI TMS320C54x, relocatable, line numbers, local symbols
daa.out:           COFF v2 executable, TI TMS320C54x, linked, line numbers, local symbols, entry point=0x1ae
vectors.obj:       COFF v2 executable, TI TMS320C6x, relocatable, line numbers, local symbols
cnfdsp_nohost.obj: COFF v2 executable, TI TMS320C6x, relocatable, line numbers, local symbols
cnfdsp_nohost.out: COFF v2 executable, TI TMS320C6x, linked, line numbers, local symbols, entry point=0xb920

The files are properly identified, and you don't even have to resort to using objdump to get basic attributes from each.

How do I use it?

As shown above, simply pass the path of the magic file snippet with -m, and then list the files of interest.

If you find yourself using this command often, it is easier to incorporate the "magic" file into your system-wide magic database. There are only a few steps involved:

  1. Locate your magic file. Typical places are /usr/share/magic and /usr/lib/magic. Use the output of grep magic $(which file) if you're stuck.
  2. Make a backup in case you hose the file while editing.
  3. Insert the contents of ti-coff.magic somewhere near the top of the file (search for "Localstuff"). Be sure not to insert the file in the middle of a group of non-comment lines. (Comments are delimited with hash marks.) Add extra newlines around the inserted file.
  4. If you have a recent version of file, you may have an additional data file named magic.mgc. If this is the case, run file -C as root to compile your newly edited magic file.

How does it work?

Check the magic file format man page (man 5 magic, but you can probably leave out the section number) and take a look at the code. It is a simple if-then matching structure, although it is admittedly not very self-explanitory. The magic numbers were culled from various TI COFF reference documents.

Back to the main page
Charles Lepple
Get TMS320C6x development tools at SourceForge.net. Fast, secure and Free Open Source software downloads Created by XEmacs Valid HTML 4.01!