[PATCH] D64200: [ELF] Allow placing non-string SHF_MERGE sections with different alignments into the same MergeSyntheticSection

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 03:23:16 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay updated this revision to Diff 208009.
MaskRay added a reviewer: nickdesaulniers.
MaskRay added a comment.

Add nickdesaulniers


The difference from D63432 <https://reviews.llvm.org/D63432>/r365015 is that this patch does not place
SHF_STRINGS sections with different alignments into the same
MergeSyntheticSection. That would (1) waste space and (2) create
unaligned sections when tail merge (-O2) is enabled. MOVAPS on such
unaligned strings can raise SIGSEGV.

This should fix PR42289: the Linux kernel has a use case that input
files have .rodata.cst32 sections with different alignments. The
expectation (and what ld.bfd and gold do) is that in the -r link, there
is only one .rodata.cst32 (SHF_MERGE sections with different alignments
can be combined), but lld currently creates one for each different
alignment.

The current merging strategy:

1. Group SHF_MERGE sections by (name, sh_flags, sh_entsize and sh_addralign). String merging is performed among a group, even if -O0 is specified.
2. Create one output section for each group. This is a special case in addInputSec().

This patch changes 1) to:

1. Group SHF_MERGE sections by (name, sh_flags, sh_entsize). String merging is performed among a group, even if -O0 is specified.

We will thus create just one .rodata.cst32 . This also improves merging
efficiency when sections with the same name but different alignments are
combined.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D64200

Files:
  ELF/SyntheticSections.cpp
  test/ELF/merge-align2.s
  test/ELF/merge-entsize2.s
  test/ELF/merge-reloc-O0.s
  test/ELF/tail-merge-string-align2.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64200.208009.patch
Type: text/x-patch
Size: 6141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190704/a8c9629e/attachment.bin>


More information about the llvm-commits mailing list