This patch reduces the stack usage by declaring 'const' stack variables as 'static const' so they end up in the .rodata section instead of being copied from there to the stack for every invocation of the corresponding function. As a plus we end up in having a smaller binary as the "copy from .rodata to stack" code isn't emitted by the compiler any more (roughly -100 bytes).
Signed-off-by: Mathias Krause mathias.krause@secunet.com
Il giorno mer, 05/01/2011 alle 13.03 +0100, Mathias Krause ha scritto:
static const char *speed_names[4] = {
I'd suggest using "static const char *const" at least (for PIE builds), or convert some of those to complete arrays.
On 07.01.2011 20:12, Diego Elio Pettenò wrote:
Il giorno mer, 05/01/2011 alle 13.03 +0100, Mathias Krause ha scritto:
static const char *speed_names[4] = {
I'd suggest using "static const char *const" at least (for PIE builds), or convert some of those to complete arrays.
I don't know how PIE may interference with this - it shouldn't matter if the array is writable or not - but you're right, the array should be marked const, too. Even though the compiler seems to be clever enough to notice no writes to the array are made and puts it into the .rodata section, too. Nevertheless, to be correct also on the source level, attached is a new version of the patch.
Thanks, for the review!
Kind regards, Mathias
* Mathias Krause mathias.krause@secunet.com [110105 13:03]:
This patch reduces the stack usage by declaring 'const' stack variables as 'static const' so they end up in the .rodata section instead of being copied from there to the stack for every invocation of the corresponding function. As a plus we end up in having a smaller binary as the "copy from .rodata to stack" code isn't emitted by the compiler any more (roughly -100 bytes).
Signed-off-by: Mathias Krause mathias.krause@secunet.com
Acked-by: Stefan Reinauer stepan@coreboot.org
On 14.01.2011 22:07, Stefan Reinauer wrote:
- Mathias Krause mathias.krause@secunet.com [110105 13:03]:
This patch reduces the stack usage by declaring 'const' stack variables as 'static const' so they end up in the .rodata section instead of being copied from there to the stack for every invocation of the corresponding function. As a plus we end up in having a smaller binary as the "copy from .rodata to stack" code isn't emitted by the compiler any more (roughly -100 bytes).
Signed-off-by: Mathias Krause mathias.krause@secunet.com
Acked-by: Stefan Reinauer stepan@coreboot.org
Thanks, committed as r1252.