-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/link: dwarf sections cause program not to run on Windows #20183
Comments
Running
After guessing and disabling writing of
The main difference in binary seems that the "/4" section is first (before ".text") in the broken version, but in the good version it's after ".tls". Not sure what the proper fix is though. |
I can reproduce this with:
I suspect your program (unlike everyone elses) uses some symbols from runtime/runtime.go. So this triggers .debug_gdb_scripts exra section to be included in your exe. If you want not to have .debug_gdb_scripts (as everyone else), your patch is good for that. Maybe we could just do what you did for all windows users. But I would like to understand what .debug_gdb_scripts is for, before we ignore it. Thank you for creating this issue. Alex |
debug_gdb_scripts seem to be for formatting Go structures in gdb. As a temporary fix, it sounds good, but I'm guessing there is a proper fix. Unfortunately, dwarf is beyond my knowledge at this moment. The only thing I was able to notice was that the order of file sections was different when the gdb_script was included (seen with PEInsider)... My guess is that when the ordering is fixed, then the problem should disappear. Which leads me to conclude, that either there must be some buggy section sorting somewhere or that order of adding the sections to the list itself is the problem. (But as I said, at the moment this stuff is beyond my knowledge.) |
Yes, there must be proper fix. But I do not know what it is.
Welcome to the club.
Yes.
Notice how go.o (cmd/link generates that) has .debug_gdb_scripts section at position 9, while a.exe (gcc generates that) has .debug_gdb_scripts first on the list?
I don't know what the problem is. I will try debug this, but I am not sure it is going to be quick. Alex |
Found a standalone example that can be used to reproduce this (and doesn't require adjustments to compiler):
|
It definitely is caused by the
Best theory seems to be that the alignment/file-offset is affecting it because:
Then it starts working. (Initial file http://egonelbre.com/files/go/bad.exe). PS: it seems that Rust has hit a similar issue in rust-lang/rust#25229. |
And here is a standalone
|
Indeed:
Lets see if @ianlancetaylor can help. Alex |
Also seems that the as long as the section name isn't in some predefined set, it breaks... e.g. Works:
Doesn't work:
Guess: somewhere in the linker there is a table that is used to look up VMA properties for debug sections, but the default value returned (for things not in the table) is inappropriate for Windows. |
The GNU linker source files that fail to list the Until that bug in the linker is fixed, the only reasonable option I see is to skip calling |
|
CL https://golang.org/cl/42651 mentions this issue. |
Should this issue remain open with "Blocked" label? |
Done. Alex |
I think this can be safely closed now that the issues was fixed in 42651? |
CL 42651 disables .debug_gdb_scripts section generation. It is a work around the problem that is out of our control #20183 (comment) But I hope one day we might be able to revert CL 42651 in some form. That is why I left this opened. I will let others close this if they see fit. Alex |
I think it's unlikely we can remove the gcc fix in near future, even if gcc gets fixed immediately. We could potentially replace with some other workaround:
I think it would be doable some way, but I suspect it wouldn't be worthwhile in the end. |
Sounds too hard.
That might be quite simple to do, if we know what to do. Maybe we could ask there https://sourceware.org/bugzilla/show_bug.cgi?id=21459
Sounds too hard and might slow down build process.
Close this issue, if you don't think there is anything for us to do here. Alex |
Nick Clifton provided a linker script that can be used to place the
And then invoke gcc with that script: |
Thanks to Nick Clifton and you - I suspect it might work just fine for our purpose. I will try it unless someone beats me to it. Mind you, currently Go does not add .debug_gdb_scripts sections when using external linker, so we need to fix that first (it is issue #20218). Alex |
CL https://golang.org/cl/43331 mentions this issue. |
Cross-reference from CL for search: For The script can still be added manually to the executable or manually loaded in gdb, when necessary. |
What did you do?
I have a program that fails to run with compiler 29f0619 and later.
Reverting that specific commit fixes the problem.
What did you expect to see?
Program starts as usual.
What did you see instead?
I see a message "This app cannot run on your PC".
System details
Microsoft Windows [Version 10.0.10586]
CC: @alexbrainman
The text was updated successfully, but these errors were encountered: