If we build lscpu as PIE, we currently get a build failure:
lscpu.c: In function 'main':
lscpu.c:333: error: can't find a register in class 'BREG' while reloading 'asm'
lscpu.c:333: error: 'asm' operand has impossible constraints
make[2]: *** [lscpu.o] Error 1
So we need a little bit of register shuffling to keep gcc happy.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
- __asm__("cpuid"
- : "=a" (*eax),
- "=b" (*ebx),
+ __asm__(
+#if defined(__PIC__) && defined(__i386__)
+ /* x86 PIC cannot clobber ebx -- gcc bitches */
+ "pushl %%ebx;"
+ "cpuid;"
+ "movl %%ebx, %%esi;"
+ "popl %%ebx;"
+ : "=S" (*ebx),
+#else
+ "cpuid;"
+ : "=b" (*ebx),
+#endif
+ "=a" (*eax),
"=c" (*ecx),
"=d" (*edx)
: "0" (op), "c"(0));