bintools_template.cmake 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # This template file can be used as a starting point for implementing support
  2. # for additional tools for reading and/or conversion of elf files.
  3. #
  4. # Although GNU bintools is used as name, then the template can be used to
  5. # support other tools.
  6. #
  7. # Overview of bintools used commands:
  8. # - memusage : Tool for reporting target memory usage
  9. # (if linker support memusage reporting leave this property empty)
  10. # - disassembly : Tool for disassemble the target
  11. # - elfconvert : Tool for converting from elf into another format.
  12. # - readelf : Tool for elf file processing
  13. # - strip : Tool for symnbol stripping
  14. #
  15. # Each tool will have the following minimum properties:
  16. # - <tool>_command : Name of executable to call
  17. # - <tool>_flag : Flags that must always be used with this command
  18. # - <tool>_flag_infile : Flag to use when specifying the file to process
  19. # - <tool>_flag_outfile : Flag to use to specify the result of the processing.
  20. #
  21. # each tool might require more flags depending on its use, as example:
  22. # - elfconvert_flag_section_remove : Flag to use when specifying sections to remove
  23. # - readelf_flags_headers : Flag to use to specify headers should be displayed
  24. #
  25. # If a given tool / flag / feature is not supported, then keep the property empty.
  26. # As bintools_template.cmake default has empty flags, then it is sufficient to
  27. # only set those flags that a given set of tools support.
  28. #
  29. # Commands will default echo a message if called, but no command has been defined.
  30. # This is done, so that unexpected calls to non-implemented command can be easily detected.
  31. # To disable the message, simply silence the command with:
  32. # set_property(TARGET bintools PROPERTY <command>_command ${CMAKE_COMMAND} -E echo "")
  33. #
  34. # The bintools properties are made generic so that implementing support for an
  35. # additional native tool should be as easy as possible.
  36. # However, there might be tools and/or use cases where the current property
  37. # scheme does not cover the exact needs. For those use-cases it is possible
  38. # to implement the call to a native tool inside a CMake script.
  39. # For example, to call a custom script for elfconvert command, one can specify:
  40. # set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_COMMAND})
  41. # set_property(TARGET bintools PROPERTY elfconvert_flag "")
  42. # set_property(TARGET bintools PROPERTY elfconvert_flag_final -P custom_elfconvert.cmake)
  43. # set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-DSTRIP_ALL=True")
  44. # set_property(TARGET bintools PROPERTY elfconvert_flag_infile "-DINFILE=")
  45. # set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "-DOUT_FILE=")
  46. #
  47. #
  48. # bintools property overview of all commands:
  49. #
  50. # Command:
  51. # - memusage : Name of command to execute
  52. # Note: For gcc compilers this command is not used,
  53. # instead a linker flag is used for this)
  54. # memusage_flag : Flags that must always be applied when calling memusage command
  55. # memusage_flag_final : Flags that must always be applied last at the memusage command
  56. # memusage_flag_infile: Flag for specifying the input file
  57. # memusage_byproducts : Byproducts (files) generated when calling memusage
  58. #
  59. #
  60. # - elfconvert : Name of command for elf file conversion.
  61. # For GNU binary utilities this is objcopy
  62. # elfconvert_formats : Formats supported by this command.
  63. # elfconvert_flag : Flags that must always be applied when calling elfconvert command
  64. # elfconvert_flag_final : Flags that must always be applied last at the elfconvert command
  65. # elfconvert_flag_strip_all : Flag that is used for stripping all symbols when converting
  66. # elfconvert_flag_strip_debug : Flag that is used to strip debug symbols when converting
  67. # elfconvert_flag_intarget : Flag for specifying target used for infile
  68. # elfconvert_flag_outtarget : Flag for specifying target to use for converted file.
  69. # Target value must be one of those listed described by: elfconvert_formats
  70. # elfconvert_flag_section_remove: Flag for specifying that following section must be removed
  71. # elfconvert_flag_section_only : Flag for specifying that only the following section should be kept
  72. # elfconvert_flag_section_rename: Flag for specifying that following section must be renamed
  73. # elfconvert_flag_gapfill : Flag for specifying the value to fill in gaps between sections
  74. # elfconvert_flag_srec_len : Flag for specifying maximum length of Srecord values
  75. # elfconvert_flag_infile : Flag for specifying the input file
  76. # elfconvert_flag_outfile : Flag for specifying the output file
  77. # For tools that prints to standard out, this should be ">" to indicate redirection
  78. #
  79. #
  80. # - disassembly : Name of command for disassembly of files
  81. # For GNU binary utilities this is objdump
  82. # disassembly_flag : Flags that must always be applied when calling disassembly command
  83. # disassembly_flag_final : Flags that must always be applied last at the disassembly command
  84. # disassembly_flag_inline_source : Flag to use to display source code mixed with disassembly
  85. # disassembly_flag_all : Flag to use for disassemble everything, including zeroes
  86. # disassembly_flag_infile : Flag for specifying the input file
  87. # disassembly_flag_outfile : Flag for specifying the output file
  88. # For tools that prints to standard out, this should be ">" to indicate redirection
  89. #
  90. #
  91. # - readelf : Name of command for reading elf files.
  92. # For GNU binary utilities this is readelf
  93. # readelf_flag : Flags that must always be applied when calling readelf command
  94. # readelf_flag_final : Flags that must always be applied last at the readelf command
  95. # readelf_flag_headers : Flag to use for specifying ELF headers should be read
  96. # readelf_flag_infile : Flag for specifying the input file
  97. # readelf_flag_outfile : Flag for specifying the output file
  98. # For tools that prints to standard out, this should be ">" to indicate redirection
  99. #
  100. #
  101. # - strip: Name of command for stripping symbols
  102. # For GNU binary utilities this is strip
  103. # strip_flag : Flags that must always be applied when calling strip command
  104. # strip_flag_final : Flags that must always be applied last at the strip command
  105. # strip_flag_all : Flag for removing all symbols
  106. # strip_flag_debug : Flag for removing debug symbols
  107. # strip_flag_dwo : Flag for removing dwarf sections
  108. # strip_flag_infile : Flag for specifying the input file
  109. # strip_flag_outfile : Flag for specifying the output file
  110. set(COMMAND_NOT_SUPPORTED "command not supported on bintools: ")
  111. # If memusage is supported as post-build command, set memusage_type to: command
  112. # and this value to the command to execute in the form: <command> <arguments>
  113. # Note: If memusage is supported during linking, please use:
  114. # set_property(TARGET linker ... ) found in cmake/linker/linker_flags.cmake instead
  115. set_property(TARGET bintools PROPERTY memusage_command "")
  116. set_property(TARGET bintools PROPERTY memusage_flag "")
  117. set_property(TARGET bintools PROPERTY memusage_flag_final "")
  118. set_property(TARGET bintools PROPERTY memusage_byproducts "")
  119. # disassembly command to use for generation of list file.
  120. set_property(TARGET bintools PROPERTY disassembly_command ${CMAKE_COMMAND} -E echo "disassembly ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
  121. set_property(TARGET bintools PROPERTY disassembly_flag "")
  122. set_property(TARGET bintools PROPERTY disassembly_flag_final "")
  123. set_property(TARGET bintools PROPERTY disassembly_flag_inline_source "")
  124. set_property(TARGET bintools PROPERTY disassembly_flag_infile "")
  125. set_property(TARGET bintools PROPERTY disassembly_flag_outfile "")
  126. # elfconvert to use for transforming an elf file into another format, such as intel hex, s-rec, binary, etc.
  127. set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_COMMAND} -E echo "elfconvert ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
  128. set_property(TARGET bintools PROPERTY elfconvert_formats "")
  129. set_property(TARGET bintools PROPERTY elfconvert_flag "")
  130. set_property(TARGET bintools PROPERTY elfconvert_flag_final "")
  131. set_property(TARGET bintools PROPERTY elfconvert_flag_outtarget "")
  132. set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "")
  133. set_property(TARGET bintools PROPERTY elfconvert_flag_gapfill "")
  134. set_property(TARGET bintools PROPERTY elfconvert_flag_infile "")
  135. set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "")
  136. # readelf for processing of elf files.
  137. set_property(TARGET bintools PROPERTY readelf_command ${CMAKE_COMMAND} -E echo "readelf ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
  138. set_property(TARGET bintools PROPERTY readelf_flag "")
  139. set_property(TARGET bintools PROPERTY readelf_flag_final "")
  140. set_property(TARGET bintools PROPERTY readelf_flag_headers "")
  141. set_property(TARGET bintools PROPERTY readelf_flag_infile "")
  142. set_property(TARGET bintools PROPERTY readelf_flag_outfile "")
  143. # strip command for stripping symbols
  144. set_property(TARGET bintools PROPERTY strip_command ${CMAKE_COMMAND} -E echo "strip ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
  145. set_property(TARGET bintools PROPERTY strip_flag "")
  146. set_property(TARGET bintools PROPERTY strip_flag_final "")
  147. set_property(TARGET bintools PROPERTY strip_flag_all "")
  148. set_property(TARGET bintools PROPERTY strip_flag_debug "")
  149. set_property(TARGET bintools PROPERTY strip_flag_dwo "")
  150. set_property(TARGET bintools PROPERTY strip_flag_infile "")
  151. set_property(TARGET bintools PROPERTY strip_flag_outfile "")