[PATCH] D75498: [llvm-objdump] Add option to sort symbols during disassembly

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 15:00:40 PST 2020


MaskRay added a comment.

Hi, can you describe the use case you have in mind? Is that for a more stable disassembly output when there can be several symbols defined at the same address?

There is no guarantee for the .symtab order but in practice it has some patterns. Both GNU as and llvm-mc sort symbols in object files. Linkers (GNU ld, gold, lld) seem to use a visiting order. So, say, you have several aliases:

  .globl foo, _foo, __foo, ___foo
  _foo:
  __foo:
  foo:
  ___foo:
    ret

After you add or delete instructions, the order among these `*foo` should not change.

For one thing, llvm-objdump currently uses the symbol table order while I think preferring STB_GLOBAL/STB_WEAK to STB_LOCAL may be nice. GNU objdump may have some other heuristics. I'll dig into its source.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75498





More information about the llvm-commits mailing list