[PATCH] fix building as PIEs on x86
Mike Frysinger <[email protected]> Mon, 18 Apr 2016 18:56:22 -0400
| Newsgroups | org.kernel.vger.linux-numa |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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