coff 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #------------------------------------------------------------------------------
  2. # $File: coff,v 1.3 2018/08/01 10:34:03 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. # MS Windows COFF Intel Itanium, AMD64
  28. # https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx
  29. >>0 uleshort 0x0200 Intel ia64
  30. >>0 uleshort 0x8664 Intel amd64
  31. # TODO for other COFFs
  32. #>>0 uleshort 0xABCD COFF_TEMPLATE
  33. >>0 default x
  34. >>>0 uleshort x type 0x%04x
  35. >>0 uleshort x COFF
  36. # F_EXEC flag bit
  37. >>18 leshort ^0x0002 object file
  38. #!:mime application/x-coff
  39. #!:ext cof/o/obj/lib
  40. >>18 leshort &0x0002 executable
  41. #!:mime application/x-coffexec
  42. # F_RELFLG flag bit,static object
  43. >>18 leshort &0x0001 \b, no relocation info
  44. # F_LNNO flag bit
  45. >>18 leshort &0x0004 \b, no line number info
  46. # F_LSYMS flag bit
  47. >>18 leshort &0x0008 \b, stripped
  48. >>18 leshort ^0x0008 \b, not stripped
  49. # flags in other COFF versions
  50. #0x0010 F_FDPR_PROF
  51. #0x0020 F_FDPR_OPTI
  52. #0x0040 F_DSA
  53. # F_AR32WR flag bit
  54. #>>>18 leshort &0x0100 \b, 32 bit little endian
  55. #0x1000 F_DYNLOAD
  56. #0x2000 F_SHROBJ
  57. #0x4000 F_LOADONLY
  58. # f_nscns - number of sections
  59. >>2 uleshort <2 \b, %d section
  60. >>2 uleshort >1 \b, %d sections
  61. # f_timdat - file time & date stamp only for little endian
  62. #>>4 date x \b, %s
  63. # f_symptr - symbol table pointer, only for not stripped
  64. >>8 ulelong >0 \b, symbol offset=0x%x
  65. # f_nsyms - number of symbols, only for not stripped
  66. >>12 ulelong >0 \b, %d symbols
  67. # f_opthdr - optional header size
  68. >>16 uleshort >0 \b, optional header size %d
  69. # at offset 20 can be optional header, extra bytes FILHSZ-20 because
  70. # do not rely on sizeof(FILHDR) to give the correct size for header.
  71. # or first section header
  72. # additional variables for other COFF files
  73. # >20 beshort 0407 (impure)
  74. # >20 beshort 0410 (pure)
  75. # >20 beshort 0413 (demand paged)
  76. # >20 beshort 0421 (standalone)
  77. # >22 leshort >0 - version %d
  78. # >168 string .lowmem Apple toolbox