Currently powertop does not compile as PIC.
This bug [1] has been detected in Gentoo using hardened and in the
bugreport there is a proposed patch too, attached below. Applies and
seems to work fine here. Please review it.

Credit to Dwokfur for it.

[1] https://bugs.gentoo.org/show_bug.cgi?id=236372

//
Peter



diff -urN powertop-1.10-orig/intelcstates.c
powertop-1.10-atoth/intelcstates.c
--- powertop-1.10-orig/intelcstates.c   2008-06-10 22:18:45.000000000 +0200
+++ powertop-1.10-atoth/intelcstates.c  2008-09-13 22:23:01.000000000 +0200
@@ -44,10 +44,17 @@
                         unsigned int *ecx,
                         unsigned int *edx)
 {
-        /* call the cpuid instruction with the registers as input and output */
-        __asm__("cpuid"
+        /* call the cpuid instruction with the registers as input and output
+        * modification by Dwokfur based on Sam Hocevar's discussion on
+        * how to make Assemly code PIC compatible:
+        * 
http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
+        */
+        __asm__("pushl %%ebx   \n\t" /* save %ebx */
+               "cpuid          \n\t"
+               "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
+               "popl %%ebx     \n\t" /* restore the old %ebx */
                 : "=a" (*eax),
-                  "=b" (*ebx),
+                  "=r" (*ebx),
                   "=c" (*ecx),
                   "=d" (*edx)
                 : "0" (*eax),

_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power

Reply via email to