This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Fix .rsrc sections with differing permissions
ClosedPublic

Authored by mstorsjo on Jun 26 2019, 12:33 PM.

Details

Summary

GNU windres, and MS cvtres (unless the /readonly option is passed) produce read-write .rsrc sections, when creating resource object files. This causes the sections to not be added to the precreated RsrcSec, and therefore not be added to the data directory.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jun 26 2019, 12:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2019, 12:33 PM
rnk accepted this revision.Jun 26 2019, 4:06 PM

lgtm

This revision is now accepted and ready to land.Jun 26 2019, 4:06 PM
mstorsjo marked an inline comment as done.Jun 26 2019, 11:42 PM
mstorsjo added inline comments.
COFF/Writer.cpp
687 ↗(On Diff #206725)

Stylistically, would it make more sense to move the .idata perms fixup out from this function, next to the fixup for .rsrc below?

ruiu added inline comments.Jun 27 2019, 4:21 AM
COFF/Writer.cpp
656 ↗(On Diff #206725)

Can you add a function comment?

657 ↗(On Diff #206725)

Use an actual type instead of auto.

mstorsjo marked 2 inline comments as done.Jun 27 2019, 1:54 PM
mstorsjo added inline comments.
COFF/Writer.cpp
656 ↗(On Diff #206725)

Sure, adding one that says "Change the characteristics of existing PartialSections that belong to the section Name to Chars."

657 ↗(On Diff #206725)

The type here is std::map<PartialSectionKey, PartialSection *>::iterator, so I think this is one of the cases where auto is warranted.

mstorsjo updated this revision to Diff 206928.Jun 27 2019, 1:56 PM
mstorsjo marked an inline comment as done.

Added the comment Rui requested. I also renamed the obj file from .obj to .o, as it is created with windres, not cvtres.

ruiu accepted this revision.Jun 28 2019, 2:43 AM

LGTM

COFF/Writer.cpp
657 ↗(On Diff #206725)

Ah, got it.

This revision was automatically updated to reflect the committed changes.

This fixes the issues mentioned at the bottom of https://reviews.llvm.org/D63109#1558181 , right?