about summary refs log tree commit diff stats
path: root/subx/apps/survey.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-15 16:39:13 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-15 16:39:13 -0700
commit549099384589fcbca3f7bc2f9b60473708f22e82 (patch)
tree80ec70b48ea5877c350f7d3412faa1e4415155c2 /subx/apps/survey.subx
parent9ad8133197a8917c819db6cee3348a7d04090877 (diff)
downloadmu-549099384589fcbca3f7bc2f9b60473708f22e82.tar.gz
5406
Bugfix eight: incorrect segment count in ELF header.

The generated examples/ex1 is still not right. But it has the second
segment now. Or almost all of it. Final byte is missing for some reason.
Diffstat (limited to 'subx/apps/survey.subx')
-rw-r--r--subx/apps/survey.subx8
1 files changed, 4 insertions, 4 deletions
diff --git a/subx/apps/survey.subx b/subx/apps/survey.subx
index 0a167132..58de2b66 100644
--- a/subx/apps/survey.subx
+++ b/subx/apps/survey.subx
@@ -2619,7 +2619,7 @@ $emit-headers:end:
 emit-elf-header:  # out : (address buffered-file), segments : (address stream {string, segment-info}), labels : (address stream {string, label-info})
     # pseudocode
     #   *Elf_e_entry = get(labels, "Entry")->address
-    #   *Elf_e_phnum = segments->write / 20         # size of a row
+    #   *Elf_e_phnum = segments->write / 16         # size of a row
     #   emit-hex-array(out, Elf_header)
     #
     # . prolog
@@ -2645,13 +2645,13 @@ emit-elf-header:  # out : (address buffered-file), segments : (address stream {s
     8b/copy                         1/mod/*+disp8   0/rm32/EAX    .           .             .           0/r32/EAX   8/disp8         .                 # copy *(EAX+8) to EAX
     # . *Elf_e_entry = EAX
     89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Elf_e_entry/disp32                # copy EAX to *Elf_e_entry
-    # *Elf_e_phnum = segments->write / 0x20
+    # *Elf_e_phnum = segments->write / 0x10
     # . EAX = segments
     8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           0/r32/EAX   0xc/disp8       .                 # copy *(EBP+12) to EAX
     # . len/EAX = segments->write
     8b/copy                         0/mod/indirect  0/rm32/EAX    .           .             .           0/r32/EAX   .               .                 # copy *EAX to EAX
-    # . EAX = len / 0x20  (destroying EDX)
-    b9/copy-to-ECX  0x20/imm32
+    # . EAX = len / 0x10  (destroying EDX)
+    b9/copy-to-ECX  0x10/imm32
     31/xor                          3/mod/direct    2/rm32/EDX    .           .             .           2/r32/EDX   .               .                 # clear EDX
     f7          7/subop/idiv        3/mod/direct    1/rm32/ECX    .           .             .           .           .               .                 # divide EDX:EAX by ECX, storing quotient in EAX and remainder in EDX
     # . *Elf_e_phnum = EAX