I am only starting to learn assembly, and i have read in the book that only .text
section can be executed.
So why am i allowed to execute instructions what are stored in .data
section?
Here is the code:
global _start
section .data
msg: db "hello world",10
msg_len: equ $-msg
proc_write_and_exit:
mov eax, 4 ;write syscall
mov ebx, 1 ;stdout handle number
mov ecx, msg
mov edx, msg_len
int 80h ;call program interrupt
mov eax, 1 ;_exit syscall
mov ebx, 0 ;program exit code
int 80h
section .text
_start: jmp proc_write_and_exit
Running on Ubuntu 18.04.4 LTS.
build: nasm -f elf execute_data_section.asm && ld -m elf_i386 execute_data_section.o
run: ./a.out
output: "hello world"
So which sections can really be executed, and which sections can't? And where can i read it to be sure? I am pretty confused at this point.