The gmemfile Utility Program reads a fully linked COFF or ELF executable and produces a binary image of the final executable as it would appear in memory. This binary image file is suitable for raw download to a target.
gmemfile [options] executable_file
executable_file is the name of the COFF or ELF executable from which you wish to generate a download image.
Display information about all options.
Specifies the output filename. If this option is not given, the output will be written to a filename similiar to the executable_file, with the suffix ".bin" added (or substituted if executable_file includes a "." suffix already). For example, "foo" becomes "foo.bin", and "a.out" becomes "a.bin".
Use ELF section headers instead of ELF program headers. Applies only to ELF files.
Write trailing zero-filled sections (e.g., ".bss")
A segment identified by an ELF program header, which is allocated in the final executable image, but which contains no initialized data is defined by the ELF standard to contain all zeros. The actual clearing of this portion of memory must be performed by the loader, the operating system, or the executable's runtime (e.g., crt0). It is also legal for a segment to be partially initialized. The remaining uninitialized portion of a segment must likewise be filled in with zeros.
By default, trailing uninitialized segments are omitted from the binary image file generated by gmemfile. This can be a big savings in both download time and file size. However, if your application depends on these segments being zeroed, and no other facility will clear these segments for you (e.g., crt0 or your target operating system), you may specify the -z option to include trailing zeros in your binary image file.
For example, if your program image looks like this:
Then without -z, the output file will look like this:
read-only segment |
read-write segment |
And with -z, the output file will look like this:
read-only segment |
read-write segment |
uninitialized segment (all zeros) |
The same type of truncation will occur if the last segment is only partially initialized.