| Summary: | openGL application seems not working on qemux86 | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Lianhao Lu <lianhao.lu> |
| Component: | graphics | Assignee: | Edwin Zhai <edwin.zhai> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | High | CC: | edwin.zhai, meta.mr.watcher, meta.watcher, sgw |
| Version: | unspecified | ||
| Target Milestone: | 1.1 | ||
| Hardware: | x86 | ||
| OS: | x86 | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | --- | |
|
Description
Lianhao Lu
2011-09-01 19:59:53 UTC
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 |