goversioninfo icon indicating copy to clipboard operation
goversioninfo copied to clipboard

rsrc merge failure: corrupt .rsrc section

Open AllenDang opened this issue 6 years ago • 11 comments

C:/Tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001\exe\a.out.exe: .rsrc merge failure: corrupt .rsrc section

The go generate command is //go:generate goversioninfo -64 -icon=./resource/pipeline.ico -manifest=./resource/PipeIt.exe.manifest

My platform is Windows 10 64bit with go version go1.13.5 windows/amd64

AllenDang avatar Jan 20 '20 06:01 AllenDang

Did you end up fixing this at all?

jonatino avatar Apr 21 '20 03:04 jonatino

I don't have a Windows machine handy unfortunately - can you post the files so we can reproduce?

josephspurrier avatar Jun 19 '20 02:06 josephspurrier

~~As suggested in another issue, go build [...] -ldflags "-linkmode=internal" resolved this issue for me. No strange output to log.~~

DON'T USE THIS! I was debugging for a solid two hours and found that linkmode=internal does NOT work if you use third-party packages. sigh

edit: Looks like the exe builds and works just fine with this error, also the details and icon and manifest are merged(?) into the exe.

lieuweberg avatar Jul 02 '20 13:07 lieuweberg

Is there any way you can post the minimal fully executable code for me to test with?

josephspurrier avatar Jul 03 '20 15:07 josephspurrier

I have a similar problem. Created a test repo here: https://github.com/pitw/test-goversioninfo

pitw avatar Jul 06 '20 12:07 pitw

While I don't use goversioninfo, I did experience the same issue when generating syso files using rsrc on Windows 10.

.syso files generated with rcrc -arch amd64 -manifest main.manifest -ico main.ico -o main.rsrc leads to a failure: corrupt .rsrc section error during "go build".

However, .syso files generated with rcrc -arch amd64 -manifest main.manifest -o main.rsrc work fine.

I finally managed to resolve the issue by downgrading from TDM-GCC 9.2.0 to TDM-GCC 5.1.0-2.

Kudos to @Rodolfoag whose answer I found here.

@pitw Can confirm your test project compiles successfully using TDM-GCC 5.1.0-2.

ldstein avatar Jul 17 '20 01:07 ldstein

Hello. rsrc has at least one bug : it doesn't align resources, while this seems mandatory (most tools can't read them properly otherwise) windres aligns them on 8 bytes.

Edit : Tried a quick and dirty fix on pitw's test repo. It worked.

go get github.com/tc-hib/goversioninfo/cmd/goversioninfo
go generate
go build

⇨ No error.

go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo
go generate
go build

.rsrc merge failure: corrupt .rsrc section

tc-hib avatar Aug 13 '20 16:08 tc-hib

Nice, replaced github.com/akavel/rsrc with github.com/tc-hib/rsrc in my project. Now building successfully with TDM-GCC 9.2.0.

Thanks for the heads up @tc-hib

ldstein avatar Aug 14 '20 01:08 ldstein

When having C code to compile (such as github.com/mattn/go-sqlite3) + resource.syso exists, this error may occur

linquize avatar Feb 23 '21 11:02 linquize

@ldstein and others: if you are still using my fork please use the original one again as the bug has been properly fixed by akavel. I've developed my own tool too: https://github.com/tc-hib/go-winres

And I'd like to delete my forks of rsrc and goversioninfo as my quick fix was bad.

tc-hib avatar Mar 05 '21 18:03 tc-hib

I'm sorry, looks like I talked a bit too early. Current version of rsrc still seems to require a bug fix.

tc-hib avatar Mar 07 '21 10:03 tc-hib

Just updated github.com/akavel/rsrc to v0.10.2. but as @tc-hib said, looks like there is still a bug.

josephspurrier avatar Aug 07 '21 13:08 josephspurrier