coff 2.7 KB

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