You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported in version: HG 2.0 Reported for operating system, platform: Linux, x86
Comments on the original bug report:
On 2009-04-26 21:34:05 +0000, Nicholas Phillips wrote:
I am using x64 Linux (using Intel Core 2 DUO), and I have noticed that there is an error in SDL_cpuinfo.c, function CPU_getCPUIDFeaturesExt for my platform.
The code in question is:
#elif defined(GNUC) && defined (x86_64) asm (
" movq %%rbx,%%rdi\n"
" movl $0x80000000,%%eax # Query for extended functions \n"
" cpuid # Get extended function limit \n"
" cmpl $0x80000001,%%eax \n"
" jl 1f # Nope, we dont have function 800000001h\n"
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
" cpuid # and get the information \n"
" movl %%edx,%0 \n"
"1: \n"
" movq %%rdi,%%rbx\n"
: "=m" (features)
:
: "%rax", "%rcx", "%rdx", "%rdi"
);
Even though %rbx is saved and restored manually, it still needs to appear on the clobbered register list, because it is modified by the cpuid instruction. If GCC chose to use %rbx to store %0 (features) it would cause big problems. For example consider the following code produced by GCC with the -S switch (code in question used out of context):
movq %rbx,%rdi
movl $0x80000000,%eax # Query for extended functions
cpuid # Get extended function limit
cmpl $0x80000001,%eax
jl 1f # Nope, we dont have function 800000001h
movl $0x80000001,%eax # Setup extended function 800000001h
cpuid # and get the information
movl %edx,48(%rbx)
1:
movq %rdi,%rbx
0 "" 2
#NO_APP
This causes a segmentation fault for obvious reasons.
Adding %rbx to the clobbered register list makes GCC use a different register to store %0, and eliminates the problem.
Cheers.
On 2009-04-26 21:46:26 +0000, Nicholas Phillips wrote:
Created attachment 324
Proposed patch for SDL_cpuinfo.c
I noticed that the same problem could happen in other functions and for other platforms found in SDL_cpuinfo.c. Here is a simple patch.
On 2009-06-25 10:56:27 +0000, Ozkan Sezer wrote:
Is SDL-1.2 not affected?
On 2009-09-26 03:05:47 +0000, Sam Lantinga wrote:
Thank you very much for your patch!
Do you give me permission to release your code with SDL 1.3 and future
versions of SDL under both the LGPL and a closed-source commercial
license?
On 2009-09-26 09:35:19 +0000, Joshua Root wrote:
Building on i386 OS X seem to be broken now:
./src/cpuinfo/SDL_cpuinfo.c: In function 'SDL_GetCPUFeatures':
./src/cpuinfo/SDL_cpuinfo.c:150: error: PIC register '%ebx' clobbered in 'asm'
On 2009-09-26 14:40:57 +0000, Sam Lantinga wrote:
Whoops, fixed, thanks!
On 2009-10-29 21:46:02 +0000, Sam Lantinga wrote:
Okay, I tracked this down and took care of it, thanks!
The text was updated successfully, but these errors were encountered:
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: HG 2.0
Reported for operating system, platform: Linux, x86
Comments on the original bug report:
On 2009-04-26 21:34:05 +0000, Nicholas Phillips wrote:
On 2009-04-26 21:46:26 +0000, Nicholas Phillips wrote:
On 2009-06-25 10:56:27 +0000, Ozkan Sezer wrote:
On 2009-09-26 03:05:47 +0000, Sam Lantinga wrote:
On 2009-09-26 09:35:19 +0000, Joshua Root wrote:
On 2009-09-26 14:40:57 +0000, Sam Lantinga wrote:
On 2009-10-29 21:46:02 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: