Linker file fill unused memory

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Linker file fill unused memory

Postby egoncalves » Fri Jan 24, 2020 11:05 am

Hi

I would like to know how to fill unused memory areas using the linker file.
If my code ends up having like 300Kbytes I would like to fill the remaining area up to 512Kbytes with a pattern like 0xFF.
This serves the purpose of calculating the SHA of the whole 512Kbytes to find if any tampering has occurred.

I have inspected esp32.ld on ESPv3.3.1 and I don't find any section for code, only ram seems to be defined.
Usually the linker file contains a MEMORY section like this:

MEMORY {
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000000FF
m_text (RX) : ORIGIN = 0x00000100, LENGTH = 0x00020000-0x100
m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00004000
}

and then a fill of the m_text section can be provided.
Something like this:

.fill :
{
FILL(0xFF);
. = ORIGIN(m_text) + LENGTH(m_text) - 1;
___ROM_AT = .;
} > m_text

How can one achieve this with the ESP32?

thanks

Who is online

Users browsing this forum: No registered users and 224 guests