This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Merge the .ctors, .dtors and .CRT sections into .rdata for MinGW
ClosedPublic

Authored by mstorsjo on Aug 29 2018, 4:19 AM.

Details

Summary

There's no point in keeping them as separate sections.

This differs from GNU ld, which places .ctors and .dtors content in .text (implemented by a built-in linker script). But since the content only is pointers, there's no need to have it executable.

GNU ld also leaves .CRT separate as its own standalone section.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 29 2018, 4:19 AM

On the same topic; GNU ld doesn't merge .CRT into .rdata either, but perhaps we should? (It shouldn't hurt.) For MSVC environments, afaik this is handled by an embedded directive /merge:.CRT=.rdata from msvcrt.lib.

mstorsjo updated this revision to Diff 163067.Aug 29 2018, 6:04 AM
mstorsjo retitled this revision from [LLD] [COFF] Merge the .ctors and .dtors sections into .rdata for MinGW to [LLD] [COFF] Merge the .ctors, .dtors and .CRT sections into .rdata for MinGW.
mstorsjo edited the summary of this revision. (Show Details)
rnk accepted this revision.Aug 29 2018, 8:31 AM

lgtm

This revision is now accepted and ready to land.Aug 29 2018, 8:31 AM
This revision was automatically updated to reflect the committed changes.