我只是想編譯一本我從書中輸入的簡單示例代碼,而GCC給了我上面的錯誤。這裏是我的代碼:GCC錯誤信息「錯誤:不支持`mov'」是什麼意思?
$ cat -n test.cpp
1 #define READ_COMMAND 3
2
3 #define MSG_LENGTH 128
4
5 #include <stdlib.h>
6 #include <stdio.h>
7
8 int main(int argc, char *arg[])
9 {
10 int syslog_command = READ_COMMAND;
11 int bytes_to_read = MSG_LENGTH;
12 int retval;
13 char buffer[MSG_LENGTH];
14
15 asm volatile(
16 "movl %1, %%ebx\n\t"
17 "movl %2, %%ecx\n\t"
18 "movl %3, %%edx\n\t"
19 "movl $103, %%eax\n\t"
20 "int $128\n\t"
21 "movl %%eax, %0"
22 :"=r" (retval)
23 :"m"(syslog_command),"r"(buffer),"m"(bytes_to_read)
24 :"%eax","%ebx","%ecx","%edx");
25 if (retval > 0) printf("%s\n", buffer);
26
27 }
28
29
的代碼應該調用syslog()
系統調用從內核printk()
環形緩衝區讀取的最後128個字節。這裏是我的操作系統和系統配置的一些信息:
uname -a
:
Linux 3.2.0-26-generiC#41-Ubuntu SMP Thu Jun 14 17:49:24 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
gcc -v
:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
繼承人的完整的錯誤:
$ gcc test.cpp
test.cpp: Assembler messages:
test.cpp:25: Error: unsupported for `mov'
這是整個消息嗎?它是什麼代碼? – 2012-07-07 03:33:49
已更新的問題。謝謝。 – Dan 2012-07-07 03:50:55
請不要在行號後面加密碼;它使複製和粘貼更加困難。只需添加一條評論,顯示哪一行是#25。 – 2012-07-07 03:52:09