WSL Ubuntu18.04
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
.section .rodata
msg:
.ascii "Hello, world.\n"
.section .text
.globl main
main:
movl $4, %eax
movl $1, %ebx
movl $msg, %ecx
movl $14, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80
1. 不加任何選項,是這樣的
$ gcc hello.s
/usr/bin/ld: /tmp/ccjICv40.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
2. 加-no-pie選項后是這樣的
gcc -no-pie hello.s
wj@wj:~/study/asm$ ./a.out
Segmentation fault (core dumped)
可這明明是個簡單的程式,不會有段錯誤的啊
我向學寫匯編,怎么就這么難啊
uj5u.com熱心網友回復:
您好,您成功了嘛?我也碰到這個問題,但苦于無法解決uj5u.com熱心網友回復:
這是匯編程式,不要用gcc,用as轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/65336.html
標籤:匯編語言
下一篇:大神速救 在線等 救急!!!
