> static void __attribute__((unused)) dummy(void) > { Why is the above marked *unused*. Thats the reason for that code to be eliminated. Regards, Muthu. On Wed, 22 Sep 2004 lapo.pasqui@xxxxxxxx wrote: > What do you mean with "dead" > The getc, putc functions are defined here and used by another files. > > ============================================================ > Da: Muthukumar Ratty <muthu@xxxxxxxxxx> > Data: 2004/09/21 mar PM 11:51:35 GMT+02:00 > A: lapo <lapo.pasqui@xxxxxxxx> > Cc: <gcc-help@xxxxxxxxxxx> > Oggetto: Re: Is it a gcc bug? Optimization doesn't work > > > > I guess it eliminates the dead code. Try to use the getc, putc functions, > it will not be eliminated then. > > > > > On Tue, 21 Sep 2004, lapo wrote: > > > Alle 14:10, mercoledì 15 settembre 2004, lapo.pasqui@xxxxxxxx ha scritto: > > Does anybody like to answer this question? > > I'd rather prefer not to open an insane bug against the gcc. > > Thanks > > Lapo > > > Hi all, > > > I've upgraded my cross gcc compiler from version 3.3.1 to 3.4.1 and I've > > > noticed a few unresolved symbols on a project (u-boot) used to compile > > > without any problem. After a quick investigation I've noticed the > > > optimization flag -0s caused a few functions not to be in the .o files. > > > Here's a code that reproduces the problem > > > > > > unsigned long get_version(void); > > > int getc(void); > > > int tstc(void); > > > void putc(const char); > > > > > > void app_startup(char **); > > > > > > enum { > > > XF_get_version , > > > XF_getc , > > > XF_tstc , > > > XF_putc , > > > XF_MAX > > > }; > > > > > > typedef unsigned int size_t; > > > typedef struct global_data > > > { > > > void **jt; > > > } gd_t; > > > > > > static void __attribute__((unused)) dummy(void) > > > { > > > asm volatile ( " .globl " "get_version" "\n" "get_version" ":\n" " > > > lwz %%r11, %0(%%r29)\n" " lwz %%r11, %1(%%r11)\n" " mtctr > > > %%r11\n" " bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), > > > "i"(XF_get_version * sizeof(void *)) : "r11"); asm volatile ( " > > > .globl " "getc" "\n" "getc" ":\n" " lwz %%r11, %0(%%r29)\n" " lwz > > > %%r11, %1(%%r11)\n" " mtctr %%r11\n" " bctr\n" : : > > > "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_getc * sizeof(void *)) : "r11"); > > > asm volatile ( " .globl " "tstc" "\n" "tstc" ":\n" " lwz > > > %%r11, %0(%%r29)\n" " lwz %%r11, %1(%%r11)\n" " mtctr %%r11\n" " > > > bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_tstc * sizeof(void > > > *)) : "r11"); asm volatile ( " .globl " "putc" "\n" "putc" ":\n" " > > > lwz %%r11, %0(%%r29)\n" " lwz %%r11, %1(%%r11)\n" " mtctr > > > %%r11\n" " bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_putc * > > > sizeof(void *)) : "r11"); } > > > > > > extern unsigned long __bss_start, _end; > > > > > > void app_startup(char **argv) > > > { > > > unsigned long * cp = &__bss_start; > > > while (cp < &_end) { > > > *cp++ = 0; > > > } > > > > > > } > > > > > > Compiling it with optimization less then 2 (e.g. powerpc-linux-gcc stubs.i > > > -c -O1), I get this symbols > > > > > > nm -C --defined-only stub.o > > > > > > 00000044 T app_startup > > > 00000000 t dummy > > > 00000010 T getc > > > 00000000 T get_version > > > 00000030 T putc > > > 00000020 T tstc > > > > > > > > > Instead, using a different optimization (e.g. powerpc-linux-gcc stubs.i -c > > > -O2), I get this symbols > > > > > > nm -C --defined-only stub.o > > > 00000000 T app_startup > > > > > > Using a previous version of gcc, I've not this different behaviour > > > > > > My questions are (as I'm not am assembler guru): > > > > > > Can you see anything wrong on this code that some new feature of the gcc > > > try to overcome? Is it indeed a regression of gcc 3.4.1 > > > > > > > > > > > > > > > ------------------------------------------------- > > > WebMail Tele2 http://www.tele2.it > > > ------------------------------------------------- > > > > ============================================================ > > > ------------------------------------------------- > WebMail Tele2 http://www.tele2.it > ------------------------------------------------- >