Merge pull request #628 from rhelmot/fix/self_modifying_instructions

Document assembly instructions for x86_self_modifying
This commit is contained in:
Nguyen Anh Quynh 2016-08-31 09:50:35 +08:00 committed by GitHub
commit d0f30547f8
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,9 @@ from struct import pack
import os
import regress
# The file we're loading is a full assembled ELF.
# Source for it, along with assembly instructions, are in x86_self_modifying.s
CODE_ADDR = 0x08048000
STACK_ADDR = 0x2000000
CODE = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86_self_modifying.elf')).read()

View File

@ -1,3 +1,17 @@
# Assembly instructions (tested on ubuntu 16.04 x86_64):
# $ as --32 x86_self_modifying.s -o x86_self_modifying.o
# $ ld -melf_i386 -z execstack x86_self_modifying.o -o x86_self_modifying.elf
# Test that it works. return code should be 65
# $ ./x86_self_modifying.elf
# $ echo $?
# 65
# Fix the entry point address in x86_self_modifying.py
# $ readelf -h x86_self_modifying.elf | grep Entry
# Entry point address: 0x8048074
.intel_syntax noprefix
.global _start