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.
As shown above, simply pass the path of the magic file snippet
-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:
/usr/lib/magic. Use the output of
grep magic $(which file)if you're stuck.
magic.mgc. If this is the case, run
file -Cas root to compile your newly edited magic file.
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.