[PATCH] D46874: [MC] - Add .stack_size sections into groups and link them with .text

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 24 01:52:34 PDT 2018


jhenderson added a comment.

In https://reviews.llvm.org/D46874#1109615, @grimar wrote:

> What I can probably do is to compute ID based on the .text section name.
>
> So that for no -ffunction-sections case it would emit several .stack_sizes with the same ID and so that final object would contain only a single section finally after merging them,
>  just like we would want.
>
> It would work for my sample case too I think. Let me try to implement this.


Yes, I think this all makes sense. Here's a summary of what I think is best without -function-sections enabled:

  // These two share a .stack_sizes section
  void func1() {}
  void func2() {}
  
  // These two share a different .stack_sizes section.
  void func3()  __attribute__ ((section (".text.other"))) {}
  void func4()  __attribute__ ((section (".text.other"))) {}
  
  // This has it's own .stack_sizes section in its group
  template <int I> int func5() { return I; }

Of course, if .stack_sizes section names were based on their "parent" section, then this would probably become much simpler, but we can't do that with the way current linkers behave.


https://reviews.llvm.org/D46874





More information about the llvm-commits mailing list