This is an archive of the discontinued LLVM Phabricator instance.

[LLD] COFF: Make link order compatible with MSVC link.exe.
ClosedPublic

Authored by ruiu on Jun 23 2015, 4:15 PM.

Details

Reviewers
pcc
Summary

Previously, we added files in directive sections to the symbol
table as we read the sections, so the link order was depth-first.
That's not compatible with MSVC link.exe nor the old LLD.

This patch is to queue files so that new files are added to the
end of the queue and processed last. Now addFile() doesn't parse
files nor resolve symbols. You need to call run() to process
queued files.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 28300.Jun 23 2015, 4:15 PM
ruiu retitled this revision from to [LLD] COFF: Make link order compatible with MSVC link.exe..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a reviewer: pcc.
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).
pcc added inline comments.Jun 23 2015, 4:37 PM
COFF/SymbolTable.cpp
289

If we move the call to run() below this loop, it should make the code a little easier to reason about, as run() will never see a symbol table that has only been partially processed by the loop.

test/COFF/order.test
2

Did you forget to add these input files?

ruiu updated this revision to Diff 28303.Jun 23 2015, 4:41 PM

Address pcc's comments.

test/COFF/order.test
2

I reused files for an existing test.

pcc added inline comments.Jun 23 2015, 4:46 PM
COFF/SymbolTable.cpp
293

Huh, does this compile? BitcodeFiles.end() is an iterator, right?

ruiu added inline comments.Jun 23 2015, 4:51 PM
COFF/SymbolTable.cpp
293

Ah, sorry, I intended to write auto instead of size_t. (And if we make that change, all tests pass.)

pcc accepted this revision.Jun 23 2015, 4:57 PM
pcc edited edge metadata.

LGTM with my suggested change.

COFF/SymbolTable.cpp
293

I don't think it is correct to compare iterators like this because the standard library may invalidate iterators if elements are appended to the vector. Can we make this use size as before?

This revision is now accepted and ready to land.Jun 23 2015, 4:57 PM
ruiu added inline comments.Jun 23 2015, 5:00 PM
COFF/SymbolTable.cpp
293

You are correct. Updated the code to use size as before.

pcc added inline comments.Jun 23 2015, 5:07 PM
COFF/SymbolTable.cpp
290

Sorry, missed this; you need error checking here.

ruiu added inline comments.Jun 23 2015, 5:09 PM
COFF/SymbolTable.cpp
290

Feel free to do this yourself. (I could do that but I guess that would be faster.)

pcc added inline comments.Jun 23 2015, 5:17 PM
COFF/SymbolTable.cpp
290

Done

290

Done

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r240483.