This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F6775A: overflow

Part Number: MSP430F6775A


Tool/software:

Hi,

I have created a global buffer with numer of char elements 127. I have tried to full it with 128 bytes of data. I was expecting buffer overflow but instead it did not happen till I did not shrink the buffer more to 126 elements. IS it limited to make those changes per two bytes in a memory or so? I would like to know more about this behavior.

Thank you for your response.

  • How do you tell that it didn't overflow? My guess is that it did overflow but your code didn't notice.

    Global variables aren't necessarily allocated right next to each other -- there are often alignment padding bytes in between.

    [Edit: Minor clarification]

  • Well I have used the ccs memory browser and I set brakepoint after the function call. I have noticed that there was a name of my variable and than all the data. That is how I have noticed the changes. I understand that there might be the padding byte but they are not shown in the memory browser? I mean when I set the size about two up I can see two cells which were initialized to 00 00. But when I will decrement by one than both will disappear. That's why I am asking cuz in some types of memory they can I can write in words not in bytes. And also I have been writing that data to the flash so.

  • I think the padding byte would be also in the flash or not ? Cuz I have been writing to the flash 71 bytes and the buffer was just to 70. And I did not noticed any extra byte.  

  • What should be the value of the padding byte ?

  • I think the content of the pad byte(s) is not specified,  but it's usually 0x00. You would see it in the Memory Browser.

    If you wrote 71 bytes (out of a possible 70) to flash, the final byte would be whatever follows your buffer in memory, which might be the following variable or a pad byte. You can find out from your .map file.

  • Okay, thank you I think I can see  the padding can be also modified by the #pragma_align. I have noticed the 0x00 when I have modified the value in it. I would like to ask, what is the default value? Because I did not put the pragma into example above but still it was aligned somehow. I also can see the length in the .map file for uninitialized variable as you mentioned above and it is changing always only when the size is even when is the size of an array odd the value stays bigger by one filled by the 0x00 as mentioned. So can I assume that default alignment is two? 

  • The pad byte(s) depend on the alignment of the subsequent variable. This described in the CC User Guide (SLAU132Y); search for "alignment", since there are a few different tables.

    The linker may also insert alignment padding between sections.

  • Thanks for Bruce's clarification.

    Hi Peter,

    I will temporarily close the thread, feel free to reply the thread if there has other issue.

    B.R.

    Sal

**Attention** This is a public forum