| |||||
Technical Support Support Resources
Product Information | BL51: ERROR L107 (ADDRESS SPACE OVERFLOW) FOR ?STACKInformation in this article applies to:
SYMPTOMSI've created a program that has an absolute IDATA variable located at 0xFE in internal memory.
idata unsigned int xxx _at_ 0xFE;
void main (void)
{
xxx = 1234;
while (1);
}
My program compiles OK, but when I link it, I receive the following linker error messages:
*** ERROR L107: ADDRESS SPACE OVERFLOW
SPACE: IDATA
SEGMENT: ?STACK
LENGTH: 0001H
*** ERROR L107: ADDRESS SPACE OVERFLOW
SPACE: IDATA
SEGMENT: ?STACK
LENGTH: 0001H
*** ERROR L119: REFERENCE MADE TO ERRONEOUS SEGMENT
SEGMENT: ?C_C51STARTUP
MODULE: C:\KEIL\C51\LIB\C51S.LIB (?C_STARTUP)
ADDRESS: 000BH
What's wrong with my program? CAUSEBy default, the linker locates IDATA segments starting with the segments other than the ?STACK segment. When you declare IDATA variables, you typically want them to be located in memory at lower addresses than the stack (since the stack grows up). The linker tries to locate IDATA segments this way for you. Since your IDATA variable (xxx) is located at 0xFE-0xFF, the is no space after it for the stack and the linker emits the errors you received. This is shown in the map file:
TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
0008H 00F6H *** GAP ***
IDATA 00FEH 0002H ABSOLUTE
Note that there is no stack located in the IDATA memory area. RESOLUTIONTo solve this problem, you must manualy specify the order in which the IDATA segments (like ?STACK) are located. In you example, you may specify the ?STACK segment in the IDATA linker command. For example: BL51 test.obj IDATA(?STACK) This instructs the linker allocate memory for the IDATA segments starting with the ?STACK segment. If you have other IDATA segments that should be located before ?STACK, you may specify them as follows: BL51 test.obj IDATA(?ID?VAR1,?ID?VAR2,?STACK) The following map file shows the result of this linker directive:
TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
IDATA 0008H 0001H UNIT ?STACK
0009H 00F5H *** GAP ***
IDATA 00FEH 0002H ABSOLUTE
Note that the ?STACK directive is located in the first available space in the IDATA memory and that the xxx variable (which is an absolute segment) is located at 0xFE. MORE INFORMATION
SEE ALSO
FORUM THREADSThe following Discussion Forum threads may provide information related to this topic. Last Reviewed: Tuesday, July 19, 2005 | ||||
| |||||