mma...@mmarkk-desktop:~/src/vmdetect$ gcc --version
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
----------------------------------------------
#include <sys/types.h>
#include <stdio.h>
int main (void)
{
size_t ecx;
asm ("cpuid": "=c" (ecx): "a" (0x1):"eax","ebx","edx");
printf ("Suspected %s machine!\n", (ecx >> 31) ? "virtual" : "real");
return 0;
}
mma...@mmarkk-desktop:~/src/vmdetect$ gcc 1main.c
1main.c: In function main:
1main.c:7: error: can't find a register in class AREG while reloading asm
1main.c:7: error: asm operand has impossible constraints
------------------------------------------------
#include <sys/types.h>
#include <stdio.h>
int main (void)
{
size_t ecx, dontneed;
asm ("cpuid": "=c" (ecx),"=a"(dontneed): "a" (0x1):"ebx","edx");
printf ("Suspected %s machine!\n", (ecx >> 31) ? "virtual" : "real");
return 0;
}
works OK.
How to correctly say compiler about clobbering eax register ?
--
Summary: inline assembler: can't set clobbering for input
register
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: socketpair at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43998