[PATCH] D52459: [ELF] - Use output section prediction when creating mergeable synthetic sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 04:56:36 PDT 2018


grimar created this revision.
grimar added a reviewer: ruiu.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

We have a bug "Section merge should match the rules specified in the linker script." (https://bugs.llvm.org//show_bug.cgi?id=38748).
Which says that LLD is unable to handle the following code correctly:

  SECTIONS {
    .rodata_fooSec : { *(.rodata.foo) }
    .rodata_barSec : { *(.rodata.bar) }
  }

We know about that and it happens because we create mergeable synthetic sections very early, before
parsing the linker script. That allows us to keep the whole linker logic simpler.
I would try not to change that.

What I suggest to do in this patch is to use output section prediction
and do not merge together sections which are going to be placed into different output sections.
That fixes the bug.

Also that fixes merge_sections.s. It turns out currently we missed merging optimization and this patch
fixes it either. That happened because we used output section name for a synthetic section. And script
instructions did not match it. This patch uses the name of the first input section as a name for synthetic
section instead.

There is a room for optimizations can be done here, I would like to see the feedback about the approach first.


https://reviews.llvm.org/D52459

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/SyntheticSections.cpp
  test/ELF/linkerscript/merge-sections-different-output.s
  test/ELF/linkerscript/merge-sections.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52459.166851.patch
Type: text/x-patch
Size: 6346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180925/19f90877/attachment.bin>


More information about the llvm-commits mailing list