Problem with u-boot compiled with 2006q1-3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with u-boot compiled with 2006q1-3



Hi,

I was unable to run u-boot compiled with the newest codesourcery
toolchain and after debugging I got the problem isolated to an example
below. U-boot breaks with -Os but works with -O0, but the example below
does not work with either one. Earlier toolchains work.

It looks like gcc does not obey the instruction to use r8 for gd
variable in main function, and so the program crashes when func() uses
gd which it thinks is in r8. Is this a bug in u-boot code or in gcc?

Best regards,
 Tomi Valkeinen



#include <stdio.h>

#define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm
("r8")

typedef struct global_data
{
    int kala;
} gd_t;

gd_t data;

void func(void);

int main()
{
    DECLARE_GLOBAL_DATA_PTR;

    gd = &data;

    __asm__ __volatile__("": : :"memory");

    gd->kala = 123;

    func();

    return 0;
}

void func()
{
    DECLARE_GLOBAL_DATA_PTR;

    int i = gd->kala;

    printf("%d\n", i);
}