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