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 9:56

>>8,9
Ah, ok. I relocated fuck to .rodata and bork segfaulted as expected.
I also objdump -x'd this program and confirmed that it sticks the string in .rodata:

#include <stdio.h>
int main(int argc, char **argv) {
puts("EXPERT PROGRAMMER");
return 0;
}


That doesn't explain why it takes 6 fucking kilobytes to poop a constrant string onto stdout, but whatever.

>>11
Thanks for the read. Sticking the whole program inside the ELF header, that's funny.

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