Placing variables at specific address generates large binary file
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-08 3:24 AM
Posted on January 08, 2016 at 12:24
I have to place some variables at specific address in memory. I'm using GCC.
I declare and use variable like this:uint8_t __attribute__((section (''.mySection''))) buffer = 5;
int main()
{
buffer = 10;
}
And in linker script I've got:
MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 145K MYSEC (xrw) : ORIGIN = 0x20025000, LENGTH = 155K }
and later:
.mySection : { *(.mySection); } > MYSEC
Normally my program takes 22 KB, with this modification it takes 384 MB (!).
I don't understand why. If I remove
__attribute__
it takes 22 KB again. What am I missing?
#memory-sections-ram-linker
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-08 4:10 AM
Posted on January 08, 2016 at 13:10
I don't understand why.
Likely because the RAM section gets correctly managed in the FLASH load region, and MYSEC does not. The .BIN isn't going to be able to represent sparse data, and unless you define MYSEC as uninitialized, or add start up code to unpack it from FLASH, none of this is going to work on a stand alone boot up of the system.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-08 6:17 AM
Posted on January 08, 2016 at 15:17 Your section is in RAM, then add NOLOAD operator for this section. Then it will not goes to output files (HEX & BIN).
