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: fibsiter.s 2014-05-18 8:37

extern print_number

section .text
global asm_main
asm_main:
enter 0,0
pusha

;; The loop instruction decrements ECX and jumps to the address specified by arg unless decrementing ECX caused its value to become zero.
;;; calculate fib(ecx), must be 2 or more
mov ecx,1507

mov eax,0
mov ebx,1
dec ecx

iter:
mov edx,ebx
add ebx,eax
mov eax,edx
loop iter

push ebp
mov ebp,esp
push ebx
call print_number
add esp,4
mov esp,ebp
pop ebp

popa
mov eax,0 ; return 0
leave
ret

Name: Anonymous 2014-05-21 4:05

>>71
enter
pusha
popa
leave

286 QUALITY!

Name: Anonymous 2014-05-21 4:15

Love the "leave" mnemonic - it is 1-char less than the return from C/C++

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