linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix building as PIEs on x86
@ 2016-04-18 22:56 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2016-04-18 22:56 UTC (permalink / raw)
  To: linux-numa

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@gentoo.org>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-18 22:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18 22:56 [PATCH] fix building as PIEs on x86 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).