This is an archive of the discontinued LLVM Phabricator instance.

[llvm-dlltool] Write correct weak externals
ClosedPublic

Authored by mstorsjo on Jul 30 2017, 1:27 PM.

Details

Summary

Previously, the created object files for the import library were broken. Write the symbol table before the string table. Simplify the code by using a separate variable Prefix instead of duplicating a few lines.

Also update the coff-weak-exports to actually check that the generated weak symbols can be found as intended.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 30 2017, 1:27 PM
martell edited edge metadata.Jul 30 2017, 1:55 PM
martell added a subscriber: hans.

Indeed, the string table should be written afterwards, thanks martin.
Feel free to add aarch64 to the frontend if you are using llvm-dlltool for wine.
I saw your mingw-w64 PATCH earlier to enable arm when using dlltool.

Anyway LGTM

@hans can I request a back port of this to 5.0 once rui approves and it lands in trunk.

martell accepted this revision.Jul 30 2017, 1:56 PM
This revision is now accepted and ready to land.Jul 30 2017, 1:56 PM

Indeed, the string table should be written afterwards, thanks martin.
Feel free to add aarch64 to the frontend if you are using llvm-dlltool for wine.
I saw your mingw-w64 PATCH earlier to enable arm when using dlltool.

Not using it for wine, but I'll try to use it for mingw/arm64. I'll send a patch for hooking that up once I've got something worth showing there :-)

ruiu accepted this revision.Jul 31 2017, 1:14 AM

LGTM

lib/Object/COFFImportFile.cpp
548 ↗(On Diff #108841)

Use std::string instead of StringRef to avoid use of str().

mstorsjo added inline comments.Jul 31 2017, 1:35 AM
lib/Object/COFFImportFile.cpp
548 ↗(On Diff #108841)

I thought about that, but then the append() below would mutably alter it - str() intentionally gives a new mutable temporary for each of the append()s here.

ruiu added inline comments.Jul 31 2017, 1:47 AM
lib/Object/COFFImportFile.cpp
548 ↗(On Diff #108841)

Then a more natural way of doing it is (Prefix + Sym).str() instead of Prefix.str().append(Sym).

mstorsjo added inline comments.Jul 31 2017, 1:53 AM
lib/Object/COFFImportFile.cpp
548 ↗(On Diff #108841)

Thanks - that does work.

mstorsjo updated this revision to Diff 108882.Jul 31 2017, 1:54 AM

Using the (Prefix + Sym).str() syntax as suggested by Rui. (With Prefix still being a StringRef - or would it be preferred to make that a std::string?)

mstorsjo marked an inline comment as done.Jul 31 2017, 1:54 AM
ruiu accepted this revision.Jul 31 2017, 3:03 AM

LGTM

lib/Object/COFFImportFile.cpp
549 ↗(On Diff #108882)

Please keep it in 80 cols.

mstorsjo marked an inline comment as done.Jul 31 2017, 4:19 AM
This revision was automatically updated to reflect the committed changes.
hans added a comment.Jul 31 2017, 9:08 AM

@hans can I request a back port of this to 5.0 once rui approves and it lands in trunk.

Rui: OK to merge to 5.0?