13e41d09dSXin LI 23e41d09dSXin LI#------------------------------------------------------------------------------ 3*48c779cdSXin LI# $File: coff,v 1.3 2018/08/01 10:34:03 christos Exp $ 43e41d09dSXin LI# coff: file(1) magic for Common Object Files not specific to known cpu types or manufactures 53e41d09dSXin LI# 63e41d09dSXin LI# COFF 73e41d09dSXin LI# 83e41d09dSXin LI# by Joerg Jenderek at Oct 2015 93e41d09dSXin LI# https://en.wikipedia.org/wiki/COFF 103e41d09dSXin LI# https://de.wikipedia.org/wiki/Common_Object_File_Format 113e41d09dSXin LI# http://www.delorie.com/djgpp/doc/coff/filhdr.html 123e41d09dSXin LI 133e41d09dSXin LI# display name+variables+flags of Common Object Files Format (32bit) 143e41d09dSXin LI# Maybe used also in adi,att3b,clipper,hitachi-sh,hp,ibm6000,intel, 153e41d09dSXin LI# mips,motorola,msdos,osf1,sharc,varied.out,vax 163e41d09dSXin LI0 name display-coff 173e41d09dSXin LI# test for unused flag bits (0x8000,0x0800,0x0400,0x0200,x0080) in f_flags 183e41d09dSXin LI>18 uleshort&0x8E80 0 193e41d09dSXin LI>>0 clear x 203e41d09dSXin LI# f_magic - magic number 213e41d09dSXin LI# DJGPP, 80386 COFF executable, MS Windows COFF Intel 80386 object file (./intel) 223e41d09dSXin LI>>0 uleshort 0x014C Intel 80386 233e41d09dSXin LI# Hitachi SH big-endian COFF (./hitachi-sh) 243e41d09dSXin LI>>0 uleshort 0x0500 Hitachi SH big-endian 253e41d09dSXin LI# Hitachi SH little-endian COFF (./hitachi-sh) 263e41d09dSXin LI>>0 uleshort 0x0550 Hitachi SH little-endian 273e41d09dSXin LI# executable (RISC System/6000 V3.1) or obj module (./ibm6000) 283e41d09dSXin LI#>>0 uleshort 0x01DF 29*48c779cdSXin LI# MS Windows COFF Intel Itanium, AMD64 30*48c779cdSXin LI# https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx 31*48c779cdSXin LI>>0 uleshort 0x0200 Intel ia64 32*48c779cdSXin LI>>0 uleshort 0x8664 Intel amd64 333e41d09dSXin LI# TODO for other COFFs 343e41d09dSXin LI#>>0 uleshort 0xABCD COFF_TEMPLATE 353e41d09dSXin LI>>0 default x 363e41d09dSXin LI>>>0 uleshort x type 0x%04x 373e41d09dSXin LI>>0 uleshort x COFF 383e41d09dSXin LI# F_EXEC flag bit 393e41d09dSXin LI>>18 leshort ^0x0002 object file 403e41d09dSXin LI#!:mime application/x-coff 413e41d09dSXin LI#!:ext cof/o/obj/lib 423e41d09dSXin LI>>18 leshort &0x0002 executable 433e41d09dSXin LI#!:mime application/x-coffexec 443e41d09dSXin LI# F_RELFLG flag bit,static object 453e41d09dSXin LI>>18 leshort &0x0001 \b, no relocation info 463e41d09dSXin LI# F_LNNO flag bit 473e41d09dSXin LI>>18 leshort &0x0004 \b, no line number info 483e41d09dSXin LI# F_LSYMS flag bit 493e41d09dSXin LI>>18 leshort &0x0008 \b, stripped 503e41d09dSXin LI>>18 leshort ^0x0008 \b, not stripped 513e41d09dSXin LI# flags in other COFF versions 523e41d09dSXin LI#0x0010 F_FDPR_PROF 533e41d09dSXin LI#0x0020 F_FDPR_OPTI 543e41d09dSXin LI#0x0040 F_DSA 553e41d09dSXin LI# F_AR32WR flag bit 563e41d09dSXin LI#>>>18 leshort &0x0100 \b, 32 bit little endian 573e41d09dSXin LI#0x1000 F_DYNLOAD 583e41d09dSXin LI#0x2000 F_SHROBJ 593e41d09dSXin LI#0x4000 F_LOADONLY 603e41d09dSXin LI# f_nscns - number of sections 613e41d09dSXin LI>>2 uleshort <2 \b, %d section 623e41d09dSXin LI>>2 uleshort >1 \b, %d sections 633e41d09dSXin LI# f_timdat - file time & date stamp only for little endian 643e41d09dSXin LI#>>4 date x \b, %s 653e41d09dSXin LI# f_symptr - symbol table pointer, only for not stripped 663e41d09dSXin LI>>8 ulelong >0 \b, symbol offset=0x%x 673e41d09dSXin LI# f_nsyms - number of symbols, only for not stripped 683e41d09dSXin LI>>12 ulelong >0 \b, %d symbols 693e41d09dSXin LI# f_opthdr - optional header size 703e41d09dSXin LI>>16 uleshort >0 \b, optional header size %d 713e41d09dSXin LI# at offset 20 can be optional header, extra bytes FILHSZ-20 because 723e41d09dSXin LI# do not rely on sizeof(FILHDR) to give the correct size for header. 733e41d09dSXin LI# or first section header 743e41d09dSXin LI# additional variables for other COFF files 753e41d09dSXin LI# >20 beshort 0407 (impure) 763e41d09dSXin LI# >20 beshort 0410 (pure) 773e41d09dSXin LI# >20 beshort 0413 (demand paged) 783e41d09dSXin LI# >20 beshort 0421 (standalone) 793e41d09dSXin LI# >22 leshort >0 - version %d 803e41d09dSXin LI# >168 string .lowmem Apple toolbox 813e41d09dSXin LI 82