idata allegedly missing (Win32)

Paul Edwards mutazilah@gmail.com
Thu May 1 07:06:39 GMT 2025


Resending without attachment as it didn't appear on the archives
when it normally does.



On Thu, May 1, 2025 at 4:58 PM Paul Edwards <mutazilah@gmail.com> wrote:
>
> Hi.
>
> This problem doesn't affect me personally - I am just
> reporting it for the record in case anyone is interested.
>
>
> I'm also not the one who did the technical analysis.
> But if anyone has any technical questions, I can ask
> for more details and will likely get them. For now I am
> just providing what I have.
>
>
> So using this:
>
> https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/makefile.std
>
> and the tools provided by http://pdos.org/pdos.zip
>
> I am able to produce Win32 executables successfully
> using pdld (ie not related to binutils):
>
>
> Here it is running on my Windows 2000 system:
>
> D:\devel\pdos\pdpclib>pdmake -f makefile.std
>
> ...
>
> pdas --oformat coff -o dllcrt.obj dllcrt.s
> rm -f dllcrt.s
> as86 -o winsupa.obj -f coff winsupa.asm
> rm -f temp.lib
> xar r temp.lib stdio.obj string.obj stdlib.obj winsupa.obj
> xar r temp.lib start.obj time.obj errno.obj assert.obj signal.obj
> xar r temp.lib locale.obj ctype.obj setjmp.obj math.obj
> xar s temp.lib
> pdld -s --no-insert-timestamp -o msvcrt.dll --shared --out-implib
> msvcrt.lib dllcrt.obj temp.lib
> ../src/kernel32.lib
> rm -f temp.lib
> pdld -s -nostdlib --no-insert-timestamp -o pdptest.exe w32start.obj
> pdptest.obj msvcrt.lib winsupa.obj setjmp.obj
>
> D:\devel\pdos\pdpclib>pdptest abc def
> welcome to pdptest
> main function is at 00401234
> allocating 10 bytes
> m1 is 003F2C80
> allocating 20 bytes
> m2 is 003F2C98
> stack is around 0022FF80
> printing arguments
> argc = 3
> arg 0 is <pdptest>
> arg 1 is <abc>
> arg 2 is <def>
>
> D:\devel\pdos\pdpclib>
>
>
> And that does everything I want, so I'm fine.
>
> However, someone substituted this final link:
>
> pdld -s -nostdlib --no-insert-timestamp -o pdptest.exe w32start.obj
> pdptest.obj msvcrt.lib winsupa.obj setjmp.obj
>
> with ld (ie binutils) from mingw - versions 2.38 and 2.42 were tried,
> and that produced an executable that didn't work (no output
> produced).
>
> A bug report was made to the pdld author in case they had
> produced an invalid library (either kernel32.lib or msvcrt.lib)
> that was causing binutils to choke.
>
> The pdld author insists that his archives are fine, and he
> took a guess at what was wrong with binutils. So I am
> reporting that guess in case anyone is interested.
>
>
> I compared the .idata sections in the executables (see attached
> pdldhd.txt and gnuldhd.txt and search for "Start of .idata" or the
> attached screenshot).
>
> It seems that GNU LD pdptest.exe is missing Import Directory Table
> (https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section)
> - the 20 bytes 28500000 00000000 00000000 F2500000 58500000.
>
> My guess is that GNU LD is expecting some undocumented archive member
> to provide the Import Directory Table instead of doing it on its own
> like PDLD does.
>
>
> And he notes that gnu ld apparently silently fails instead of
> giving an error. So I assume you don't think that is appropriate
> behavior. If you don't want libraries produced by other tools
> to be used - fine, but at least produce an error message when
> someone provides a "bad" library. ie don't silently produce a
> bad executable that fails without explanation.
>
>
> The way he has worded that suggests to me that there is
> some wiggle room - maybe there is some documentation
> to say that an archive contains an "import directory table"
> and he just doesn't know where that documentation is.
> I still consider it to be a bug if the archive is violating the
> documentation and ld silently produces an invalid
> executable, but YMMV.
>
>
> I'm not affected because I don't mix and match pdld and ld,
> and nor does he, and nor do most people, so normally
> no-one cares.
>
> But I care enough to document the issue publicly in case
> it helps someone else in a similar situation.
>
> I have placed what I have access to at:
>
> http://pdos.org/ldidata.zip
>
> That has the msvcrt.lib that is potentially choking binutils.
> And it has a doit.bat with the command to produce
> pdptest.exe with pdld - and the working pdptest.exe.
> I don't have mingw installed so can't reproduce the
> non-working executable myself. If you really need that
> done, I can ask someone to do it for me. I also provided
> the mentioned screenshot and text files. I'll also attach
> the screenshot to this message.
>
> Thanks. Paul.


More information about the Binutils mailing list