On Mac OS you can pass a text file as an argument for -order_file
command line option. That file contains a list of symbols, and the
linker sorts these symbols in the same order as in the order file.
That custom ordering was implemented by adding a "custom" comparator
function to the LayoutPass. That made the comparator function in the
LayoutPass, which does too much stuff already, more complex.
I'm trying to make the pass simpler and faster. I found that if we
implement the feature as a separate pass, it becomes easy to understand.
In this patch, I added a new pass, OrderPass, which sorts atoms
according to the order file. Because it uses stable sort, it preserves
symbol order if they are not mentioned in the order file. We already
took similar approach in PE/COFF (PECOFF/GroupSectionPass.h).
This patch has no change in functionality.