bin2obj
is a tool that converts binary files into object files that can be directly linked by the linkers of C compilers in CodeWarrior.
% bin2obj BINARY_FILE OBJECT_FILE
[-b|--begin SYMBOL_BEGIN] [-e|--end SYMBOL_END]
[-C|--compatible] [-a|--align ALIGNMENT] [-r|--readonly] [-s|--section SECTION]
Converts the binary file specified by BINARY_FILE
into a linkable object format and outputs the file with the name OBJECT_FILE
. This tool operates the same way as the the BinToElf tool that comes with the CodeWarrior for NINTENDO DS package.
The -b
and -e
options specify symbols that enable the data in the binary file to be accessed from programs written in C and other languages. You can use the long names for the options, --begin
and --end
instead of -b
and -e
.
The name for the symbol at the start of the data region is specified using SYMBOL_BEGIN
. Similarly, the name for the symbol at the end of the data region (more specifically, the next address after the last data) is specified using SYMBOL_END
. The size of the binary region is calculated by subtracting the value of SYMBOL_BEGIN
from the value of SYMBOL_END
.
When specifying the symbol name, you can use the special keywords %f, %t, %b, and %e
. These keywords reference a portion of a binary file, as shown below for the file specified by BINARY_FILE
.
%f
or%t
- The portion of
BINARY_FILE
excluding the directory.%b
- The portion of
BINARY_FILE
excluding the directory and the file extension.%e
- The file extension of
BINARY_FILE
(excluding the dot)
When these options are not specified, the default values are %b_begin
for SYMBOL_BEGIN
and %b_end
for SYMBOL_END
.
The -C
option generates a symbol that is compatible with the BinToElf tool that is included in CodeWarrior for NINTENDO DS. You can use the long name --compatible
instead of -C
. The -C
option is equivalent to the following option specifications:
-b _binary_%f -e _binary_%f_end
The -a
option specifies the alignment value for the data block when the binary file is made into an object. You can use the long name --align
instead of -a
. The default value is 4.
When the -r
option is specified, the data block is handled as a read-only section (normally a .rodata
section.) You can use the long name --readonly
instead of -r
. If this option is not specified, the data block is treated as a readable/writable section (normally a .data
section).
The -s
option can be used to specify the data block section name. You can use the long name --section
for -s
. If this option is not specified, .rodata
is used as the name for a read-only data block and .data
gets used as the name for a readable/writable data block.
$NitroSDK/tools/bin/bin2obj.exe
The BinToElf tool in the CodeWarrior for NINTENDO DS package.
06/14/2005 Initial version.