impossible constraint in 'asm' error

2019-09-02 03:11发布

I'm trying to cross-compile a c++ file with arm-linux-gnueabi-g++.:

make CROSS_COMPILE=arm-linux-gnueabi- all

But an error occurs:

arm-linux-gnueabi-g++ -O2 -c -oa32.o PMCTestA.cpp
In file included from PMCTest.h:54:0,
                 from PMCTestA.cpp:24:
PMCTestLinux.h: In member function ‘void CCounters::GetProcessorVendor()’:
PMCTestLinux.h:63:73: error: impossible constraint in ‘asm’
make: *** [a32.o] Error 1

And here is part of the code in PMCTestLinux.h from row 61:

static void Cpuid (int Output[4], int aa) { 
    int a, b, c, d;
    __asm("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(aa),"c"(0) : );
    Output[0] = a;
    Output[1] = b;
    Output[2] = c;
    Output[3] = d;
}

static inline void Serialize () {
    // serialize CPU
    __asm__ __volatile__ ( "xorl %%eax, %%eax \n cpuid " : : : "%eax","%ebx","%ecx","%edx" );
}

static inline int Readtsc() {
    // read time stamp counter
    int r;
    __asm__ __volatile__ ( "rdtsc" : "=a"(r) : : "%edx");    
    return r;
}

static inline int Readpmc(int nPerfCtr) {
    // read performance monitor counter number nPerfCtr
    int r;
    __asm__ __volatile__ ( "rdpmc" : "=a"(r) : "c"(nPerfCtr) : "%edx");    
    return r;
}

Does anyone know something about this error? I'm not sure if the problem is about the compiler. My system is Ubuntu 10.04 and the version of arm-linux-gnueabi-g++ is 4.7.3

0条回答
登录 后发表回答