1# SPDX-License-Identifier: Apache-2.0
2#
3# - elfconvert  : Name of command for elf file conversion.
4#                 In this implementation `objcopy` is used
5#   elfconvert_formats            : Formats supported: ihex, srec, binary
6#   elfconvert_flag               : empty
7#   elfconvert_flag_final         : empty
8#   elfconvert_flag_strip_all     : -S
9#   elfconvert_flag_strip_debug   : -g
10#   elfconvert_flag_compress_debug_sections: --compress-debug-sections
11#   elfconvert_flag_intarget      : --input-target=
12#   elfconvert_flag_outtarget     : --output-target=
13#   elfconvert_flag_section_remove: --remove-section=
14#   elfconvert_flag_section_only  : --only-section=
15#   elfconvert_flag_section_rename: --rename-section;
16#   elfconvert_flag_gapfill       : --gap-fill;
17#                                   Note: The ';' will be transformed into an
18#                                   empty space when executed
19#   elfconvert_flag_srec_len      : --srec-len=
20#   elfconvert_flag_infile        : empty, objcopy doesn't take arguments for filenames
21#   elfconvert_flag_outfile       : empty, objcopy doesn't take arguments for filenames
22#
23
24# elfconvert to use for transforming an elf file into another format,
25# such as intel hex, s-rec, binary, etc.
26set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_OBJCOPY})
27
28# List of format the tool supports for converting, for example,
29# GNU tools uses objectcopy, which supports the following: ihex, srec, binary
30set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary)
31
32set_property(TARGET bintools PROPERTY elfconvert_flag "")
33set_property(TARGET bintools PROPERTY elfconvert_flag_final "")
34
35set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-S")
36set_property(TARGET bintools PROPERTY elfconvert_flag_strip_debug "-g")
37
38set_property(TARGET bintools PROPERTY elfconvert_flag_compress_debug_sections "--compress-debug-sections")
39
40set_property(TARGET bintools PROPERTY elfconvert_flag_intarget "--input-target=")
41set_property(TARGET bintools PROPERTY elfconvert_flag_outtarget "--output-target=")
42
43set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "--remove-section=")
44set_property(TARGET bintools PROPERTY elfconvert_flag_section_only "--only-section=")
45set_property(TARGET bintools PROPERTY elfconvert_flag_section_rename "--rename-section;")
46
47set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;")
48
49# Note, placing a ';' at the end results in the following param  to be a list,
50# and hence space separated.
51# Thus the command line argument becomes:
52# `--gap-file <value>` instead of `--gap-fill<value>` (The latter would result in an error)
53set_property(TARGET bintools PROPERTY elfconvert_flag_gapfill "--gap-fill;")
54set_property(TARGET bintools PROPERTY elfconvert_flag_srec_len "--srec-len=")
55
56set_property(TARGET bintools PROPERTY elfconvert_flag_infile "")
57set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "")
58
59#
60# - disassembly : Name of command for disassembly of files
61#                 In this implementation `objdump` is used
62#   disassembly_flag               : -d
63#   disassembly_flag_final         : empty
64#   disassembly_flag_inline_source : -S
65#   disassembly_flag_all           : -SDz
66#   disassembly_flag_infile        : empty, objdump doesn't take arguments for filenames
67#   disassembly_flag_outfile       : '>', objdump doesn't take arguments for output file, but result is printed to standard out, and is redirected.
68
69set_property(TARGET bintools PROPERTY disassembly_command ${CMAKE_OBJDUMP})
70set_property(TARGET bintools PROPERTY disassembly_flag -d)
71set_property(TARGET bintools PROPERTY disassembly_flag_final "")
72set_property(TARGET bintools PROPERTY disassembly_flag_inline_source -S)
73set_property(TARGET bintools PROPERTY disassembly_flag_all -SDz)
74
75set_property(TARGET bintools PROPERTY disassembly_flag_infile "")
76set_property(TARGET bintools PROPERTY disassembly_flag_outfile ">;" )
77
78#
79# - strip: Name of command for stripping symbols
80#          In this implementation `strip` is used
81#   strip_flag         : empty
82#   strip_flag_final   : empty
83#   strip_flag_all     : --strip-all
84#   strip_flag_debug   : --strip-debug
85#   strip_flag_dwo     : --strip-dwo
86#   strip_flag_infile  : empty, strip doesn't take arguments for input file
87#   strip_flag_outfile : -o
88
89# This is using strip from bintools.
90set_property(TARGET bintools PROPERTY strip_command ${CMAKE_STRIP})
91
92# Any flag the strip command requires for processing
93set_property(TARGET bintools PROPERTY strip_flag "")
94set_property(TARGET bintools PROPERTY strip_flag_final "")
95
96set_property(TARGET bintools PROPERTY strip_flag_all --strip-all)
97set_property(TARGET bintools PROPERTY strip_flag_debug --strip-debug)
98set_property(TARGET bintools PROPERTY strip_flag_dwo --strip-dwo)
99set_property(TARGET bintools PROPERTY strip_flag_remove_section -R )
100
101set_property(TARGET bintools PROPERTY strip_flag_infile "")
102set_property(TARGET bintools PROPERTY strip_flag_outfile -o )
103
104#
105# - readelf : Name of command for reading elf files.
106#             In this implementation `readelf` is used
107#   readelf_flag          : empty
108#   readelf_flag_final    : empty
109#   readelf_flag_headers  : -e
110#   readelf_flag_infile   : empty, readelf doesn't take arguments for filenames
111#   readelf_flag_outfile  : '>', readelf doesn't take arguments for output
112#                           file, but result is printed to standard out, and
113#                           is redirected.
114
115# This is using readelf from bintools.
116set_property(TARGET bintools PROPERTY readelf_command ${CMAKE_READELF})
117
118set_property(TARGET bintools PROPERTY readelf_flag "")
119set_property(TARGET bintools PROPERTY readelf_flag_final "")
120set_property(TARGET bintools PROPERTY readelf_flag_headers -e)
121
122set_property(TARGET bintools PROPERTY readelf_flag_infile "")
123set_property(TARGET bintools PROPERTY readelf_flag_outfile ">;" )
124
125# Example on how to support dwarfdump instead of readelf
126#set_property(TARGET bintools PROPERTY readelf_command dwarfdump)
127#set_property(TARGET bintools PROPERTY readelf_flag "")
128#set_property(TARGET bintools PROPERTY readelf_flag_headers -E)
129#set_property(TARGET bintools PROPERTY readelf_flag_infile "")
130#set_property(TARGET bintools PROPERTY readelf_flag_outfile "-O file=" )
131
132
133set_property(TARGET bintools PROPERTY symbols_command ${CMAKE_NM})
134set_property(TARGET bintools PROPERTY symbols_flag "")
135set_property(TARGET bintools PROPERTY symbols_final "")
136set_property(TARGET bintools PROPERTY symbols_infile "")
137set_property(TARGET bintools PROPERTY symbols_outfile ">;" )
138