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 "l.h" | 8 #include "l.h" |
9 #include "../ld/lib.h" | 9 #include "../ld/lib.h" |
10 #include "../ld/pe.h" | 10 #include "../ld/pe.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 default: | 141 default: |
142 l = sizeof(oh); | 142 l = sizeof(oh); |
143 dd = oh.DataDirectory; | 143 dd = oh.DataDirectory; |
144 break; | 144 break; |
145 } | 145 } |
146 ········ | 146 ········ |
147 PEFILEHEADR = rnd(sizeof(dosstub)+sizeof(fh)+l+sizeof(sh), PEFILEALIGN); | 147 PEFILEHEADR = rnd(sizeof(dosstub)+sizeof(fh)+l+sizeof(sh), PEFILEALIGN); |
148 PESECTHEADR = rnd(PEFILEHEADR, PESECTALIGN); | 148 PESECTHEADR = rnd(PEFILEHEADR, PESECTALIGN); |
149 nextsectoff = PESECTHEADR; | 149 nextsectoff = PESECTHEADR; |
150 nextfileoff = PEFILEHEADR; | 150 nextfileoff = PEFILEHEADR; |
| 151 |
| 152 // some mingw libs depend on this symbol, for example, FindPESectionByNa
me |
| 153 xdefine("__image_base__", SDATA, PEBASE); |
151 } | 154 } |
152 | 155 |
153 static void | 156 static void |
154 pewrite(void) | 157 pewrite(void) |
155 { | 158 { |
156 cseek(0); | 159 cseek(0); |
157 cwrite(dosstub, sizeof dosstub); | 160 cwrite(dosstub, sizeof dosstub); |
158 strnput("PE", 4); | 161 strnput("PE", 4); |
159 // TODO: This code should not assume that the | 162 // TODO: This code should not assume that the |
160 // memory representation is little-endian or | 163 // memory representation is little-endian or |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 set(SizeOfStackReserve, pe64 ? 0x00200000 : 0x00100000); | 667 set(SizeOfStackReserve, pe64 ? 0x00200000 : 0x00100000); |
665 // account for 2 guard pages | 668 // account for 2 guard pages |
666 set(SizeOfStackCommit, (pe64 ? 0x00200000 : 0x00100000) - 0x2000
); | 669 set(SizeOfStackCommit, (pe64 ? 0x00200000 : 0x00100000) - 0x2000
); |
667 } | 670 } |
668 set(SizeOfHeapReserve, 0x00100000); | 671 set(SizeOfHeapReserve, 0x00100000); |
669 set(SizeOfHeapCommit, 0x00001000); | 672 set(SizeOfHeapCommit, 0x00001000); |
670 set(NumberOfRvaAndSizes, 16); | 673 set(NumberOfRvaAndSizes, 16); |
671 | 674 |
672 pewrite(); | 675 pewrite(); |
673 } | 676 } |
OLD | NEW |