Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

x86 Assembly Questions

Name: Anonymous 2014-04-26 23:52

$ cat bork.asm

section .data
fuck: dd 0xDEADBEEF

section .text
global _start
_start:
mov dword [fuck],0xABADC0DA

mov eax,1
mov ebx,0
int 0x80


Why doesn't writing to the .data segment segfault? Shouldn't Linux map it to a read-only page?

$ nasm -f elf bork.asm
$ gold -s -o bork-gold bork.asm
$ ld -s -melf_i386 -o bork-ld bork.o
$ du -bh *
432 bork-gold
132 bork.asm
340 bork-ld
608 bork.o


How does such a minimal binary take up 300+ bytes?

Name: Anonymous 2014-04-27 0:18

>>2
https://web.archive.org/web/20120822144129/http://www.cin.ufpe.br/~if817/arquivos/asmtut/index.html
or if you've never programmed anything in assembly before
https://skilldrick.github.io/easy6502/

>>3
objdump -x bork-ld

bork-ld: file format elf32-i386
bork-ld
architecture: i386, flags 0x00000102:
EXEC_P, D_PAGED
start address 0x08048080

Program Header:
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
filesz 0x00000096 memsz 0x00000096 flags r-x
LOAD off 0x00000098 vaddr 0x08049098 paddr 0x08049098 align 2**12
filesz 0x00000004 memsz 0x00000004 flags rw-

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000016 08048080 08048080 00000080 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000004 08049098 08049098 00000098 2**2
CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
no symbols

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List