From 517a471bc0945657dc331c16d4bed74c7dc5b3b5 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 6 Jul 2018 23:13:03 -0700 Subject: 4316 Second attempt at commit 4291. We'll now not copy the headers into memory, but we'll still allocate space for them. Still some security benefits, and I'm gaining confidence that I understand the ELF format. --- subx/teensy/test5 | Bin 96 -> 96 bytes subx/teensy/test5.s | 15 +++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'subx/teensy') diff --git a/subx/teensy/test5 b/subx/teensy/test5 index 4d2da664..f3c9730d 100755 Binary files a/subx/teensy/test5 and b/subx/teensy/test5 differ diff --git a/subx/teensy/test5.s b/subx/teensy/test5.s index d549306b..ca7c86e4 100644 --- a/subx/teensy/test5.s +++ b/subx/teensy/test5.s @@ -25,11 +25,14 @@ ehdrsize equ $ - ehdr phdr: ; Elf32_Phdr dd 1 ; p_type - dd 0 ; p_offset - dd $$ ; p_vaddr - dd $$ ; p_paddr - dd filesize ; p_filesz - dd filesize ; p_memsz + # don't copy ehdr or phdr into the first segment. + dd 0x54 ; p_offset + # but you can't save on bytes for them, because p_align. + # messing with the ORG won't help you here. + dd 0x08048054 ; p_vaddr + dd 0x08048054 ; p_paddr + dd codesize ; p_filesz + dd codesize ; p_memsz dd 5 ; p_flags dd 0x1000 ; p_align phdrsize equ $ - phdr @@ -39,4 +42,4 @@ _start: mov eax, 1 int 0x80 -filesize equ $ - $$ +codesize equ $ - _start -- cgit 1.4.1-2-gfad0