Rev 7696 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7696 | Rev 7983 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | (* |
1 | (* |
2 | BSD 2-Clause License |
2 | BSD 2-Clause License |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | Copyright (c) 2018-2019, Anton Krotov |
4 | Copyright (c) 2018-2019, Anton Krotov |
5 | All rights reserved. |
5 | All rights reserved. |
Line 114... | Line 114... | ||
114 | ImportTable: CHL.INTLIST; |
114 | ImportTable: CHL.INTLIST; |
115 | ILen, libcount, isize: INTEGER; |
115 | ILen, libcount, isize: INTEGER; |
Line 116... | Line 116... | ||
116 | 116 | ||
Line -... | Line 117... | ||
- | 117 | icount, dcount, ccount: INTEGER; |
|
Line 117... | Line 118... | ||
117 | icount, dcount, ccount: INTEGER; |
118 | |
118 | 119 | code: CHL.BYTELIST; |
|
Line 119... | Line 120... | ||
119 | 120 | ||
Line 139... | Line 140... | ||
139 | header.mem := align(header.size + program.stack + program.bss + PARAM_SIZE * 2 + 4096, FileAlignment); |
140 | header.mem := align(header.size + program.stack + program.bss + PARAM_SIZE * 2 + 4096, FileAlignment); |
140 | header.sp := base + header.mem - PARAM_SIZE * 2; |
141 | header.sp := base + header.mem - PARAM_SIZE * 2; |
141 | header.param := header.sp; |
142 | header.param := header.sp; |
142 | header.path := header.param + PARAM_SIZE; |
143 | header.path := header.param + PARAM_SIZE; |
Line 143... | Line -... | ||
143 | - | ||
- | 144 | ||
144 | 145 | code := program.code; |
|
145 | reloc := program.rel_list.first(BIN.RELOC); |
146 | reloc := program.rel_list.first(BIN.RELOC); |
Line 146... | Line 147... | ||
146 | WHILE reloc # NIL DO |
147 | WHILE reloc # NIL DO |
147 | 148 | ||
Line 148... | Line 149... | ||
148 | L := BIN.get32le(program.code, reloc.offset); |
149 | L := BIN.get32le(code, reloc.offset); |
Line 149... | Line 150... | ||
149 | delta := 3 - reloc.offset - text; |
150 | delta := 3 - reloc.offset - text; |
150 | 151 | ||
151 | CASE reloc.opcode OF |
152 | CASE reloc.opcode OF |
Line 152... | Line 153... | ||
152 | 153 | ||
153 | |BIN.RIMP: |
154 | |BIN.RIMP: |
Line 154... | Line 155... | ||
154 | iproc := BIN.GetIProc(program, L); |
155 | iproc := BIN.GetIProc(program, L); |
155 | BIN.put32le(program.code, reloc.offset, idata + iproc.label) |
156 | BIN.put32le(code, reloc.offset, idata + iproc.label) |
Line 156... | Line 157... | ||
156 | 157 | ||
157 | |BIN.RBSS: |
158 | |BIN.RBSS: |
Line 158... | Line 159... | ||
158 | BIN.put32le(program.code, reloc.offset, L + bss) |
159 | BIN.put32le(code, reloc.offset, L + bss) |
159 | 160 | ||
Line 160... | Line 161... | ||
160 | |BIN.RDATA: |
161 | |BIN.RDATA: |
161 | BIN.put32le(program.code, reloc.offset, L + data) |
162 | BIN.put32le(code, reloc.offset, L + data) |
Line 162... | Line 163... | ||
162 | 163 | ||
163 | |BIN.RCODE: |
164 | |BIN.RCODE: |
Line 164... | Line 165... | ||
164 | BIN.put32le(program.code, reloc.offset, BIN.GetLabel(program, L) + text) |
165 | BIN.put32le(code, reloc.offset, BIN.GetLabel(program, L) + text) |
165 | 166 | ||
166 | |BIN.PICDATA: |
167 | |BIN.PICDATA: |
Line 167... | Line 168... | ||
167 | BIN.put32le(program.code, reloc.offset, L + data + delta) |
168 | BIN.put32le(code, reloc.offset, L + data + delta) |
168 | 169 | ||
Line 169... | Line 170... | ||
169 | |BIN.PICCODE: |
170 | |BIN.PICCODE: |
Line 170... | Line 171... | ||
170 | BIN.put32le(program.code, reloc.offset, BIN.GetLabel(program, L) + text + delta) |
171 | BIN.put32le(code, reloc.offset, BIN.GetLabel(program, L) + text + delta) |
171 | 172 | ||
Line 196... | Line 197... | ||
196 | WR.Write32LE(File, header.mem); |
197 | WR.Write32LE(File, header.mem); |
197 | WR.Write32LE(File, header.sp); |
198 | WR.Write32LE(File, header.sp); |
198 | WR.Write32LE(File, header.param); |
199 | WR.Write32LE(File, header.param); |
199 | WR.Write32LE(File, header.path); |
200 | WR.Write32LE(File, header.path); |
Line 200... | Line 201... | ||
200 | 201 | ||
201 | CHL.WriteToFile(File, program.code); |
202 | CHL.WriteToFile(File, code); |
Line 202... | Line 203... | ||
202 | WR.Padding(File, FileAlignment); |
203 | WR.Padding(File, FileAlignment); |
203 | 204 |