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