This is an archive of the discontinued LLVM Phabricator instance.

Fix broken export table if .rdata is merged with .text.
ClosedPublic

Authored by ruiu on Jan 24 2019, 10:03 AM.

Details

Summary

Previously, we assumed that .rdata is zero-filled, so when writing
an COFF import table, we didn't write anything if the data is zero.
That assumption was wrong because .rdata can be merged with .text.
If .rdata is merged with .text, they are initialized with 0xcc, which
is a trap instruction.

This patch removes that assumption from code.

Should be merged to 8.0 branch as this is a regression.

Fixes https://bugs.llvm.org/show_bug.cgi?id=39826

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

ruiu created this revision.Jan 24 2019, 10:03 AM
rnk accepted this revision.Jan 24 2019, 10:42 AM

lgtm

lld/COFF/DLL.cpp
475–476 ↗(On Diff #183336)

I think we don't need this dead store if we modify the loop below to write zero unconditionally if !E.Noname. Maybe it's worth asserting Config->Exports.size() == Size to ensure there is no padding.

This revision is now accepted and ready to land.Jan 24 2019, 10:42 AM
ruiu marked an inline comment as done.Jan 24 2019, 10:59 AM
ruiu added inline comments.
lld/COFF/DLL.cpp
475–476 ↗(On Diff #183336)

Actually this store seems completely dead. I'll remove before submitting.

This revision was automatically updated to reflect the committed changes.