This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
How to pad a section to an aligned size in the linker script file
- From: "R. Diez" <rdiezmail-binutils at yahoo dot de>
- To: binutils at sourceware dot org
- Date: Thu, 14 Jul 2011 12:38:13 +0100 (BST)
- Subject: How to pad a section to an aligned size in the linker script file
- Reply-to: rdiezmail-binutils at yahoo dot de
Hi there:
I have some PowerPC assembly code in crt0.asm that zeroes sections .bss and .sbss before calling main(). I copied that piece of code from somewhere else, and it can only fill 32-bit aligned sizes, as it writes 32-bit words at a time. At the beginning, it just divides the size by 4, so it may miss up to 3 bytes at the end.
I have seen in the map file that the size of my .bss/.sbss section is not always a multiple of 4. I then tried to add 32 bits worth of padding at the end with LONG(0), so that the important content always get zeroed. That portion in the linker script file looks like this:
.sbss :
{
*(.sbss)
*(.sbss.*)
LONG(0)
} >ram
.bss :
{
*(.bss)
*(.bss.*)
LONG(0)
} >ram
However, I'm getting these linker warnings:
powerpc-unknown-eabi/bin/ld: warning: section `.sbss' type changed to PROGBITS
powerpc-unknown-eabi/bin/ld: warning: section `.bss' type changed to PROGBITS
As far as I can see, there are 2 ways to solve this:
1) Instead of LONG(0), use some directive to reserve the space, but not fill it. I haven't found which directive could do that though.
2) Convince the linker that the section size should grow if necessary to be a multiple of 4. I haven't found a way to achieve that yet.
Can anybody help?
Please copy me on the answer, as I'm not subscribed to this list.
Thanks in advance,
R. Diez