From 549099384589fcbca3f7bc2f9b60473708f22e82 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 15 Jul 2019 16:39:13 -0700 Subject: 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. --- subx/apps/survey | Bin 40460 -> 40460 bytes subx/apps/survey.subx | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'subx/apps') diff --git a/subx/apps/survey b/subx/apps/survey index 62ee325e..93e7afc1 100755 Binary files a/subx/apps/survey and b/subx/apps/survey differ 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 -- cgit 1.4.1-2-gfad0 v class='alt'>
57deeb86 ^
fe7f8ca0 ^
b4c2c703 ^
811b7c28 ^

b4c2c703 ^
811b7c28 ^











cba63cf3 ^


a66c4a26 ^
fe7f8ca0 ^
cba63cf3 ^
471fc680 ^
cba63cf3 ^
a2853ab6 ^
cba63cf3 ^
ce9e6572 ^
8fa87054 ^


a66c4a26 ^

f027adc0 ^
08f08fb9 ^
d8084b41 ^
08f08fb9 ^
d8084b41 ^

08f08fb9 ^





cba63cf3 ^
3de15ddd ^

d8084b41 ^
24e68318 ^
d8084b41 ^

d36c43ff ^
d8084b41 ^

cba63cf3 ^
b4250dbc ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59