Tree/Branch: Poky/Master Commit: dfce2695b96ab587b8235cfab2859a874e9d2eef Using the core-image-sato-sdk image for qemux86, when running openGL applications in the target, the applications would report the following errors in the target: sh-4.1# ./glxgears go on... You maybe forgot to launch QEMU with -enable-gl argument. Trying TCP/IP communication instead impossible to connect to server: Connection refused Checking the QEMU launch options confirmed that "-enable-gl" argument was used. And the qemu printed the following errors on the host: func_number >= 0 && func_number < GL_N_CALLS failed cpu_get_phys_page_debug(env, 00000000) == ffffffff not in phys mem 00000000(ffffffff 00000000) cpu_x86_handle_mmu_fault = 1 call _init32 pid=1159 cannot get call parameters
Root cause is new gcc's optimization plus our small bug for saving register. opengl calling (in call_opengl_qemu) includes 4 steps: 1. prepare opengl parameters on stack 2. save some "input" register by push 3. load "input" register with parameters on stack via same index as step 1 4. issue "int 0x99" to trap into qemu, who will get parameter in the registers Attaching objdump of different gcc output for same qemugl code, you can see new gcc uses "%esp" rather than "%ebp" to index local variable in stack, which leads wrong index in step 3, as push decrease "%esp" automatically. So when trapping into qemu, wrong parameters are accessed. Saving registers via local variables will fix it. ** compiled by new gcc ** mov %eax,0x38(%esp) mov %edx,0x34(%esp) mov 0x60(%esp),%eax mov 0x68(%esp),%edx mov %eax,0x30(%esp) mov %ebp,0x2c(%esp) mov %edx,0x28(%esp) push %ebx push %ecx push %edx push %esi mov 0x38(%esp),%eax mov 0x34(%esp),%ebx mov 0x30(%esp),%ecx mov 0x2c(%esp),%edx mov 0x28(%esp),%esi int $0x99 pop %esi pop %edx pop %ecx pop %ebx ** compiled by old gcc ** mov %eax,-0x1c(%ebp) mov %edx,-0x20(%ebp) mov 0x8(%ebp),%eax mov 0xc(%ebp),%edx mov 0x10(%ebp),%ecx mov %eax,-0x24(%ebp) mov %edx,-0x28(%ebp) mov %ecx,-0x2c(%ebp) push %ebx push %ecx push %edx push %esi mov -0x1c(%ebp),%eax mov -0x20(%ebp),%ebx mov -0x24(%ebp),%ecx mov -0x28(%ebp),%edx mov -0x2c(%ebp),%esi int $0x99 pop %esi pop %edx pop %ecx pop %ebx
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=0289683798bb3b6d1cfbf7cccb834b4b78d9bdab