Merge pull request #478 from nfedera/cpuidfix

xfreerdp: Fixed PIC base address corruption by inline assembly
This commit is contained in:
Marc-André Moreau 2012-02-29 12:25:35 -08:00
commit 6c64c288c9

View File

@ -598,14 +598,22 @@ void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned
{ {
#ifdef __GNUC__ #ifdef __GNUC__
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
*eax = info;
__asm volatile __asm volatile
("mov %%ebx, %%edi;" /* 32bit PIC: don't clobber ebx */ (
"cpuid;" /* The EBX (or RBX register on x86_64) is used for the PIC base address
and must not be corrupted by our inline assembly. */
#if defined(__i386__)
"mov %%ebx, %%esi;" "mov %%ebx, %%esi;"
"mov %%edi, %%ebx;" "cpuid;"
:"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) "xchg %%ebx, %%esi;"
: :"edi"); #else
"mov %%rbx, %%rsi;"
"cpuid;"
"xchg %%rbx, %%rsi;"
#endif
: "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
: "0" (info)
);
#endif #endif
#endif #endif
} }