[PATCH] D116787: [llvm-readobj][MachO] Add option to sort the symbol table before dumping (MachO only, for now).

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 7 11:00:49 PST 2022


MaskRay added a comment.

I can imagine that this feature will be useful in lld tests. It will avoid test churn if lld does parallel initialization of symbol table (still deterministic, but the order may occasionally if we tune parameters).

Symbol table sorting takes significant time (single-digit percentage in ld.lld) and sorting symbols alphabetically can spend more time (I cut down some ld.lld symbol table iteration time more than half by avoiding symbol name operation). so I think it is justified that lld itself does not do it. Rather, llvm-readobj and CHECK lines operate on the sorted symbol table.

For Mach-O, instead of a pure alphabetical sort, have you thought about keeping the local/external/undefined groups and performing sorting within each group?
A pure alphabetical sort is somewhat invalid conceptually.
For ELF, this means local symbols always precede non-local (STB_WEAK,STB_GLOBAL,STB_GNU_UNIQUE) symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116787



More information about the llvm-commits mailing list