about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/021translate.cc6
-rwxr-xr-xsubx/ex1bin96 -> 96 bytes
-rwxr-xr-xsubx/teensy/test5bin99 -> 99 bytes
-rw-r--r--subx/teensy/test5.s10
4 files changed, 8 insertions, 8 deletions
diff --git a/subx/021translate.cc b/subx/021translate.cc
index ae110c21..94553ae9 100644
--- a/subx/021translate.cc
+++ b/subx/021translate.cc
@@ -41,7 +41,7 @@ void dump_elf_header(ostream& out) {
   // e_version
   O(0x01); O(0x00); O(0x00); O(0x00);
   // e_entry
-  int e_entry = START + /*size of ehdr*/52 + /*size of phdr*/32;
+  int e_entry = START;
   emit(e_entry);
   // e_phoff -- immediately after ELF header
   int e_phoff = 52;
@@ -73,14 +73,14 @@ void dump_elf_header(ostream& out) {
   uint32_t p_type = 0x1;
   emit(p_type);
   // p_offset
-  uint32_t p_offset = 0;
+  uint32_t p_offset = /*size of ehdr*/52 + /*size of phdr*/32;
   emit(p_offset);
   // p_vaddr
   emit(START);
   // p_paddr
   emit(START);
   // p_filesz
-  uint32_t size = (End_of_program-/*we're not using location 0*/1) + /*size of ehdr*/52 + /*size of phdr*/32;
+  uint32_t size = End_of_program - /*we're not using location 0*/1;
   emit(size);
   // p_memsz
   emit(size);
diff --git a/subx/ex1 b/subx/ex1
index 205f8d60..cf6b2f4c 100755
--- a/subx/ex1
+++ b/subx/ex1
Binary files differdiff --git a/subx/teensy/test5 b/subx/teensy/test5
index a67a5299..b960ac41 100755
--- a/subx/teensy/test5
+++ b/subx/teensy/test5
Binary files differdiff --git a/subx/teensy/test5.s b/subx/teensy/test5.s
index 54a79846..e4bd0c7e 100644
--- a/subx/teensy/test5.s
+++ b/subx/teensy/test5.s
@@ -11,7 +11,7 @@ ehdr:                                                 ; Elf32_Ehdr
               dw      2                               ;   e_type
               dw      3                               ;   e_machine
               dd      1                               ;   e_version
-              dd      _start                          ;   e_entry
+              dd      $$                              ;   e_entry
               dd      phdr - $$                       ;   e_phoff
               dd      0                               ;   e_shoff
               dd      0                               ;   e_flags
@@ -25,11 +25,11 @@ ehdrsize  equ  $ - ehdr
 
 phdr:                                                 ; Elf32_Phdr
               dd      1                               ;   p_type
-              dd      0                               ;   p_offset
+              dd      _start - $$                     ;   p_offset
               dd      $$                              ;   p_vaddr
               dd      $$                              ;   p_paddr
-              dd      filesize                        ;   p_filesz
-              dd      filesize                        ;   p_memsz
+              dd      codesize                        ;   p_filesz
+              dd      codesize                        ;   p_memsz
               dd      5                               ;   p_flags
               dd      0x1000                          ;   p_align
 phdrsize  equ  $ - phdr
@@ -43,4 +43,4 @@ _start:
     dd 0x00000001  ; imm32 operand
   int 0x80
 
-filesize      equ     $ - $$
+codesize      equ     $ - _start