--- /usr/local/google/home/waffles/Downloads/C/CpuArch.c 2015-03-25 05:17:41.000000000 -0700 +++ CpuArch.c 2016-02-19 12:42:20.327993932 -0800 @@ -45,7 +45,8 @@ "push %%EDX\n\t" "popf\n\t" "andl %%EAX, %0\n\t": - "=c" (flag) : "c" (flag)); + "=c" (flag) : "c" (flag): + "%eax", "%edx" ); #endif return flag; } @@ -78,8 +79,17 @@ #else + // When built using GCC and -fPIC (until GCC 5.0), ebx points to the global + // offset table, so the value must be preserved before executing cpuid. + // Attempting to explicitly clobber ebx is a compile-time error. __asm__ __volatile__ ( - #if defined(MY_CPU_X86) && defined(__PIC__) + #if defined(MY_CPU_AMD64) && defined(__PIC__) + "mov %%rbx, %%rdi\n" + "cpuid\n" + "xchg %%rdi, %%rbx\n" + : "=a" (*a) , + "=D" (*b) , + #elif defined(MY_CPU_X86) && defined(__PIC__) "mov %%ebx, %%edi;" "cpuid;" "xchgl %%ebx, %%edi;"