Hi,
I have an linker error for the following, after I inserted in the prm file .init and assigned it to the ROM segment.
The error is: ".init appears twice in PLACEMENT block".
I thought in the prm file .init only appears once.
Can anybody explain why?
/* This is a linker parameter file for the mc9s08jm32 */NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */ Z_RAM = READ_WRITE 0x00B0 TO 0x00FF; RAM = READ_WRITE 0x0100 TO 0x08AF; RAM1 = READ_WRITE 0x1860 TO 0x195F; ROM = READ_ONLY 0x8000 TO 0xFFAD; ROM1 = READ_ONLY 0xFFC0 TO 0xFFC3; /* INTVECTS = READ_ONLY 0xFFC4 TO 0xFFFF; Reserved for Interrupt Vectors */ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */ DEFAULT_RAM /* non-zero page variables */ INTO RAM,RAM1; .init, SP_section, _PRESTART, /* startup code */ STARTUP, /* startup data structures */ ROM_VAR, /* constant variables */ STRINGS, /* string literals */ VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */ DEFAULT_ROM, COPY /* copy down information: how to initialize variables */ INTO ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */ _DATA_ZEROPAGE, /* zero page variables */ MY_ZEROPAGE INTO Z_RAM;ENDSTACKSIZE 0x50VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
解決済! 解決策の投稿を見る。
You can write something like this in your C code:
extern int __SEG_SIZE_SSTACK[];
void foo(void) {
unsigned int stackSize = (unsigned int)__SEG_SIZE_SSTACK;
/* ... */
}
The linker manual contains some more details on this.
_PRESTART is an alias for .init. There are more of these aliases (SSTACK, ROM_VAR, etc). There is a list in the linker manual, and you will find there also the reason why the aliases exist at all: allowing the section names to be referenced from C code (for instance with __SEG_START/__SEG_SIZE/__SEG_END).
Hi,
What do you mean by "allowing the section names to be referenced from C code"?
Would you please illustrate with a simple example? Thanks in advance...
You can write something like this in your C code:
extern int __SEG_SIZE_SSTACK[];
void foo(void) {
unsigned int stackSize = (unsigned int)__SEG_SIZE_SSTACK;
/* ... */
}
The linker manual contains some more details on this.