Quantcast
Viewing all articles
Browse latest Browse all 22077

Is there a way to force a variable to be placed at top of .bss section?

I am using GCC on a Cortex M0 from NXP.

I have a non-initialized buffer which needs to be placed at 512 byte boundary due to DMA access restrictions:

DMA_CH_DESCRIPTOR_T __attribute__ ((aligned (512))) Chip_DMA_Table[MAX_DMA_CHANNEL];

This will end up in .bss section, but of course, due to alignment, there will be some lost space before. I know that .bss starts (in my MCU) at 0x10000000 which is already 512 aligned.

So the big question is how can I force my buffer to be the first symbol in .bss ?

I already tried like this but it doesn't work

.bss : ALIGN(4){    _bss = .;    PROVIDE(__start_bss_RAM = .) ;    PROVIDE(__start_bss_SRAM = .) ;    drv_dma.o (.bss)     *(.bss*)    *(COMMON)    . = ALIGN(4) ;    _ebss = .;    PROVIDE(__end_bss_RAM = .) ;    PROVIDE(__end_bss_SRAM = .) ;    PROVIDE(end = .);} > SRAM AT> SRAM

Note: I can see several potential resolves:

  1. defining my own .bss_top for example, and modify my startup script to consider it as a separate .bss and initialize it.

  2. defining a separate section BEFORE actual .bss and initialize my buffer from code somewhere

memset(...)

But I said it's worth to ask, maybe there is a simple linker catch on this one.

Thank you,


Viewing all articles
Browse latest Browse all 22077

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>