[lld] [lld][macho] Support 1-byte branch relocs for x86_64 (PR #164439)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 21 10:17:24 PDT 2025


================
@@ -96,11 +98,18 @@ int64_t X86_64::getEmbeddedAddend(MemoryBufferRef mb, uint64_t offset,
 void X86_64::relocateOne(uint8_t *loc, const Reloc &r, uint64_t value,
                          uint64_t relocVA) const {
   if (r.pcrel) {
-    uint64_t pc = relocVA + 4 + pcrelOffset(r.type);
+    uint64_t pc = relocVA + (1 << r.length) + pcrelOffset(r.type);
----------------
ellishg wrote:

Also, could we factor out `1 << r.length` into its own function? Then I could use it to fix the bug in `BPSectionOrderer.cpp` and hopefully prevent future bugs like it.

https://github.com/llvm/llvm-project/pull/164439


More information about the llvm-commits mailing list