[英]Writing to .bss section in x86 assembly
我有一個.bss
節,其中有8個字節的緩沖區。 現在,我正在尋找一種在不發出系統調用的情況下將數字2
存儲在緩沖區中的方法。 那可能嗎 ?
我的嘗試無效:
.section .text
.section .bss
.lcomm SAMPLE_BUFFER, 8
.globl _start
_start:
movl $2,SAMPLE_BUFFER
movl $1, %eax
int $0x80
執行時:
$ as --32 buffer.s -o buffer.o
$ ld -m elf_i386 buffer.o -o buffer
$ ./buffer
fish: “./buffer” terminated by signal SIGSEGV (Address boundary error)
在發出_start
的機器代碼之前,您需要確保切換回.text
部分。 _start
,您將_start
放在無法執行的.bss
,從而使程序崩潰。
除此之外,您的代碼似乎正確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.