I recently found out that instructions I had written to compile HDBC-postgresql on Windows were no longer working with Haskell Platform 2012.2.0.0. The library builds alright, but when attempting to link the built library, cabal
fails with:
Loading package HDBC-postgresql-2.3.2.1 ... ghc.exe: Unknown PEi386 section name `.idata$4' (while processing: C:/PROGRA~1/POSTGR~1/9.2/lib\libpq.a) ghc.exe: panic! (the 'impossible' happened) (GHC version 7.4.1 for i386-unknown-mingw32): loadArchive "C:/PROGRA~1/POSTGR~1/9.2/lib\\libpq.a": failed
I tried re-making libpq.a
with dlltool --no-idata4 --no-idata5
, but then the error message changed to Unknown PEi386 section name `.idata$7'
.
This seems to be GHC bug 7103.
According to the PE and COFF Specification, the dollar sign has a special meaning when included in section names, signaling a "grouped section". The linker is supposed to discard the "$" and all characters that follow it to create a merged .idata
section, where the characters following the "$" are used to determine the ordering of contributions to the merged section.
Is there a way to force dlltool
to not output grouped sections?
Alternatively, is there a way to take a GNU archive (A file), merge all grouped sections, and output the resulting merged import library (implib)?
EDIT: The same error happens with Haskell Platform 2012.4.0.0.
EDIT2 After looking at the source code of dlltool
, there doesn't appear to be a way to force it not to output grouped sections. Also, I haven't found a ready-built utility that will merge grouped sections in an object file.
For the purpose of the bounty and this question, I am changing it to: How to construct a single .idata
section given a module definition (DEF) file.