This is an archive of the discontinued LLVM Phabricator instance.

Fix size computation in WindowsResourceCOFFWriter::performFileLayout()
AbandonedPublic

Authored by inglorion on Dec 14 2017, 4:44 PM.

Details

Reviewers
ruiu
zturner
Summary

We calculated the size of auxiliary sections as two coff_symbol16s,
instead of as a coff_symbol16 and a coff_aux_section_definition. This
caused us to allocate insufficient bytes, causing the linker to crash
on some resource files. This change fixes the computation.

Fixes PR35581.

Event Timeline

inglorion created this revision.Dec 14 2017, 4:44 PM
inglorion added inline comments.Dec 14 2017, 4:47 PM
llvm/lib/Object/WindowsResource.cpp
378

The code that actually writes the bytes (and thus needs to match the size we compute here) is in WindowsResourceCOFFWriter::writeSymbolTable(), starting on line 511.

ruiu added a comment.Dec 14 2017, 4:49 PM

Do you think you can add a test?

pcc added a subscriber: pcc.Dec 14 2017, 4:53 PM
pcc added inline comments.
llvm/lib/Object/WindowsResource.cpp
379

Is this correct? I think the size of an auxiliary symbol is the same as the size of a regular symbol, so this looks like this would produce the same result as before.

inglorion added inline comments.Dec 14 2017, 5:26 PM
llvm/lib/Object/WindowsResource.cpp
379

You are right; they are both 18 bytes. And just changing the code as I've done here does not actually fix the problem. I had some printstrumentation in there that seems to make the difference between working and broken. This is getting more interesting.

inglorion abandoned this revision.Dec 14 2017, 7:49 PM

Superseded by D41270.