summaryrefslogtreecommitdiff
path: root/sys-apps/x86info/files/x86info-1.24-pic.patch
blob: b4098c5c68c2d9df2eece0c985745d926f9dfee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
http://bugs.gentoo.org/270388

--- a/cpuid.c
+++ b/cpuid.c
@@ -62,12 +62,28 @@
 		sched_setaffinity(getpid(), sizeof(set), &set);
 	}
 
+#ifdef __PIC__
+	/* GCC on i386 bitches if you clobber ebx.  So hide it behind
+	 * gcc's back. */
+	asm(
+		"movl %%ebx,%%edi\n"
+		"cpuid\n"
+		"movl %%ebx,%1\n"
+		"movl %%edi,%%ebx\n"
+		: "=a" (a),
+		  "=m" (b),
+		  "+c" (c),
+		  "=d" (d)
+		: "0" ((unsigned int)idx)
+		: "edi");
+#else
 	asm("cpuid"
 		: "=a" (a),
 		  "=b" (b),
 		  "+c" (c),
 		  "=d" (d)
 		: "0" ((unsigned int)idx));
+#endif
 
 	if (eax!=NULL)
 		*eax = a;