From 89ec3a610d2a1c9887fe9ee0bd622f3ab14c6750 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Sun, 24 Feb 2013 22:45:53 +0800 Subject: [PATCH] =?utf8?q?cmd/dist:=20avoid=20using=20%ebx=20on=20i386.=20?= =?utf8?q?Or=20gcc=20(-fPIC)=20will=20complain:=20cmd/dist/unix.c:=20In=20?= =?utf8?q?function=20=E2=80=98cansse2=E2=80=99=20cmd/dist/unix.c:774:=20er?= =?utf8?q?ror:=20can't=20find=20a=20register=20in=20class=20=E2=80=98BREG?= =?utf8?q?=E2=80=99=20while=20reloading=20=E2=80=98asm=E2=80=99=20cmd/dist?= =?utf8?q?/unix.c:774:=20error:=20=E2=80=98asm=E2=80=99=20operand=20has=20?= =?utf8?q?impossible=20constraints?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This affects bootstrapping on native Darwin/386 where all code is compiled with -fPIC. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7394047 --- src/cmd/dist/unix.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c index baf019ef9c..d8b88893c9 100644 --- a/src/cmd/dist/unix.c +++ b/src/cmd/dist/unix.c @@ -770,7 +770,15 @@ sigillhand(int signum) static void __cpuid(int dst[4], int ax) { -#if defined(__i386__) || defined(__x86_64__) +#ifdef __i386__ + // we need to avoid ebx on i386 (esp. when -fPIC). + asm volatile( + "mov %%ebx, %%edi\n\t" + "cpuid\n\t" + "xchgl %%ebx, %%edi" + : "=a" (dst[0]), "=D" (dst[1]), "=c" (dst[2]), "=d" (dst[3]) + : "0" (ax)); +#elif defined(__x86_64__) asm volatile("cpuid" : "=a" (dst[0]), "=b" (dst[1]), "=c" (dst[2]), "=d" (dst[3]) : "0" (ax)); -- 2.48.1