
Albert ARIBAUD albert.u.boot@aribaud.net wrote on 2012/10/02 22:05:40:
Hi Joakim,
On Tue, 2 Oct 2012 21:13:39 +0200, Joakim Tjernlund joakim.tjernlund@transmode.se wrote:
*********************************************************************/ void display_board_info(u32 btype) {
- char cpu_2420[] = "2420"; /* cpu type */
- char cpu_2422[] = "2422";
- char cpu_2423[] = "2423";
- char db_men[] = "Menelaus"; /* board type */
- char db_ip[] = "IP";
- char mem_sdr[] = "mSDR"; /* memory type */
- char mem_ddr[] = "mDDR";
- char t_tst[] = "TST"; /* security level */
- char t_emu[] = "EMU";
- char t_hs[] = "HS";
- char t_gp[] = "GP";
- char unk[] = "?";
- char *cpu_2420 = "2420"; /* cpu type */
- char *cpu_2422 = "2422";
- char *cpu_2423 = "2423";
- char *db_men = "Menelaus"; /* board type */
- char *db_ip = "IP";
- char *mem_sdr = "mSDR"; /* memory type */
- char *mem_ddr = "mDDR";
- char *t_tst = "TST"; /* security level */
- char *t_emu = "EMU";
- char *t_hs = "HS";
- char *t_gp = "GP";
- char *unk = "?";
hmm, on ppc I think this will cause relocation entries which will build size.
Jocke
Can you try it and post results with and without it? Sizes and if possible disassembly of the function for both cases.
Since you asked, I had to check :) Did this: #include <stdio.h> #ifdef NO_RELOC void display_board_info1(int btype) { char cpu_2420[] = "2420"; /* cpu type */ char cpu_2422[] = "2422"; char cpu_2423[] = "2423"; char db_men[] = "Menelaus"; /* board type */ char db_ip[] = "IP"; char mem_sdr[] = "mSDR"; /* memory type */ char mem_ddr[] = "mDDR"; char t_tst[] = "TST"; /* security level */ char t_emu[] = "EMU"; char t_hs[] = "HS"; char t_gp[] = "GP"; char unk[] = "?"; printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", cpu_2420, cpu_2422, cpu_2423, db_men, db_ip, mem_sdr, mem_ddr, t_tst, t_emu, t_hs, t_gp, unk); } #else void display_board_info2(int btype) { char *cpu_2420 = "2420"; /* cpu type */ char *cpu_2422 = "2422"; char *cpu_2423 = "2423"; char *db_men = "Menelaus"; /* board type */ char *db_ip = "IP"; char *mem_sdr = "mSDR"; /* memory type */ char *mem_ddr = "mDDR"; char *t_tst = "TST"; /* security level */ char *t_emu = "EMU"; char *t_hs = "HS"; char *t_gp = "GP"; char *unk = "?"; printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", cpu_2420, cpu_2422, cpu_2423, db_men, db_ip, mem_sdr, mem_ddr, t_tst, t_emu, t_hs, t_gp, unk); } #endif and built it with: powerpc-softfloat_4.5.3-linux-gnu-gcc -O2 -fpic -mrelocatable ppc-str-reloc.c -c -DNO_RELOC -o no_reloc.o
and
powerpc-softfloat_4.5.3-linux-gnu-gcc -O2 -fpic -mrelocatable ppc-str-reloc.c -c -o reloc.o
Result is: #> size reloc.o no_reloc.o text data bss dec hex filename 248 52 0 300 12c reloc.o 538 0 0 538 21a no_reloc.o
Turns out that gcc still uses const string ptrs which makes for really bad code. So your char * conversion is better for ppc too given the way gcc operates
Jocke