Rev 8677 | Rev 8716 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8677 | Rev 8678 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | TCCState* s1; |
39 | TCCState* s1; |
40 | IMAGE_MEOS_FILE_HEADER header; |
40 | IMAGE_MEOS_FILE_HEADER header; |
41 | meos_section_info* code_sections; |
41 | meos_section_info* code_sections; |
42 | meos_section_info* data_sections; |
42 | meos_section_info* data_sections; |
43 | meos_section_info* bss_sections; |
43 | meos_section_info* bss_sections; |
44 | meos_section_info* imp_sections; // Pointers to imported libraries and functions |
- | |
45 | } me_info; |
44 | } me_info; |
Line 46... | Line 45... | ||
46 | 45 | ||
Line 63... | Line 62... | ||
63 | for (si=me->bss_sections;si;si=si->next) |
62 | for (si=me->bss_sections;si;si=si->next) |
64 | { |
63 | { |
65 | if (si->sec_num==num) |
64 | if (si->sec_num==num) |
66 | return si; |
65 | return si; |
67 | } |
66 | } |
68 | for (si=me->imp_sections;si;si=si->next) |
- | |
69 | { |
- | |
70 | if (si->sec_num==num) |
- | |
71 | return si; |
- | |
72 | } |
- | |
73 | return (meos_section_info*)0; |
67 | return (meos_section_info*)0; |
74 | } |
68 | } |
Line 75... | Line 69... | ||
75 | 69 | ||
76 | void build_reloc(me_info* me) |
70 | void build_reloc(me_info* me) |
Line 166... | Line 160... | ||
166 | si->next=me->bss_sections; |
160 | si->next=me->bss_sections; |
167 | si->sec_num=i; |
161 | si->sec_num=i; |
168 | me->bss_sections=si; |
162 | me->bss_sections=si; |
169 | continue; |
163 | continue; |
170 | } |
164 | } |
171 | if (strcmp(".imp.@.",s->name)==0) |
- | |
172 | { |
- | |
173 | si=tcc_malloc(sizeof(meos_section_info)); |
- | |
174 | si->data=s->data; |
- | |
175 | si->data_size=s->data_offset; |
- | |
176 | si->next=me->imp_sections; |
- | |
177 | si->sec_num=i; |
- | |
178 | me->imp_sections=si; |
- | |
179 | continue; |
- | |
180 | } |
- | |
181 | } |
165 | } |
182 | int addr; |
166 | int addr; |
183 | addr=sizeof(IMAGE_MEOS_FILE_HEADER); |
167 | addr=sizeof(IMAGE_MEOS_FILE_HEADER); |
184 | for (si=me->code_sections;si;si=si->next) |
168 | for (si=me->code_sections;si;si=si->next) |
185 | { |
169 | { |
Line 189... | Line 173... | ||
189 | for (si=me->data_sections;si;si=si->next) |
173 | for (si=me->data_sections;si;si=si->next) |
190 | { |
174 | { |
191 | si->sh_addr=addr; |
175 | si->sh_addr=addr; |
192 | addr+=si->data_size; |
176 | addr+=si->data_size; |
193 | } |
177 | } |
194 | for (si=me->imp_sections;si;si=si->next) |
- | |
195 | { |
- | |
196 | si->sh_addr=addr; |
- | |
197 | addr+=si->data_size; |
- | |
198 | } |
- | |
199 | me->header.image_size=addr; |
178 | me->header.image_size=addr; |
200 | for (si=me->bss_sections;si;si=si->next) |
179 | for (si=me->bss_sections;si;si=si->next) |
201 | { |
180 | { |
202 | si->sh_addr=addr; |
181 | si->sh_addr=addr; |
203 | addr+=si->data_size; |
182 | addr+=si->data_size; |
Line 288... | Line 267... | ||
288 | meos_section_info* si; |
267 | meos_section_info* si; |
289 | for(si=me.code_sections;si;si=si->next) |
268 | for(si=me.code_sections;si;si=si->next) |
290 | fwrite(si->data,1,si->data_size,f); |
269 | fwrite(si->data,1,si->data_size,f); |
291 | for (si=me.data_sections;si;si=si->next) |
270 | for (si=me.data_sections;si;si=si->next) |
292 | fwrite(si->data,1,si->data_size,f); |
271 | fwrite(si->data,1,si->data_size,f); |
293 | // IMPORTANT: Write ".imp.@." sections at the very end! |
- | |
294 | // BSS sections don't count, they should not be in the file at all |
- | |
295 | // Cause MENUET header filled assuming that file size does not include BSS |
- | |
296 | // We just emit it for smaller entrophia, sometimes |
- | |
297 | // it makes the kex file being packed better |
- | |
298 | for (si=me.imp_sections;si;si=si->next) |
- | |
299 | fwrite(si->data,1,si->data_size,f); |
- | |
300 | if (!s1->nobss) |
272 | if (!s1->nobss) |
301 | { |
273 | { |
302 | for (si=me.bss_sections;si;si=si->next) |
274 | for (si=me.bss_sections;si;si=si->next) |
303 | { |
275 | { |
304 | if (si->data == NULL) |
276 | if (si->data == NULL) |
Line 325... | Line 297... | ||
325 | register int val; |
297 | register int val; |
326 | asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize)); |
298 | asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize)); |
327 | return val; |
299 | return val; |
328 | } |
300 | } |
Line -... | Line 301... | ||
- | 301 | ||
329 | 302 | ||
330 | char *getcwd(char *buf, size_t size) |
303 | char *getcwd(char *buf, size_t size) |
331 | { |
304 | { |
332 | int rc = get_current_folder(buf, size); |
305 | int rc = get_current_folder(buf, size); |
333 | if (rc > size) |
306 | if (rc > size) |