<div dir="ltr"><div>newfun.obj seems broken -- dumpbin couldn't read.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 3:19 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 class=""><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>If you want to define an alias symbol "bar" to "foo" (which is an
extension you want to provide), one way is to create an object file that
defines "bar" and "__imp_bar" as aliases to "foo" and "__imp_foo",
respectively, and add that object file to the import library. As a
result, the import library file defines four symbols,
{,__imp_}{foo,bar}.</div><div><br></div><div>Do you know how to define
symbol aliases in COFF? If you don't, take a look a member of
oldnames.lib (which comes with MSVC). That library file defines bunch of
aliases, and you can do the same thing.</div></blockquote></span>Thanks for pointing me in the right direction :)<br><br>After looking at oldnames.lib I done a little more reading and I assume I do it like this then for the alias.<br><div><br>The import table points to the functions like this.<br>__imp_oldfu -> newfun.obi<br>oldfu -> newfun.obj<br></div><div>I have attached the 2 files named here.<br></div><div><br>I assume this is what you meant by Weak Externals ?<br></div></div></blockquote><div><br></div><div>Yes, that's what I meant. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 6:36 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"><div dir="ltr">Hmm, that's not correct too. All symbols listed in the archive header must be defined by some member in the archive. In other words, the header is created just by extracting all external symbols from members. It's not doable to rename symbol A to B by writing B to the archive file header.<br><div><br></div><div>By aliasing, I was suggesting adding an extra object file to an archive file containing a short import file. The extra object file is to define aliases to symbols defined by the import library.</div><div><br></div><div>Say, you are creating a DLL which defines a function symbol "foo". You need to create an import library that defines "foo" and "__imp_foo". This is what normal linkers do.</div><div><br></div><div>If you want to define an alias symbol "bar" to "foo" (which is an extension you want to provide), one way is to create an object file that defines "bar" and "__imp_bar" as aliases to "foo" and "__imp_foo", respectively, and add that object file to the import library. As a result, the import library file defines four symbols, {,__imp_}{foo,bar}.</div><div><br></div><div>Do you know how to define symbol aliases in COFF? If you don't, take a look a member of oldnames.lib (which comes with MSVC). That library file defines bunch of aliases, and you can do the same thing.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 2:25 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><span><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">The header of libuser32b.a says that it defines MessageBoxB and
__imp_MessageBoxB, but the import library file in the archive actually
defines MessageBoxA (not B). So the archive file is broken. You may want
to fix the header and try again.</blockquote></span></span><div>Yes this is how I done the alias.<br></div><span><div><br></div><div>If you consider this invalid then look at libuser32.a<br></div><div>The header defines MessageBoxA and __imp_MessageBoxB.<br></div>This should be valid yes ?<br><br></span></div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, Aug 13, 2015 at 6:19 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br></span><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The header of libuser32b.a says that it defines MessageBoxB and __imp_MessageBoxB, but the import library file in the archive actually defines MessageBoxA (not B). So the archive file is broken. You may want to fix the header and try again.</div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 2:04 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"><div><div><div><div><div><div><div><div><div><div><div><div>Hi Rui,<br><br></div>I have finished my tool to generate short import libs for mingw-w64.<br><br></div>It works fine with lld for actual symbols.<br></div>But it seems lld segfaults when I try to use and an alias as we discussed before.<br><br></div>I have attached 3 import libraries.<br></div>They all only have 1 import function.<br><br></div>libuser32orig.a -> Works fine and only has MessageBoxA<br><br></div>libuser32b.a -> the symbol table has MessageBoxB and __imp_MessageBoxB but the Import object has MessageBoxA.user32.dll.<br><br></div>This causes a segfault in lld but should link correctly right ?<br></div><div><br></div>Additionally I have attached libuser32.a<br>This is the same as libuser32b.a but the symbol table has MessageBoxA and __imp_MessageBoxB rather then MessageBoxB and __imp_MessageBoxB<br><br></div><div>This also segfaults I assume due to the same bug.<br><br></div>The reason I created this iteration is because we should be able to in the import library just add extra __imp_{alias} to the symbol tables that point to the original import of MessageBoxA.<br><br></div><div>Other then alias support the only difference between my new tool and lib.exe is that I don't bother to create .debug sections as we don't need them.<br></div><br>Kind Regards<span><font color="#888888"><br></font></span></div><span><font color="#888888">Martell<br></font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>