Custom Linker Script Section
Hello,
I have a problem here with linker script modification. My MCU part number is PIC32MZ2048EFG100.
I have a large constant array in a file name res.c. The declaration of the constant is as follow:
const unsigned char res[] = {......}
The res[] array is the binary image of webpages generated by a third-party utility program.
Right now, i want to move the res[] to the program flash memory starting at 0x9D100000. I know the following declaration in res.c will work:
const unsigned char __attribute__((address(0x9D100000),keep)) res[]
However, this requires me to change the utility program which is written in C#. I want to do the changes in linker script instead. So instead of declaring the res[] with __attribute, i want to modify the linker script to place the res[] starting at 0x9D100000.
These are lines i have added to my linker script (app_mz.ld):
MEMORY
{
kseg1_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x480
kseg0_program_mem (rx) : ORIGIN = 0x9D000000 + 0x480, LENGTH = 0x100000 - 0x480
kseg0_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x0
webpage_bin_mem : ORIGIN = 0x9D100000, LENGTH = 0xFC000
app_setting_mem : ORIGIN = 0x9D1FC000, LENGTH = 0x4000
kseg0_data_mem (w!x) : ORIGIN = 0x80000000, LENGTH = 0x80000
sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
kseg2_ebi_data_mem : ORIGIN = 0xC0000000, LENGTH = 0x4000000
kseg2_sqi_data_mem : ORIGIN = 0xD0000000, LENGTH = 0x4000000
kseg3_ebi_data_mem : ORIGIN = 0xE0000000, LENGTH = 0x4000000
kseg3_sqi_data_mem : ORIGIN = 0xF0000000, LENGTH = 0x4000000
}
In the memory regions, i have added a webpage_bin_mem region starting at 0x9D100000.
And then in the SECTIONS i have added a new output section named web. And place the res.o in the webpage_bin_mem region.
.web:
{
res.o
} > webpage_bin_mem
When compiled, there were errors returned by the linker:
pic32m-ld.exe:app_mz.ld.00:202: syntax error
collect2.exe: error: ld returned 255 exit status
Can someone shed some light here what's my mistakes?
post edited by weehau - 2019/08/24 06:47:57