If we want to specify a binary file to an absolute address, we can burn the binary file to FLASH by burner or load the file to the RAM. Today I will introduce a new easier solution to achieve this purpose, and it can tell programmer the size of binary at the same time.
It is hard for linker to link the binary file to elf, but it can handle the object files(*.o). So we can use the ld tool to translate binary files to object files(*.bin—>*.o) with below command:
nds32le-elf-ld.exe -r -b binary -o binary.o binary.bin Then we can use SaG to specify this binary.o to an absolute address:
FLASH 0x80000000 0x00100000
{
EXEC1 0x80000000 0x00100000
{
ADDR NEXT __bin_start
*binary.o (+RO,+RW)
ADDR __bin_end
}
}The header of the elf file:
Attachment:
header_file.png [ 20.56 KiB | Viewed 74859 times ]
And in the C code, we can invoke the start and end addresses and the size of the binary as follow:
extern unsigned char __bin_start, __bin_end;
unsigned int bin_size = &__bin_start - &__bin_end;End...