I'm having a .bss
section in which I have a buffer of 8 bytes inside it. Now, I'm looking for a way to store the number 2
inside the buffer without issuing a system call. Is that possible ?
My attempt which doesn't work:
.section .text
.section .bss
.lcomm SAMPLE_BUFFER, 8
.globl _start
_start:
movl $2,SAMPLE_BUFFER
movl $1, %eax
int $0x80
On execution:
$ 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)
You need to make sure to switch back to the .text
section before emitting the machine code for _start
. As is, you place _start
in .bss
which is not executable, crashing your program.
Apart from that, your code seems correct.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加