
Dear Wolfgang Denk,
On 10 January 2011 21:14, Wolfgang Denk wd@denx.de wrote:
Dear Minkyu Kang,
In message AANLkTimgBjOSE8c+_6AsUon5KnNR1_UKNqc=Wf_UD2+J@mail.gmail.com you wrote:
int (*test_func)(void);
This results in a symbol in bss segment, right?
And then, set to NULL at arch_cpu_init()
Such an assignment is illegal then. Bss has not been initalized before relocation, and must not be accessed (neither read nor write).
Illegal? as a result, yes.
No, illegal as an action. You MUST NOT access any symbols in BSS before relocation (more precisely, before bss has been initialized).
And you MUST NOT write any symbols in data segment before relocation, either.
In both cases, the result of such actions is undefined behaviour.
But we do many things before the reloaction as arch init, board init and so on.
Of course, but as mentioned we must not read or write to symbols in bss, and we must not write to symbols in data segment.
How about lcd_setmem function? panel_info is located at bss area, but lcd_setmem access this structure. Is it illegal?
This must not be done before relocation.
No, please see 360 line of arch/arm/lib/board.c This function is called before relocation.
And how about init_func_i2c()? This function is called twice, before the relocation and after relocation. When we use board_i2c_init function then, there is possibility that use symbols in bss because of this function is called after relocation.
If we ignore this exception, it will be a big constraint.
btw, there are any side effects on my patch? I think.. It is just a little safety feature.
Thanks Minkyu Kang