Is it a gcc bug? Optimization doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-------------------------------------------------


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux