mirror of https://github.com/FreeRDP/FreeRDP
xfreerdp: Fixed PIC base address corruption by inline assembly
EBX (or RBX on x86_64) is used for the PIC base address. The current cpuid inline assembly only saved ebx which is fine under i386 but only half of the fun on x86_64.
This commit is contained in:
parent
506cca7abb
commit
f821425bf3
|
@ -598,18 +598,26 @@ 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
|
||||||
"mov %%ebx, %%esi;"
|
and must not be corrupted by our inline assembly. */
|
||||||
"mov %%edi, %%ebx;"
|
#if defined(__i386__)
|
||||||
:"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
|
"mov %%ebx, %%esi;"
|
||||||
: :"edi");
|
"cpuid;"
|
||||||
|
"xchg %%ebx, %%esi;"
|
||||||
|
#else
|
||||||
|
"mov %%rbx, %%rsi;"
|
||||||
|
"cpuid;"
|
||||||
|
"xchg %%rbx, %%rsi;"
|
||||||
|
#endif
|
||||||
|
: "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||||
|
: "0" (info)
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 xf_detect_cpu()
|
uint32 xf_detect_cpu()
|
||||||
{
|
{
|
||||||
unsigned int eax, ebx, ecx, edx = 0;
|
unsigned int eax, ebx, ecx, edx = 0;
|
||||||
|
|
Loading…
Reference in New Issue