summaryrefslogtreecommitdiff
path: root/src/cmd/ld/pe.c
diff options
context:
space:
mode:
authorEvan Shaw <chickencha@gmail.com>2010-04-13 16:13:53 -0700
committerEvan Shaw <chickencha@gmail.com>2010-04-13 16:13:53 -0700
commit7ca61e6dfefcbf33d392ee8bf3b153b53732681f (patch)
treecb5d9fe03d5ca37782df18f2c3debd14bb01e3c6 /src/cmd/ld/pe.c
parentdea11104c5421381888410e9eac63ab0734202e6 (diff)
downloadgo-7ca61e6dfefcbf33d392ee8bf3b153b53732681f.tar.gz
8l: add DOS stub to PE binaries
R=rsc CC=golang-dev http://codereview.appspot.com/915041 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/ld/pe.c')
-rw-r--r--src/cmd/ld/pe.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/cmd/ld/pe.c b/src/cmd/ld/pe.c
index 15bd7b70d..d3439abfb 100644
--- a/src/cmd/ld/pe.c
+++ b/src/cmd/ld/pe.c
@@ -11,6 +11,28 @@
#include "../ld/lib.h"
#include "../ld/pe.h"
+// DOS stub that prints out
+// "This program cannot be run in DOS mode."
+static char dosstub[] =
+{
+ 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+ 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd,
+ 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,
+ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72,
+ 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f,
+ 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e,
+ 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20,
+ 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a,
+ 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
static int pe64;
static int nsect;
static int sect_virt_begin;
@@ -64,8 +86,7 @@ pewrite(void)
{
int i, j;
- strnput("MZ", 0x3c);
- LPUT(0x40); // file offset to PE header
+ write(cout, dosstub, sizeof dosstub);
strnput("PE", 4);
for (i=0; i<sizeof(fh); i++)