On 10/08/11 23:23, Kenneth Salerno wrote:
Thanks for the information, Mark.
I'm having issues getting OpenBIOS to work properly when I disable optimization, and I'm sure it's something I'm doing wrong or my compiler has a bug (GCC 4.6.1).
If I change -O2 to -O0 in Makefile.target, execution in QEMU will hang with a next instruction pointer of 0x0000000000000004 while reading the IDE device inside the Forth code... If I compile with -02, as you already know, I am told by GDB that ofmem->mfree was optimized out and cannot set a watchpoint:
#0 0x00000000fff91a84 in ofmem_free (ptr=0x3fca1774) at ../libopenbios/ofmem_common.c:175 #1 0x00000000fff8862c in free (ptr=<optimized out>) at ../arch/ppc/qemu/ofmem.c:258 #2 0x00000000fff93798 in deblk_close (di=<optimized out>) at ../packages/deblocker.c:66 #3 0x00000000fff8d950 in call1_func () at ../libopenbios/bindings.c:431 #4 0x00000000fff8b62c in call () at ../kernel/forth.c:244 #5 0x00000000fff8b4e8 in processxt (xt=<optimized out>) at ../kernel/forth.c:106 #6 next () at ../kernel/forth.c:127 #7 0x00000000fff8d288 in enterforth (xt=<optimized out>) at ../kernel/forth.c:156 #8 0x00000000fff8de7c in _selfword (method=0xfffb7d26 "close-deblocker", cache_xt=0xfffc0088) at ../libopenbios/bindings.c:83 #9 0x00000000fff98478 in ob_ide_close (drive=<optimized out>) at ../drivers/ide.c:1289 #10 0x00000000fff8d950 in call1_func () at ../libopenbios/bindings.c:431 #11 0x00000000fff8b62c in call () at ../kernel/forth.c:244 #12 0x00000000fff8b4e8 in processxt (xt=<optimized out>) at ../kernel/forth.c:106 #13 next () at ../kernel/forth.c:127 #14 0x00000000fff8d288 in enterforth (xt=<optimized out>) at ../kernel/forth.c:156 #15 0x00000000fff8daec in _fword (word=<optimized out>, cache_xt=0xfffbfec0) at ../libopenbios/bindings.c:71 #16 0x00000000fff8f20c in of_client_interface (params=0x44200) at ../libopenbios/client.c:318 #17 0x00000000fff019fc in of_client_callback () at ../arch/ppc/qemu/start.S:614 Backtrace stopped: frame did not save the PC
Sorry to bug you but why can't I get a working OpenBIOS ELF with compiler optimization disabled?
Gosh that's a tricky one :/
The only time I've ever seen bugs like this in OpenBIOS, i.e. where non-opimised and optimised binaries have different behaviour, is in the following cases:
i) there is a memory clobbering issue, e.g. Forth dictionary overwriting memory it shouldn't
ii) not enough stack space on SPARC before executing the client image
iii) an MMU bug in OpenBIOS
iv) a QEMU emulation bug
I think you'll need to dig deeper with gdb/qemu with you optimised build in order to try and work out what's happening here - sorry I can't offer any more useful tips :(
ATB,
Mark.