问题
According to the GNU documentation for ld
, a NOLOAD
section works as following:
The `(NOLOAD)' directive will mark a section to not be loaded at run time. The linker will process the section normally, but will mark it so that a program loader will not load it into memory.
Now, regarding to the program loader, accordign to wikipedia:
Embedded systems typically do not have loaders, and instead, the code executes directly from ROM. In order to load the operating system itself, as part of booting, a specialized boot loader is used.
Then, what exactly a NOLOAD
section does for FW / embedded software?
回答1:
The NOLOAD
section defines a section that is required to link the program properly but must not be loaded to memory. For example you may need to link your program with some code located in ROM, so you tell the linker to mark the code in ROM as NOLOAD
. Then the tool that will load the program (a debugger, an OS or whatever) will not load this part of the code.
来源:https://stackoverflow.com/questions/57181652/understanding-linker-script-noload-sections-in-embedded-software