<div dir="ltr">I don't think the short import library supports that. With that you can undecorate names, but AFAIK you cannot define arbitrary aliases for dllexported symbols. Does mingw-w64 heavily relies on that feature?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 6, 2015 at 8:14 AM, Martell Malone <span dir="ltr"><<a href="mailto:martellmalone@gmail.com" target="_blank">martellmalone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Before I let this slip by aswell there is one big issue with switching over to the implib format for mingw-w64<div><br></div><div><div>LIBRARY "user32.dll"</div><div>EXPORTS</div><div>MessageBoxA == MessageBoxW</div></div><div><br></div><div>dlltool objct format provides us with the option of having an alias.</div><div>Can we do this in implib ?</div><div><br></div><div>What the above .def means that where MessagBoxW is called it is joined to MessageBoxA.</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 6, 2015 at 3:58 PM, Martell Malone <span dir="ltr"><<a href="mailto:martellmalone@gmail.com" target="_blank">martellmalone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class="gmail_quote">Yeah, I found that too and it (especially the way how it creates a gap between .idata$3 and .idata$4) looks really hacky. I also found that GNU ld has a special logic to order .idata$<n> sections.<br>At first I thought that I could mimic GNU ld and MSVC linker to generate the .idata section, but seems like it would really mess up the DLL import table generation code. We probably should keep the existing logic</blockquote></span><div>Yeah I don't think copying gnu ld is the way to go, it is a very hacky project to say the least :)</div><div><br></div><div><br></div><div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.8px">It feels to me that it makes more sense to add a new option to dlltool to generate short import libraries. It shouldn't be that hard. Martell, what do you think?</span></blockquote></span><div>I already wrote a replacement tool for this called genlib that will go into the mingw-w64 project.</div><div>I want to remove mingw-w64's dependancy on binutils so that we can have a clang based toolchain without binutils at all.</div><div>The notion of having dlltool as part of binutils made no sense in the first place, It should have been part of mingw to begin with.</div><div>The name was chosen to correlate to on of mingw-w64's other tools called gendef which creates the def files from parsing dll's.<br></div></div><div>I'm still finalizing the code in this and doing some tests.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.8px">I then tried to detect dlltool-style import files and read them as if they were short import libraries, so that I can keep the existing code. That didn't work well because it's not easy to detect dlltool-style import files in a reliable manner without sacrificing performance.</span></blockquote></span><div>While you might not want to merge because of this into the official project because of performance issues it might be something for the mingw-w64 users to avail of until ld supports import style libraries.</div><div><br></div><div><div>If you have the patch for this I'd like have a look at it if possible.</div></div><div><div>I'd like to try and apply this over the PECOFF for the clang 3.7 package in our msys2 distro.</div><div><br></div><div>The issue I have is I would have to get approval to switch to using genlib instead of dlltool as mingw-w64's default.</div></div><div>This would not be approved until ld supports implibs and the next version of binutils released.</div><div>As you probably well know how things work that could take months to get changed over.</div><div>I'd like to use your patch as a base for a temporary stop over until this happens</div><div><br></div><div>I'm sure the distro users of msys2 won't mind a performance hit until 3.8 rather then having no support at all.</div><div><br></div><div><br></div><div><br></div><div> </div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 10:51 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Aug 3, 2015 at 10:36 PM, Martell Malone <span dir="ltr"><<a href="mailto:martellmalone@gmail.com" target="_blank">martellmalone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">From my reading on how gnuld handles PE/COFF<div>It uses a linker script that describes how it lays out its idata section.</div><div>From i386pe.x</div><div><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">  .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)
    SORT(*)(.idata$5)
    SORT(*)(.idata$6)
    SORT(*)(.idata$7)
  }</pre></div></div></blockquote><div><br></div></span><div>Yeah, I found that too and it (especially the way how it creates a gap between .idata$3 and .idata$4) looks really hacky. I also found that GNU ld has a special logic to order .idata$<n> sections.</div><div><br></div><div>At first I thought that I could mimic GNU ld and MSVC linker to generate the .idata section, but seems like it would really mess up the DLL import table generation code. We probably should keep the existing logic.</div><div><br></div><div>I then tried to detect dlltool-style import files and read them as if they were short import libraries, so that I can keep the existing code. That didn't work well because it's not easy to detect dlltool-style import files in a reliable manner without sacrificing performance.</div><div><br></div><div>It feels to me that it makes more sense to add a new option to dlltool to generate short import libraries. It shouldn't be that hard. Martell, what do you think?</div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><pre style="word-wrap:break-word"><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">Under ld/emultempl/pep.em in binutils it describes how it converts the MS import library to its format.</div><div><font face="arial, sans-serif"><span style="white-space:normal">see here <a href="http://github.com/bminor/binutils-gdb/blob/master/ld/emultempl/pep.em#L1625" target="_blank">http://github.com/bminor/binutils-gdb/blob/master/ld/emultempl/pep.em#L1625</a><br></span></font></div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">From the code in this function and the rest of pep.em we can see how it handles it.</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">I'm sure this will make more sense to you however as you know what the MS format is.</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">I assume the conversion will have to go the other way for us</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">I think the most notable thing is the use of idata7 instead of idata6 for the dll name</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">We could use that as a check?</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">Then hijack it pulling out the function names once we see this being used and insert it into the sections like a MS generated one</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">You might have a much cleaner solution however. :)</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">If this isn't enough insight into what you need I can do more digging.</div><div style="color:rgb(34,34,34);white-space:normal;font-family:arial,sans-serif">Just ping me and let me know</div></pre></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 4, 2015 at 3:15 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ruiu added a comment.<br>
<br>
Do you know anything about how GNU ld handles these import libraries? My<br>
linker is able to read it and construct .idata section, but the resulting<br>
.idata section is not going to be in correct format. If GNU linker is able<br>
to generate a correct .idata section from this type of import libraries,<br>
there must be something I'm missing in my linker.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D11724" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11724</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></span></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>