[lld/mac] Set branchRange a bit more carefully
authorNico Weber <thakis@chromium.org>
Sun, 29 Aug 2021 19:19:19 +0000 (15:19 -0400)
committerNico Weber <thakis@chromium.org>
Mon, 30 Aug 2021 16:36:06 +0000 (12:36 -0400)
commit9721197520e5badd4e6385399f6b08575c6c8504
tree538b67afe20d41d6879e10ed1845df00edffde94
parentf564299fe94bade150c845f134284038d27b422a
[lld/mac] Set branchRange a bit more carefully

- Don't subtract thunkSize from branchRange. Most places care about
  the actual maximal branch range. Subtract thunkSize in the one place
  that wants to leave room for a thunk.
- Set it to 0x800_0000 instead of 0xFF_FFFF
- Subtract 4 for the positive branch direction since it's a
  two's complement 24bit number sign-extended mutiplied by 4,
  so its range is -0x800_0000..+0x7FF_FFFC
- Make boundary checks include the boundary values

This doesn't make a huge difference in practice. It's preparation
for a "real" fix for PR51578 -- but it also lets the repro in comment 0
in that bug place one more thunk before hitting the TODO.

Differential Revision: https://reviews.llvm.org/D108897
lld/MachO/Arch/ARM64.cpp
lld/MachO/ConcatOutputSection.cpp
lld/MachO/Target.h