summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys-utils/lscpu.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 3e3fbbeb6..6b6082fbf 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -330,9 +330,19 @@ static inline void
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));