一、About fromELF
The fromELF utility translates Executable Linkable Format (ELF) image files produced by armlink into other formats suited to ROM tools and to loading directly into memory. You can also use it to display various information about an ELF object or to generate text files containing the information.
fromELF outputs the following image formats:
Plain binary format.
Motorola 32-bit S-record format.
Intel Hex-32 format.
Byte Oriented (Verilog Memory Model) Hex format.
ELF format. You can resave as ELF. For example, you can convert a -debug
ELF image to a -nodebug
ELF image).
fromELF can also display information about the input file, for example disassembly output or symbol listings, to either standard output or a text file.
Do not link your images with the -nodebug
linker option if you require a -fieldoffsets
fromELF step. If your image is produced without debug information:
fromELF cannot translate the image into other file formats
fromELF cannot produce a meaningful disassembly listing.
二、fromELF command-line options
The fromELF command syntax is as follows:
fromelf
[-help] [ -fieldoffsets [[-select select_options
]]] [-nolinkview] [-nodebug] [-vsn] [[text_output_format
] | code_output_format
] [-base n
] [memory_config
] [-
utputo
output_file
] {input_file
}
where:
-h
elp
This option shows help and usage information. If this option is specified, other command-line options are ignored. Calling fromELF without any parameters produces the same help information.
-fieldoffsets
This option produces, to standard output, a list of assembly language EQU
directives that equate C++ class or C structure field names to their offsets from the base of the class or structure. The input ELF file can be a relocatable object or an image.
Use -o
to redirect the output to a file. Use the INCLUDE
command from armasm to load the produced file and provide access to C++ classes and C structure members by name from assembly language. See the ADS Assembler Guide for more information on armasm.
If the source file does not have debug information, this option is not available. You cannot use this option together with a
.code_output_format
-fieldoffsets
outputs all structure information. To output a subset of the structures, use -select
. select_options
If you do not require a file that can be input to armasm, use the -text -a
option to format the display addresses in a more readable form. The -a
option only outputs address information for structures and static data in images because the addresses are not known in a relocatable object.
-select select_options
Use -select
together with either the select_option
-fieldoffsets
or -text -a
options to select only those fields that match the patterns in the option list.
Use special characters to select multiple fields:
Join options in the list together with a ,
as in: a*,b*,c*
.
The wildcard character *
can be used to match any name.
The wildcard character ?
can be used to match any single letter.
Specify the fields to include by prefixing a +
to the select_option
string. This is the default.
Specify the fields to exclude by prefixing a ~
to the select_option
string.
If you are using a special character on Unix, you must enclose the options in quotes to prevent the shell expanding the selection.
-nolinkview
Use -nolinkview
to discard the section-level view (link-time view) from the ELF image and retain only the segment level view (load-time view). Discarding the link-view section level eliminates:
the section header table
the section header string table
the string table
the symbol table
all debug sections.
All that is left in the output is the program header table and the program segments. According to the ELF specification, these are all that a program loader can rely upon being present in an ELF file.
This option can have unexpected effects if -elf
is not specified on the command line. See Example 7.2 for an example of correct usage.
-nodebug
This option does not put debug information in the output files. This is the default for binary images. If -nodebug
is specified, it affects all output formats. It overrides the -text -g
option.
This option can have unexpected effects if -elf
is not specified on the command line. The options in Example 7.1 produce a text file because no output format has been specified.
Example 7.1. Text output
fromelf -nodebug image -o image_nodb.asf
To get ELF format output use the options shown in Example 7.2
Example 7.2. ELF output
fromelf -elf -nodebug image.axf -o image_ndb.axf
-vsn
This option displays fromELF version information.
text_output_format
Use a text specification, for example -text -c
, to display image information in text format. You can decode an ELF image or ELF object file using this option. This is the default. If no text or code output format is specified, -text
is assumed.
If
is not specified with the output_file
-o
option, the information is displayed on stdout.
If a specific text category is not specified, the default is to output header information.
If specified, the text category consists of one or more of the following:
a
Prints the global and static data addresses (including addresses for structure and union contents). This option can only be used on files containing debug information. Use the -select
option to output a subset of the data addresses.
c
Disassembles code
d
Prints contents of the data sections
g
Prints debug information
r
Prints relocation information
s
Prints the symbol table
t
Prints the string table(s)
v
Prints detailed information on each segment and section header of the image
z
Prints the code and data sizes.
The category selectors can be specified as one of:
individual options, -text -c -d
a single concatenated string, -text -cd
category selectors only, -c -d
multiple characters following a slash character, -text/cd.
If an output format is not specified, the default output format of -text
is used and the individual category selectors are recognized. If another output format is specified, the selectors are ignored.
code_output_format
This option selects the binary or ELF output file options.
can be one of:code_output_format
-bin
Plain binary. You can split output from this option into multiple files with the
option.memory_config
-ihf
Extended Intellec Hex format. You can specify the base address of the output with the -base
option. (This option is deprecated and will be removed from future versions of the product.)
-m32
Motorola 32-bit format (32-bit S-records). You can specify the base address of the output with the -base
option.
-i32
Intel Hex-32 format. You can specify the base address of the output with the -base
option.
-vhx
Byte Oriented (Verilog Memory Model) Hex format. This format is suitable for loading into the memory models of HDL simulators. You can split output from this option into multiple files with the
option.memory_config
-elf
ELF format (resaves as ELF). This can be used to convert a debug ELF image into a no-debug ELF image.
If you use fromELF to convert an ELF image containing multiple load regions to a binary format using any of the -bin
, -ihf
, -m32
, -i32
, or -vhx
options, fromELF creates an output directory named
and generates one binary output file for each load region in the input image. fromELF places the output files in the output_file
directory.output_file
ELF images contain multiple load regions if, for example, they are built with a scatter-load description file that defines more than one load region.
-base n
This option specifies the base address of the output for Motorola S-record, Intel Hex, and Extended Intellec Hex file formats. This option is available only if -m32
, -i32
, or -ihf
is specified as the output format.
You can specify the base address as either:
a decimal value, for example -base 0
as a hexadecimal value, for example -base 0x8000.
All addresses encoded in the output file start at the base address
. If you do not specify a n
-base
option, the base address is taken from the load region address.
If multiple load regions are present, the -base
value is used for each output file. That is, it overrides all load region addresses.
memory_config
This option outputs multiple files for multiple memory banks. This option is available only if -vhx
or -bin
is specified as the output format.
The format of
ismemory_config
-
where:width
xbanks
width
is the width of memory in the target memory system (8-bit, 16-bit, 32-bit, or 64-bit).
banks
specifies the number of memory banks in the target memory system.
Valid configurations are:
-8x1
-8x2
-8x4
-16x1
-16x2
-32x1
-32x2
-64x1
fromELF uses the last specified configuration if more than one configuration is specified. If this option is selected for any format other than -bin
or -vhx
it is ignored.
If the image has one load region, fromELF generates
files with the following naming conventions: bank
If there is one memory bank (
is 1) the output file is named by the banks
-o
argument.output_file
If there are multiple memory banks (bank>1), fromELF generates
number of files starting with banks
and finishing with output_file
0
. For example:output_file bank
-1
fromelf -vhx -8x2 test.axf -o test
generates two files named test0
and test1
.
If the image has multiple load regions, fromELF creates a directory named
and generates bank files for each load region named output_file
to load region
0
.load region banks-1
The memory width specified by
controls the size of the chunk of information read from the image and written to a file. The first chunk read is allocated to the first file (width
), the next chunk is allocated to the next file. After a chunk is allocated to the last file, allocation begins again with the first file (that is, the allocation is modulo based on the number of files). For example:output_file
0
For a
of memory_config
-8x4
byte0 -> file0
byte1 -> file1
byte2 -> file2
byte3 -> file3
byte4 -> file0
...
For a
of memory_config
-16x2
halfword0 -> file0
halfword1 -> file1
halfword3 -> file0
...
-o
utput output_file
This option specifies the name of the output file, or the name of the output directory if multiple output files are created (see the description of
and text_output_format
for more information). Specifying the output file is optional with the code_output_format
-text
output option and mandatory with all other outputs.
input_file
This option specifies the ELF file to be translated.
fromELF accepts only ARM-executable ELF files and ARM object ELF files (.o). If
is a scatter-loaded image that contains more than one load region and the output format is either input_file
-bin
, -ihf
, -m32
, -i32
, or -vhx
, fromELF creates a separate file for each load region.