[PATCH] D22749: [ELF] - Linkerscript: Implemented SORT command

Ed Maste via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 07:11:02 PDT 2016


emaste added inline comments.

================
Comment at: ELF/LinkerScript.cpp:139
@@ +138,3 @@
+                return A->getSectionName() < B->getSectionName();
+              return compareFileNames(A->getFile(), B->getFile());
+            });
----------------
grimar wrote:
> evgeny777 wrote:
> > What exact sorting order should be used? Shouldn't file name have greater priority than section name?
> > 
> > Also how about this one:
> > ```
> > *(SORT(*.data.*))
> > ```
> > vs this one:
> > ```
> > SORT(*)(*.data.*)
> > ```
> I think my first iteration was correct. SORT can be applied both to sections and to filenames separatelly. Since I am applying it for sections here, no need to sort filenames.
> As you mentioned documentation says "the linker will sort the files or sections into ascending order by name". Its a bit confusing, but says correct thing. files OR sections. I am going to revert this to previous iteration.
Right, it should sort by file or section names independently I think; the common use case is for ctor and dtor section names (this is the case for FreeBSD) and it's definitely the section name that's important there.

```KEEP (*(SORT(.dtors.*)))```

For reproducible builds though we do want to make sure the sort is stable / deterministic in the non-sorted field.



https://reviews.llvm.org/D22749





More information about the llvm-commits mailing list