How to resolve the GHC error "Unknown partition name PEi386`.idata $ 4 '" in Windows?

I recently found out that the instructions I wrote to compile HDBC-postgresql on Windows no longer work with Haskell Platform 2012.2.0.0. The library is building in order, but trying to link the built-in cabal library fails:

  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 libpq.a with dlltool --no-idata4 --no-idata5 , but then the error message changed to Unknown PEi386 section name `.idata$7' .

GGC 7103 seems to be bug .

In accordance with the PE and COFF specifications, the dollar sign has special meaning when included in section names, signaling a “grouped section”. The linker is supposed to discard "$" and all subsequent characters to create a merged .idata , where the characters following the "$" are used to determine the order in which the merged section is contributed.

Is there a way to force dlltool not to display grouped partitions?

As an alternative, is it possible to use the GNU archive (file A), merge all grouped partitions and display the resulting combined import library (implib)?

EDIT: The same thing happens with Haskell Platform 2012.4.0.0.

EDIT2 After looking at the dlltool source code , there seems to be no way to make it not display grouped sections. In addition, I did not find a ready-made utility that combines grouped sections in an object file.

For the sake of generosity, and this question, I change it to: How to build one .idata specified for a module definition file (DEF).

+4
source share
1 answer

The linker is supposed to discard "$" and all subsequent characters to create a merged .idata section p>

Yes, but this is only the default behavior for the Microsoft linker. I don’t get fast enough on your tool chain, so just hints. The gcc compiler requires an explicit config to merge the various .idata $ x sections into a single .idata section. This is done by the SECTION directive. In mingw, which appears to be executed using a script, a sample is available here . Pay attention to this part of the script:

  .idata BLOCK(__section_alignment__) : { /* This cannot currently be handled with grouped sections. See pe.em:sort_sections. */ SORT(*)(.idata$2) SORT(*)(.idata$3) /* These zeroes mark the end of the import list. */ LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); SORT(*)(.idata$4) __IAT_start__ = .; SORT(*)(.idata$5) __IAT_end__ = .; SORT(*)(.idata$6) SORT(*)(.idata$7) } 

Pretty incomprehensible, but the shoes fit. Make sure your linker is using a script.

+1
source

Source: https://habr.com/ru/post/1443819/


All Articles