Part Number: TMS320F28335
Tool/software: TI C/C++ Compiler
Hello,
After calling the user-defined function from the main function, the array declared in the called function exists in the ebss area, not the stack area.
Why do these cases exist?
MEMORY
{
/* Program Memory. */
PAGE 0:
BEGIN : origin = 0x000000, length = 0x000002
RAMM0 : origin = 0x000050, length = 0x0003B0
RAMLP : origin = 0x008000, length = 0x005000
CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when ... */
/* ... CSM is in use. */
CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
ADC_CAL : origin = 0x380080, length = 0x000009
BOOTROM : origin = 0x3FF27C, length = 0x000D44
VECTORS : origin = 0x3FFFC0, length = 0x000040
/* Data Memory. */
PAGE 1 :
BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack. */
RAMM1 : origin = 0x000400, length = 0x000400
PIE_VRAM : origin = 0x000D00, length = 0x000100
RAMLD : origin = 0x00D000, length = 0x001000
RAMLE : origin = 0x00E000, length = 0x001000
RAMLF : origin = 0x00F000, length = 0x001000
}
SECTIONS
{
/* Program sections. */
ram_start : > BEGIN, PAGE = 0 /* codestart branches to c_int00(). */
ramfuncs : > RAMLP, PAGE = 0
.text : > RAMLP, PAGE = 0
.cinit : > RAMLP, PAGE = 0
.pinit : > RAMLP, PAGE = 0
.switch : > RAMLP, PAGE = 0
/* Default reset handler. Not used. */
.reset : > VECTORS, PAGE = 0, TYPE = DSECT
/* Data sections. */
.stack : > RAMM1, PAGE = 1
pie_vram : > PIE_VRAM, PAGE = 1
.ebss : > RAMLD, PAGE = 1 /* Global and static variable */
.econst : > RAMLE, PAGE = 1 /* Constant data */
.esysmem : > RAMLF, PAGE = 1 /* Memory for malloc type functions */
/* 128-bit CSM Password. Not used. */
csm_rsvd : > CSM_RSVD, PAGE = 0, TYPE = DSECT
csmpasswds : > CSM_PWL, PAGE = 0, TYPE = DSECT
/* ADC Calibration. */
.adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
}
And, my sample code is
void stack_overflow()
{
char overflowable[10]="BBBBBBBBBB";
int len2=100;
int i;
char *buff2;
buff2 = &overflowable;
char s2[100] = {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"};
memcpy(overflowable, s2, len2);
for(i=0; i<100; i++){
printf("%s", buff2[i]);
}
}
please refer to the attached photo for the address and data confirmed through the Memory Browser.
char overflowable[10] array's address id 0xD44C.
Thanks, Regards
Han