在64位系統(tǒng)(GNU工具鏈)上組裝32位二進(jìn)制文件我編寫可以編譯的程序集代碼:as power.s -o power.o當(dāng)我鏈接power.o對象文件時出現(xiàn)了問題:ld power.o -o power為了在64位操作系統(tǒng)(Ubuntu14.04)上運(yùn)行,我添加了.code32在power.s文件,但是我仍然收到錯誤:分段故障(堆芯傾棄)power.s:.code32
.section .data
.section .text
.global _start
_start:
pushl $3
pushl $2
call power
addl $8, %esp
pushl %eax
pushl $2
pushl $5
call power
addl $8, %esp
popl %ebx
addl %eax, %ebx
movl $1, %eax
int $0x80
.type power, @function
power:
pushl %ebp
movl %esp, %ebp
subl $4, %esp
movl 8(%ebp), %ebx
movl 12(%ebp), %ecx
movl %ebx, -4(%ebp)
power_loop_start:
cmpl $1, %ecx
je end_power
movl -4(%ebp), %eax
imull %ebx, %eax
movl %eax, -4(%ebp)
decl %ecx
jmp power_loop_start
end_power:
movl -4(%ebp), %eax
movl %ebp, %esp
popl %ebp
ret
在64位系統(tǒng)(GNU工具鏈)上組裝32位二進(jìn)制文件
慕工程0101907
2019-06-11 20:39:05