[PATCH] fix building as PIEs on x86

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can't declare ebx as clobbered with most versions of gcc when you
build as PIC/PIE.  Save/restore the code ourselves using xchg & esi.

Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
---
 clearcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clearcache.c b/clearcache.c
index 82469c1..4acf024 100644
--- a/clearcache.c
+++ b/clearcache.c
@@ -57,7 +57,7 @@ void clearcache(unsigned char *mem, unsigned size)
 #if defined(__i386__) || defined(__x86_64__)
 	unsigned i, cl, eax, feat;
 	/* get clflush unit and feature */
-	asm("cpuid" : "=a" (eax), "=b" (cl), "=d" (feat) : "0" (1) : "cx");
+	asm("xchg %%ebx, %%esi; cpuid; xchg %%esi, %%ebx;" : "=a" (eax), "=S" (cl), "=d" (feat) : "0" (1) : "cx");
 	if (!(feat & (1 << 19)))
 		fallback_clearcache();
 	cl = ((cl >> 8) & 0xff) * 8;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux