I want to embed a binary file into a VB rom, and access its data through a pointer in the c source code. So I made a linkable object of the file with ld like so:
$ v810-ld -r -b binary -o myfile.o myfile.bin
Inspecting the results using objdump shows this:
$ v810-objdump -x myfile.o
myfile.o: file format elf32-v810
myfile.o
architecture: v810, flags 0x00000010:
HAS_SYMS
start address 0x00000000
private flags = 0: v810 architecture
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 000031de 05000000 05000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
05000000 l d .data 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
000031de g *ABS* 00000000 _binary_myfile_bin_size
05000000 g .data 00000000 _binary_myfile_bin_start
070003ff g *ABS* 00000000 __vbvectors_end
050031de g *ABS* 00000000 __data_end
000003ff g *ABS* 00000000 v
050031de g .data 00000000 _binary_myfile_bin_end
070001e0 g *ABS* 00000000 __vbvectors_lma
05000000 g *ABS* 00000000 __data_vma
00000000 g *ABS* 00000000 __data_lma
07000000 g *ABS* 00000000 __text_vma
Then I declare and use the variable in the c source using the symbol names from the object file:
The problem is I’m getting a compiler error saying undefined reference to ‘_binary_myfile_bin_start’. So I guess I’m not linking the object file correctly…
How can I make it so the data isn’t loaded into ram? I want it to stay in the rom and just have my pointer point to it there.
I’ve been trying to put it in the .rodata section of the object file, but the v810 version of objcopy is lacking the –rename-section switch for some reason…