I have a question about the behavior of the linker script found in this question:
https://stackoverflow.com/a/55193198/2421349
To save you a click, the relavant portion is:
OUTPUT_ARCH(riscv)
MEMORY
{
/* qemu-system-risc64 virt machine */
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 128M
}
ENTRY(_start)
And in a later section:
PROVIDE (__executable_start = SEGMENT_START("text-segment", ORIGIN(RAM)));
. = SEGMENT_START("text-segment", ORIGIN(RAM)) + SIZEOF_HEADERS;
PROVIDE(__stack_top = ORIGIN(RAM) + LENGTH(RAM));
We set __executable_start
to begin at ORIGIN(RAM)
. Then we use the .
command to move the linker output location SIZEOF_HEADERS
bytes forward. And finally we set __stack_top = ORIGIN(RAM) + LENGTH(RAM)
.
Assuming the stack grows down towards ORIGIN(RAM)
, won't it eventually overwrite __executable_start
and whatever SIZEOF_HEADERS
is if the stack grows large enough?