#287 - notron - Sun Jan 05, 2003 11:11 pm
I am trying to link a pure binary file to a compiled C image using GCC (G++) and following the instructions from the FAQ at DEVRS/GBA.
quoting....................................................................................
5) *** Convert your data to .o (gcc object) file #2 ***
If you are using DevKitAdv, or crtls v1.2 or later, then you can use the following technique without needing to modify your lnkscript. Do the following:
objcopy -I binary -O elf32-little in_file out_file.all.rodata.ext
(Ignore the "architecture UNKNOWN" warning message.)
This will force the lnkscript to put all sections in this file into the .rodata (read-only data / ROM) section. To be able to access this data from your C code use the following:
typedef unsigned char u8;
extern const u8 _binary_outname_all_rodata_ext_start [ ];
(The symbols _binary_outname_all_rodata_ext_size & _binary_outname_all_rodata_ext_end are also available. However, the "size" symbol seems to be an address to a value rather than the value itself so you may need to do -> (u32)&_binary..._size )
endquoting...................................................................................
Everything works fine as far as actually causing the binary image to be appended to the rom image. But when I try to access the binary data using the predefined _binary_<outname>_all_rodata_<ext>_start[] construct, the linker always gives me an unresolved external reference.
It seems like the objcopy routine does not create the symbol in its symbol table using the method above.
Any help on resolving this would be much appreciated.
_________________
MysticX is The Defender
quoting....................................................................................
5) *** Convert your data to .o (gcc object) file #2 ***
If you are using DevKitAdv, or crtls v1.2 or later, then you can use the following technique without needing to modify your lnkscript. Do the following:
objcopy -I binary -O elf32-little in_file out_file.all.rodata.ext
(Ignore the "architecture UNKNOWN" warning message.)
This will force the lnkscript to put all sections in this file into the .rodata (read-only data / ROM) section. To be able to access this data from your C code use the following:
typedef unsigned char u8;
extern const u8 _binary_outname_all_rodata_ext_start [ ];
(The symbols _binary_outname_all_rodata_ext_size & _binary_outname_all_rodata_ext_end are also available. However, the "size" symbol seems to be an address to a value rather than the value itself so you may need to do -> (u32)&_binary..._size )
endquoting...................................................................................
Everything works fine as far as actually causing the binary image to be appended to the rom image. But when I try to access the binary data using the predefined _binary_<outname>_all_rodata_<ext>_start[] construct, the linker always gives me an unresolved external reference.
It seems like the objcopy routine does not create the symbol in its symbol table using the method above.
Any help on resolving this would be much appreciated.
_________________
MysticX is The Defender