Thread overview
State of Windows x64 COFF support?
Feb 19, 2015
Etienne
Feb 19, 2015
Etienne
Feb 19, 2015
ketmar
Feb 19, 2015
Etienne
Feb 20, 2015
Kagamin
February 19, 2015
I'm having corrupt symbol table errors on a Win64 build of a big application, I can't find a way around it. I'm wondering if the COFF support is still experimental in DMD?

Thanks!
February 19, 2015
On 2015-02-19 11:39 AM, Etienne wrote:
> I'm having corrupt symbol table errors on a Win64 build of a big
> application, I can't find a way around it. I'm wondering if the COFF
> support is still experimental in DMD?
>
> Thanks!

I just counted 67k sections using a printf in DMD... The limit is 65k so that explains that.
February 19, 2015
On Thu, 19 Feb 2015 13:29:58 -0500, Etienne wrote:

> On 2015-02-19 11:39 AM, Etienne wrote:
>> I'm having corrupt symbol table errors on a Win64 build of a big application, I can't find a way around it. I'm wondering if the COFF support is still experimental in DMD?
>>
>> Thanks!
> 
> I just counted 67k sections using a printf in DMD... The limit is 65k so that explains that.

i remember that DMD creates one section for each function (to allow smartlink feature). with templates this can be alot. maybe it needs new cli flag "--collapse-sections" or something like it.

February 19, 2015
On 2015-02-19 1:41 PM, ketmar wrote:
>
> i remember that DMD creates one section for each function (to allow
> smartlink feature). with templates this can be alot. maybe it needs new
> cli flag "--collapse-sections" or something like it.
>

I watched the section names and discovered over 20,000 sections named : .debug$S

According to the code, a new .debug$S section is created every time it is searched with the flag IMAGE_SCN_LNK_COMDAT in:

https://github.com/D-Programming-Language/dmd/blob/de6fccf8391b1dfdb959fa0f089920c2c8e6aff8/src/backend/mscoffobj.c#L1724

I deleted this flag and now the program links correctly with COFF with <50k sections.

It would have been easier to debug with an error in mscoffobj.c:1591:

assert(scnhdr_cnt < 65536, "Too many symbols for COFF format");

https://github.com/D-Programming-Language/dmd/blob/de6fccf8391b1dfdb959fa0f089920c2c8e6aff8/src/backend/mscoffobj.c#L1591

With this simple patch on the compiler, there are stil some errors compiling Botan on win64, but they are not related to the COFF format anymore.
February 20, 2015
Implementations can have bugs, probably COFF support wasn't stress tested.