OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // PE (Portable Executable) file writing | 5 // PE (Portable Executable) file writing |
6 // http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx | 6 // http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx |
7 | 7 |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "l.h" | 10 #include "l.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 diag("unknown PE architecture"); | 198 diag("unknown PE architecture"); |
199 errorexit(); | 199 errorexit(); |
200 case '6': | 200 case '6': |
201 fh.Machine = IMAGE_FILE_MACHINE_AMD64; | 201 fh.Machine = IMAGE_FILE_MACHINE_AMD64; |
202 break; | 202 break; |
203 case '8': | 203 case '8': |
204 fh.Machine = IMAGE_FILE_MACHINE_I386; | 204 fh.Machine = IMAGE_FILE_MACHINE_I386; |
205 break; | 205 break; |
206 } | 206 } |
207 | 207 |
208 if(!debug['s']) { | |
209 IMAGE_SECTION_HEADER *symsect; | |
210 symsect = new_section(".symdat", 8+symsize+lcsize, 0); | |
211 symsect->Characteristics = IMAGE_SCN_MEM_READ| | |
212 IMAGE_SCN_CNT_INITIALIZED_DATA; | |
213 } | |
214 | |
215 add_import_table(); | 208 add_import_table(); |
216 | 209 |
217 fh.NumberOfSections = nsect; | 210 fh.NumberOfSections = nsect; |
218 fh.TimeDateStamp = time(0); | 211 fh.TimeDateStamp = time(0); |
219 fh.SizeOfOptionalHeader = sizeof(oh); | 212 fh.SizeOfOptionalHeader = sizeof(oh); |
220 fh.Characteristics = IMAGE_FILE_RELOCS_STRIPPED| | 213 fh.Characteristics = IMAGE_FILE_RELOCS_STRIPPED| |
221 IMAGE_FILE_EXECUTABLE_IMAGE|IMAGE_FILE_DEBUG_STRIPPED; | 214 IMAGE_FILE_EXECUTABLE_IMAGE|IMAGE_FILE_DEBUG_STRIPPED; |
222 if(thechar == '8') | 215 if(thechar == '8') |
223 fh.Characteristics |= IMAGE_FILE_32BIT_MACHINE; | 216 fh.Characteristics |= IMAGE_FILE_32BIT_MACHINE; |
224 | 217 |
(...skipping 20 matching lines...) Expand all Loading... |
245 oh.SizeOfHeaders = PERESERVE; | 238 oh.SizeOfHeaders = PERESERVE; |
246 oh.Subsystem = 3; // WINDOWS_CUI | 239 oh.Subsystem = 3; // WINDOWS_CUI |
247 oh.SizeOfStackReserve = 0x00200000; | 240 oh.SizeOfStackReserve = 0x00200000; |
248 oh.SizeOfStackCommit = 0x00001000; | 241 oh.SizeOfStackCommit = 0x00001000; |
249 oh.SizeOfHeapReserve = 0x00100000; | 242 oh.SizeOfHeapReserve = 0x00100000; |
250 oh.SizeOfHeapCommit = 0x00001000; | 243 oh.SizeOfHeapCommit = 0x00001000; |
251 oh.NumberOfRvaAndSizes = 16; | 244 oh.NumberOfRvaAndSizes = 16; |
252 | 245 |
253 pewrite(); | 246 pewrite(); |
254 } | 247 } |
OLD | NEW |