[lld-macho] Use DO_BIND_ADD_ADDR_IMM_SCALED for bind opcodes
authorVincent Lee <leevince@fb.com>
Fri, 16 Jul 2021 03:25:48 +0000 (20:25 -0700)
committerVincent Lee <leevince@fb.com>
Mon, 19 Jul 2021 23:18:33 +0000 (16:18 -0700)
commit321b2bef098553ec648e4174aae92c63a6e1a810
tree13f662758580f12ed1c51a4e375e1a47408f26c0
parentde3ea51be4367367202da5f53ca4e39848d3ccf6
[lld-macho] Use DO_BIND_ADD_ADDR_IMM_SCALED for bind opcodes

Implement pass 3 of bind opcodes from ld64 (which supports both 32-bit and 64-bit).
Pass 3 implementation condenses BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB opcode
to BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED.  This change is already behind an
O2 flag so it shouldn't impact current performance. I verified ld64's output with x86_64 LLD
and they were both emitting the same optimized bind opcodes (although in a slightly different
order). Tested with arm64_32 LLD and compared that with x86 LLD that the order of the bind
opcodes are the same (offset values are different which should be expected).

Reviewed By: int3, #lld-macho

Differential Revision: https://reviews.llvm.org/D106128
lld/MachO/SyntheticSections.cpp
lld/test/MachO/bind-opcodes.s