[PATCH] D38170: [ELF] - Drop SHF_LINK_ORDER flag from output.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 04:50:30 PDT 2017


grimar added inline comments.


================
Comment at: ELF/OutputSections.cpp:447
 
+static uint32_t getLinkOrder(ArrayRef<InputSection *> V) {
+  for (InputSection *IS : V)
----------------
ruiu wrote:
> grimar wrote:
> > ruiu wrote:
> > > This is O(N^2) where N is the number of input sections. Please don't do that.
> > I believe that is O(Mx) here. Where M is amount of sections in output section, so that M0+M1+....+Mn == N,
> > where N is total amount of input sections. Overall complexity is O(N).
> > Because for each output section this function scans over its input sections once.
> > 
> > I think you was confused by incorrect code style in `OutputSection::finalize()`, I fixed it in r314394.
> > 
> I still do not understand this. It doesn't seem correct. You need to handle two or LinkOrderSections, right? Why can you assume that there is always up to one LinkOrderSection?
I do not assume it. For non-relocatable case all what I need is to know if we have
link order sections or not, so that we can sort them. In that case any value
except 0 is enough.

For -r case I believe proper behavior would be to merge together only sections that have
the same parent output sections for their link - order sections.
So link order index should be always the same.

FWIW, original code set sh_link value using first input section's value,
what does not seem correct either.

I changed code a little to make my intentions more clear, is it looks better now ?


https://reviews.llvm.org/D38170





More information about the llvm-commits mailing list