From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM: prevent misaligned array inits
Date: Thu, 4 Oct 2012 22:22:41 +0200 [thread overview]
Message-ID: <20121004222241.353d1c58@lilith> (raw)
In-Reply-To: <506BE945.3060709@omicron.at>
Hi Mark,
On Wed, 3 Oct 2012 09:29:09 +0200, Mark Marshall
<mark.marshall@omicron.at> wrote:
> I've just had a quick look at this in passing, but at least some of
> these changes seem wrong to me. For example, the code in
> board/ti/omap2420h4/sys_info.c :: display_board_info
> should be:
>
> void display_board_info(u32 btype)
> {
> static const char cpu_2420[] = "2420"; /* cpu type */
> static const char cpu_2422[] = "2422";
> static const char cpu_2423[] = "2423";
> static const char db_men[] = "Menelaus"; /* board type */
> static const char db_ip[] = "IP";
> static const char mem_sdr[] = "mSDR"; /* memory type */
> static const char mem_ddr[] = "mDDR";
> static const char t_tst[] = "TST"; /* security level */
> static const char t_emu[] = "EMU";
> static const char t_hs[] = "HS";
> static const char t_gp[] = "GP";
> static const char unk[] = "?";
>
> const char *cpu_s, *db_s, *mem_s, *sec_s;
> u32 cpu, rev, sec;
>
> This produces smaller code and is probably what the original
> author wanted the compiler to do. I've only compile tested
> this, not actually run it.
>
> Original file:
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 000004b4 00000000 00000000 00000034 2**2
> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
> 1 .data 00000000 00000000 00000000 000004e8 2**0
> CONTENTS, ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 000004e8 2**0
> ALLOC
> 3 .rodata.str1.1 00000072 00000000 00000000 000004e8 2**0
> CONTENTS, ALLOC, LOAD, READONLY, DATA
>
> After my changes:
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 000003ac 00000000 00000000 00000034 2**2
> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
> 1 .data 00000000 00000000 00000000 000003e0 2**0
> CONTENTS, ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 000003e0 2**0
> ALLOC
> 3 .rodata 00000048 00000000 00000000 000003e0 2**2
> CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
> 4 .rodata.str1.1 00000047 00000000 00000000 00000428 2**0
> CONTENTS, ALLOC, LOAD, READONLY, DATA
>
Thanks Mike. Indeed, there is a range of choices to replace the
original local char arrays: global arrays, static local arrays,
char pointers, const char pointers, or even direct strings in code. I'd
originally gone for const chars because the idea was not optimizing but
getting rid of a compiler issue, however, with my toolchain, this led
to warnings about losing the const qualifier, so I went to simple char*.
I'll recheck with (const) static char[] and chose whetever gets the
best score.
> Regards,
>
> Mark Marshall.
Amicalement,
--
Albert.
next prev parent reply other threads:[~2012-10-04 20:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-02 18:46 [U-Boot] [RFC] ARM: prevent misaligned array inits Albert ARIBAUD
2012-10-02 19:13 ` Joakim Tjernlund
2012-10-02 20:05 ` Albert ARIBAUD
2012-10-03 8:22 ` Joakim Tjernlund
2012-10-02 20:06 ` Stephen Warren
2012-10-02 21:20 ` Albert ARIBAUD
2012-10-02 21:42 ` Måns Rullgård
2012-10-03 7:29 ` Mark Marshall
2012-10-04 20:22 ` Albert ARIBAUD [this message]
2012-10-04 12:02 ` Thierry Reding
2012-10-04 19:10 ` Lucas Stach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121004222241.353d1c58@lilith \
--to=albert.u.boot@aribaud.net \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox