当前位置: 技术问答>linux和unix
汇编代码里加入一个nop就编译不过了?
来源: 互联网 发布时间:2016-11-05
本文导语: 代码如下: 2 .section .data output: .ascii "The processor Ventor ID is 'xxxxxxxxxxxx'n" .section .text .global _start _start: nop movl $0, %eax cpuid movl $output, %edi ...
代码如下:
2
.section .data
output:
.ascii "The processor Ventor ID is 'xxxxxxxxxxxx'n"
.section .text
.global _start
_start:
nop
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $2, %ebx
int $0x80
去掉_start后的nop就正常,加上,在ld的时候就报错:
cpuid.o: In function `_start':
/home/lihacker/workspace/asm/cpuid.s:10: multiple definition of `_start'
cpuid:/home/lihacker/workspace/asm/cpuid.s:10: first defined here
2
.section .data
output:
.ascii "The processor Ventor ID is 'xxxxxxxxxxxx'n"
.section .text
.global _start
_start:
nop
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $2, %ebx
int $0x80
去掉_start后的nop就正常,加上,在ld的时候就报错:
cpuid.o: In function `_start':
/home/lihacker/workspace/asm/cpuid.s:10: multiple definition of `_start'
cpuid:/home/lihacker/workspace/asm/cpuid.s:10: first defined here
|
复制你的代码,编译没错
|
应该没有问题吧