The 'cpuid' assembly instruction is notorious for hating PIC. Here we code two different versions of the cpuid instruction ... the first will work when dealing with PIC, while the second is slightly faster and can be used with non-PIC. http://bugs.gentoo.org/61947 --- src/core/cpuid.cc +++ src/core/cpuid.cc @@ -68,9 +68,6 @@ #ifdef __i386__ -#define cpuid_up(in,a,b,c,d)\ - asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in)); - static void cpuid(int cpunumber, unsigned long idx, unsigned long &eax, @@ -96,7 +93,21 @@ edx = (*(unsigned long *) (buffer + 12)); } else - cpuid_up(idx, eax, ebx, ecx, edx); + asm( +#ifdef __PIC__ + "movl %%ebx,%%edi\n" + "cpuid\n" + "movl %%ebx,%3\n" + "movl %%edi,%%ebx\n" + : "=a" (eax), "=c" (ecx), "=d" (edx), "=m" (ebx) + : "a" (idx) + : "edi" +#else + "cpuid\n" + : "=a" (eax), "=c" (ecx), "=d" (edx), "=b" (ebx) + : "a" (idx) +#endif + ); } /* Decode Intel TLB and cache info descriptors */