需把汇编代码 .globl _start 改为.globl main,例如:
#cpuid.s Sample program to extract the processor Vendor ID
.section .data
output:
.ascii "The processor Vendor ID is 'xxxxxxxxxxxxxxxx'\n"
.section .text
.globl main
main:
movl $0, %eax # eax=0, 表示厂商ID
cpuid
movl $output, %edi
movl %ebx, 28(%edi) # 替换 output 第28个字符位置
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax # 系统调用值 4 --> write
movl $1, %ebx # 要写入的文件描述符, 1 --> STDOUT
movl $output, %ecx # 字符串的开头
movl $42, %edx # 字符串的长度 write(STDOUT, output, 42)
int $0x80
movl $1, %eax # 1 --> exit
movl $0, %ebx # exit(1)
int $0x80
# gcc -o cpuid 02-cpuid-gcc.s -m32
-m32:加上 -m32 参数,生成32位的代码。在64位机器上编译32位程序时使用;