]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/file/magic/Magdir/coff
MFV r353143 (phillip):
[FreeBSD/FreeBSD.git] / contrib / file / magic / Magdir / coff
1
2 #------------------------------------------------------------------------------
3 # $File: coff,v 1.3 2018/08/01 10:34:03 christos Exp $
4 # coff: file(1) magic for Common Object Files not specific to known cpu types or manufactures
5 #
6 # COFF
7 #
8 # by Joerg Jenderek at Oct 2015
9 # https://en.wikipedia.org/wiki/COFF
10 # https://de.wikipedia.org/wiki/Common_Object_File_Format
11 # http://www.delorie.com/djgpp/doc/coff/filhdr.html
12
13 # display name+variables+flags of Common Object Files Format (32bit)
14 # Maybe used also in adi,att3b,clipper,hitachi-sh,hp,ibm6000,intel,
15 # mips,motorola,msdos,osf1,sharc,varied.out,vax
16 0       name                            display-coff
17 # test for unused flag bits (0x8000,0x0800,0x0400,0x0200,x0080) in f_flags
18 >18     uleshort&0x8E80 0
19 >>0     clear           x
20 # f_magic - magic number
21 # DJGPP, 80386 COFF executable, MS Windows COFF Intel 80386 object file (./intel)
22 >>0     uleshort        0x014C          Intel 80386
23 # Hitachi SH big-endian COFF (./hitachi-sh)
24 >>0     uleshort        0x0500          Hitachi SH big-endian
25 # Hitachi SH little-endian COFF (./hitachi-sh)
26 >>0     uleshort        0x0550          Hitachi SH little-endian
27 # executable (RISC System/6000 V3.1) or obj module (./ibm6000)
28 #>>0    uleshort        0x01DF
29 # MS Windows COFF Intel Itanium, AMD64
30 # https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx
31 >>0     uleshort        0x0200          Intel ia64
32 >>0     uleshort        0x8664          Intel amd64
33 # TODO for other COFFs
34 #>>0    uleshort        0xABCD          COFF_TEMPLATE
35 >>0     default         x
36 >>>0    uleshort        x               type 0x%04x
37 >>0     uleshort        x               COFF
38 # F_EXEC flag bit
39 >>18    leshort         ^0x0002         object file
40 #!:mime application/x-coff
41 #!:ext cof/o/obj/lib
42 >>18    leshort         &0x0002         executable
43 #!:mime application/x-coffexec
44 # F_RELFLG flag bit,static object
45 >>18    leshort         &0x0001         \b, no relocation info
46 # F_LNNO flag bit
47 >>18    leshort         &0x0004         \b, no line number info
48 # F_LSYMS flag bit
49 >>18    leshort         &0x0008         \b, stripped
50 >>18    leshort         ^0x0008         \b, not stripped
51 # flags in other COFF versions
52 #0x0010    F_FDPR_PROF
53 #0x0020    F_FDPR_OPTI
54 #0x0040    F_DSA
55 # F_AR32WR flag bit
56 #>>>18  leshort         &0x0100         \b, 32 bit little endian
57 #0x1000    F_DYNLOAD
58 #0x2000    F_SHROBJ
59 #0x4000    F_LOADONLY
60 # f_nscns - number of sections
61 >>2     uleshort        <2              \b, %d section
62 >>2     uleshort        >1              \b, %d sections
63 # f_timdat - file time & date stamp only for little endian
64 #>>4    date            x               \b, %s
65 # f_symptr - symbol table pointer, only for not stripped
66 >>8     ulelong         >0              \b, symbol offset=0x%x
67 # f_nsyms - number of symbols, only for not stripped
68 >>12    ulelong         >0              \b, %d symbols
69 # f_opthdr - optional header size
70 >>16    uleshort        >0              \b, optional header size %d
71 # at offset 20 can be optional header, extra bytes FILHSZ-20 because
72 # do not rely on sizeof(FILHDR) to give the correct size for header.
73 # or first section header
74 # additional variables for other COFF files
75 # >20   beshort         0407            (impure)
76 # >20   beshort         0410            (pure)
77 # >20   beshort         0413            (demand paged)
78 # >20   beshort         0421            (standalone)
79 # >22   leshort         >0              - version %d
80 # >168  string          .lowmem         Apple toolbox
81