Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are .data and .text in x86?

Tags:

x86

1

.data
value: .long 0x69
.text
#...

2

.text
value: .long 0x69
#...

I'm a student learning x86 and I noticed that value can't be modified if it's under .text. I've been trying to read why, but I couldn't find it. Can someone lead me to where I can read about it or explain it briefly?

like image 307
UXkQEZ7 Avatar asked Oct 06 '22 05:10

UXkQEZ7


1 Answers

.text section is the region of an executable where the actual executable instructions lie, and the .data section is the region of an executable where the non-stack based variables and constants lie. The reason why you can't modify values in the .text section is because of a security feature called W^X(aka PaX, Exec Shield, DEP, etc), which is enabled on most of the modern operating systems, where the OS disallows region of the memory unwritable while they are being executed. It's there to help alleviate arbitrary code injections.

like image 65
JosephH Avatar answered Oct 10 '22 14:10

JosephH