1298178Sdelphij 2298178Sdelphij#------------------------------------------------------------------------------ 3354939Sdelphij# $File: coff,v 1.3 2018/08/01 10:34:03 christos Exp $ 4298178Sdelphij# coff: file(1) magic for Common Object Files not specific to known cpu types or manufactures 5298178Sdelphij# 6298178Sdelphij# COFF 7298178Sdelphij# 8298178Sdelphij# by Joerg Jenderek at Oct 2015 9298178Sdelphij# https://en.wikipedia.org/wiki/COFF 10298178Sdelphij# https://de.wikipedia.org/wiki/Common_Object_File_Format 11298178Sdelphij# http://www.delorie.com/djgpp/doc/coff/filhdr.html 12298178Sdelphij 13298178Sdelphij# display name+variables+flags of Common Object Files Format (32bit) 14298178Sdelphij# Maybe used also in adi,att3b,clipper,hitachi-sh,hp,ibm6000,intel, 15298178Sdelphij# mips,motorola,msdos,osf1,sharc,varied.out,vax 16298178Sdelphij0 name display-coff 17298178Sdelphij# test for unused flag bits (0x8000,0x0800,0x0400,0x0200,x0080) in f_flags 18328874Seadler>18 uleshort&0x8E80 0 19298178Sdelphij>>0 clear x 20298178Sdelphij# f_magic - magic number 21298178Sdelphij# DJGPP, 80386 COFF executable, MS Windows COFF Intel 80386 object file (./intel) 22298178Sdelphij>>0 uleshort 0x014C Intel 80386 23298178Sdelphij# Hitachi SH big-endian COFF (./hitachi-sh) 24298178Sdelphij>>0 uleshort 0x0500 Hitachi SH big-endian 25298178Sdelphij# Hitachi SH little-endian COFF (./hitachi-sh) 26298178Sdelphij>>0 uleshort 0x0550 Hitachi SH little-endian 27298178Sdelphij# executable (RISC System/6000 V3.1) or obj module (./ibm6000) 28328874Seadler#>>0 uleshort 0x01DF 29354939Sdelphij# MS Windows COFF Intel Itanium, AMD64 30354939Sdelphij# https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx 31354939Sdelphij>>0 uleshort 0x0200 Intel ia64 32354939Sdelphij>>0 uleshort 0x8664 Intel amd64 33298178Sdelphij# TODO for other COFFs 34298178Sdelphij#>>0 uleshort 0xABCD COFF_TEMPLATE 35298178Sdelphij>>0 default x 36298178Sdelphij>>>0 uleshort x type 0x%04x 37298178Sdelphij>>0 uleshort x COFF 38298178Sdelphij# F_EXEC flag bit 39298178Sdelphij>>18 leshort ^0x0002 object file 40298178Sdelphij#!:mime application/x-coff 41298178Sdelphij#!:ext cof/o/obj/lib 42298178Sdelphij>>18 leshort &0x0002 executable 43298178Sdelphij#!:mime application/x-coffexec 44298178Sdelphij# F_RELFLG flag bit,static object 45298178Sdelphij>>18 leshort &0x0001 \b, no relocation info 46298178Sdelphij# F_LNNO flag bit 47298178Sdelphij>>18 leshort &0x0004 \b, no line number info 48298178Sdelphij# F_LSYMS flag bit 49298178Sdelphij>>18 leshort &0x0008 \b, stripped 50298178Sdelphij>>18 leshort ^0x0008 \b, not stripped 51298178Sdelphij# flags in other COFF versions 52328874Seadler#0x0010 F_FDPR_PROF 53298178Sdelphij#0x0020 F_FDPR_OPTI 54298178Sdelphij#0x0040 F_DSA 55298178Sdelphij# F_AR32WR flag bit 56298178Sdelphij#>>>18 leshort &0x0100 \b, 32 bit little endian 57328874Seadler#0x1000 F_DYNLOAD 58298178Sdelphij#0x2000 F_SHROBJ 59298178Sdelphij#0x4000 F_LOADONLY 60298178Sdelphij# f_nscns - number of sections 61298178Sdelphij>>2 uleshort <2 \b, %d section 62298178Sdelphij>>2 uleshort >1 \b, %d sections 63298178Sdelphij# f_timdat - file time & date stamp only for little endian 64298178Sdelphij#>>4 date x \b, %s 65298178Sdelphij# f_symptr - symbol table pointer, only for not stripped 66298178Sdelphij>>8 ulelong >0 \b, symbol offset=0x%x 67298178Sdelphij# f_nsyms - number of symbols, only for not stripped 68298178Sdelphij>>12 ulelong >0 \b, %d symbols 69328874Seadler# f_opthdr - optional header size 70298178Sdelphij>>16 uleshort >0 \b, optional header size %d 71298178Sdelphij# at offset 20 can be optional header, extra bytes FILHSZ-20 because 72298178Sdelphij# do not rely on sizeof(FILHDR) to give the correct size for header. 73298178Sdelphij# or first section header 74298178Sdelphij# additional variables for other COFF files 75298178Sdelphij# >20 beshort 0407 (impure) 76298178Sdelphij# >20 beshort 0410 (pure) 77298178Sdelphij# >20 beshort 0413 (demand paged) 78298178Sdelphij# >20 beshort 0421 (standalone) 79298178Sdelphij# >22 leshort >0 - version %d 80298178Sdelphij# >168 string .lowmem Apple toolbox 81298178Sdelphij 82