[PATCH] D67504: [ELF] Make MergeInputSection merging aware of output sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 07:42:51 PDT 2019


MaskRay added a comment.

In D67504#1672620 <https://reviews.llvm.org/D67504#1672620>, @peter.smith wrote:

> Thanks for the update. I don't have any more comments at the moment, I'm in favour of making the change. It would be useful to get the perspective of someone coming to the patch for the first time to see if it was easy for them to understand. A possible alternative would be to filter out the MergeInputSections into a separate list. Assign all the other InputSections as before. Then work out where the MergeSyntheticSections would go, create them and insert them into the OutputSections. However I don't think that would be obviously any better.


Thanks for the review. The problem with 2 lists (one for MergeInputSections that will be merged into MergeSyntheticSections, the other for InputSections) is that the relative positions are significant in the output. If we have 2 lists, `sortInputSections`will become more complex. LinkerScript.cpp:395

  // Sort sections as instructed by SORT-family commands and --sort-section
  // option. Because SORT-family commands can be nested at most two depth
  // (e.g. SORT_BY_NAME(SORT_BY_ALIGNMENT(.text.*))) and because the command
  ...
  static void sortInputSections(MutableArrayRef<InputSectionBase *> vec,
                                const SectionPattern &pat) {


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67504/new/

https://reviews.llvm.org/D67504





More information about the llvm-commits mailing list