From fb18cadaa765feb3f7d8b7ac7909dc89b4856ca5 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 10 Apr 2020 15:14:34 -0700 Subject: [PATCH] fix a crash when translating apps/ex1 --- apps/survey | Bin 54048 -> 54048 bytes apps/survey.subx | 12 ++++++------ translate_subx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/survey b/apps/survey index 90dc27864a6216ffef935374af9bb963e309d350..526b06309cf53125f761815b3a46e43fd03ee595 100755 GIT binary patch delta 22 ecmZ3mjCsK_<_$M186_s)s#Ina+5E3kDG~s29SLy& delta 22 ecmZ3mjCsK_<_$M183iWas#Ina*!-_jDG~s1r3qyK diff --git a/apps/survey.subx b/apps/survey.subx index f2825525..94bd10ff 100644 --- a/apps/survey.subx +++ b/apps/survey.subx @@ -3177,7 +3177,7 @@ $emit-headers:end: emit-elf-header: # out: (addr buffered-file), segments: (addr stream {(handle array byte), segment-info}), labels: (addr stream {(handle array byte), label-info}) # pseudocode # *$Elf_e_entry = get(labels, "Entry")->address - # *$Elf_e_phnum = segments->write / 16 # size of a row + # *$Elf_e_phnum = segments->write / 20 # size of a row # emit-hex-array(out, Elf_header) # write-buffered(out, "\n") # @@ -3191,10 +3191,10 @@ emit-elf-header: # out: (addr buffered-file), segments: (addr stream {(handle a # *$Elf_e_entry = get(labels, "Entry")->address # . eax = labels 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 . # copy *(ebp+16) to eax - # . label-info/eax = get(labels, "Entry", row-size=16, "label table") + # . label-info/eax = get(labels, "Entry", row-size=24, "label table") # . . push args 68/push "label table"/imm32 - 68/push 0x10/imm32/row-size + 68/push 0x18/imm32/row-size 68/push "Entry"/imm32 50/push-eax # . . call @@ -3205,13 +3205,13 @@ emit-elf-header: # out: (addr buffered-file), segments: (addr stream {(handle a 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 / 0x10 + # *$Elf_e_phnum = segments->write / 20 # . 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 / 0x10 (destroying edx) - b9/copy-to-ecx 0x10/imm32 + # . eax = len / 20 (clobbering ecx and edx) + b9/copy-to-ecx 0x14/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 diff --git a/translate_subx b/translate_subx index ba36986a..22bcf32a 100755 --- a/translate_subx +++ b/translate_subx @@ -15,7 +15,7 @@ # sets of debug files.) # Again, that's for subsequent scripts. -set -e +set -ev ./build