64位ATT汇编语言as汇编ld链接,执行报错Segmentation fault
absCallAndPrintAbsAsLd.s里边的内容如下:
.section .datastringToShow:.ascii "The abs of number is %d\n\0"
.global _start
.section .text
_start:pushq %rbpmovq %rsp,%rbpmovq $-5,%rdicall absmovq $stringToShow,%rdimovq %rax,%rsicall printfpopq %rbpmovq %rax,%rdimovq $0x3c,%raxsyscall
as -g absCallAndPrintAbsAsLd.s -o absCallAndPrintAbsAsLd.o进行汇编。
ld -g absCallAndPrintAbsAsLd.o -o absCallAndPrintAbsAsLd -lc -I /usr/lib64/ld-linux-x86-64.so.2进行链接。
./absCallAndPrintAbsAsLd执行报错Segmentation fault。

我把rsp中的地址加上8之后,就不报错了,因为这属于平栈了。
.section .datastringToShow:.ascii "The abs of number is %d\n\0"
.global _start
.section .text
_start:pushq %rbpmovq %rsp,%rbpmovq $-5,%rdicall abssubq $8,%rspmovq $stringToShow,%rdimovq %rax,%rsicall printfaddq $8,%rsppopq %rbpmovq %rax,%rdimovq $0x3c,%raxsyscall
as -g absCallAndPrintAbsAsLd.s -o absCallAndPrintAbsAsLd.o进行汇编。
ld -g absCallAndPrintAbsAsLd.o -o absCallAndPrintAbsAsLd -lc -I /usr/lib64/ld-linux-x86-64.so.2进行链接。
./absCallAndPrintAbsAsLd执行
