mingw built exe fails to run

10 views
Skip to first unread message

Alex Brainman

unread,
Jan 19, 2010, 11:32:16 PM1/19/10
to golang-nuts

I have used instructions in src/pkg/runtime/pchw/README to cross
compile a small program

package main

func main() {
print("hello\n")
}

and runtime pkg with GOOS=mingw.

Build completes without any errors, resulting executable runs on
windows, but it doesn't print my "hello\n", just exits.

Looking in the runtime code for mingw, I can see, that it searches for
entry points to some Windows system dlls, but the exe itself doesn't
have them (import table is missing).

Isn't generated PE exe supposed to have dll entries?

Am I missing something here?

I suspect it is something "to be done". If that's the case, are there
any other things to overcome?

Thank you for your comments


Alex

Alex Brainman

unread,
Jan 20, 2010, 11:15:26 PM1/20/10
to golang-nuts

> Isn't generated PE exe supposed to have dll entries?
>

After some head banging, I have discovered, that my exe runs fine on
WinXP, but not on Win2000.

It seems, (the only reference on the Internet I can find is
http://www.phreedom.org/solar/code/tinype/) that WinXP PE loader is
smart enough to load kernel32.dll automatically. On the other hand,
Win2000 needs all imported functions explicitly listed in PE import
table.

So, if we want Win2000 supported, it looks like we need to generate
import table.


Alex

Hector

unread,
Jan 21, 2010, 5:45:59 PM1/21/10
to golang-nuts
LOL, I'm tempted to say screw Win2k...

On Jan 21, 4:15 am, Alex Brainman <alex.brain...@gmail.com> wrote:
> > Isn't generated PE exe supposed to have dll entries?
>
> After some head banging, I have discovered, that my exe runs fine on
> WinXP, but not on Win2000.
>

> It seems, (the only reference on the Internet I can find ishttp://www.phreedom.org/solar/code/tinype/) that WinXP PE loader is

Alex Brainman

unread,
Jan 21, 2010, 9:10:14 PM1/21/10
to golang-nuts

> LOL, I'm tempted to say screw Win2k...
>

Don't waste your time. I'll be away for a week, when back, I'll try to
tackle it. (I haven't done anything like that before, but I'll have a
go).

I believe, your trick with not providing import table will only work
for kernel32.dll, but not other dlls..

I think, better way to approach this is to import LoadLibrary and
GetProcAddress and then use these to load others during runtime.

Alex

Alex Brainman

unread,
Feb 3, 2010, 12:25:44 AM2/3/10
to golang-nuts
Hector,

On Jan 22, 9:45 am, Hector <hector...@gmail.com> wrote:
> LOL, I'm tempted to say screw Win2k...
>

I've made the change and it seems to be working OK on my Win2k. Should
I send it to you to have a look? There are only 2 files changed pe.c
and pe.h.

Alex

Reply all
Reply to author
Forward
0 new messages