[PATCH] D45801: COFF: Use (name, output characteristics) as a key when grouping input sections into output sections.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 18 23:34:32 PDT 2018


pcc created this revision.
pcc added reviewers: ruiu, rnk.

This is what link.exe does and lets us avoid needing to worry about
merging output characteristics while adding input sections to output
sections.

With this change we can't process /merge in the same way as before
because sections with different output characteristics can still
be merged into one another. So this change moves the processing of
/merge to just before we assign addresses. In the case where there
are multiple output sections with the same name, link.exe only merges
the first section with the source name into the first section with
the target name, and we do the same.

This isn't quite enough though because link.exe has a special case for
.CRT in 32-bit mode: it processes sections whose output characteristics
are DATA | R | W as though the output characteristics were DATA | R
(so that they get merged into things like constructor lists in the
expected way). Chromium has a few such sections, and it turns out
that those sections were causing the problem that resulted in r318699
(merge .xdata into .rdata) being reverted: because of the previous
permission merging semantics, the .CRT sections were causing the entire
.rdata section to become writable, which caused the SEH runtime to
crash because it apparently requires .xdata to be read-only. This
change also implements the same special case.

This should unblock being able to merge .xdata into .rdata by default,
as well as .bss into .data, both of which will be done in followups.

Depends on https://reviews.llvm.org/D45799


https://reviews.llvm.org/D45801

Files:
  lld/COFF/Writer.cpp
  lld/COFF/Writer.h
  lld/test/COFF/crt-chars.test
  lld/test/COFF/output-chars.test
  lld/test/COFF/unwind.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45801.143045.patch
Type: text/x-patch
Size: 11522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180419/e9dd4b3f/attachment.bin>


More information about the llvm-commits mailing list