[lld] [lld][macho] Support 1-byte branch relocs for x86_64 (PR #164439)
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 12:12:56 PDT 2025
================
@@ -84,6 +84,8 @@ int64_t X86_64::getEmbeddedAddend(MemoryBufferRef mb, uint64_t offset,
const uint8_t *loc = buf + offset + rel.r_address;
switch (rel.r_length) {
+ case 0:
+ return *loc + pcrelOffset(rel.r_type);
case 2:
return static_cast<int32_t>(read32le(loc)) + pcrelOffset(rel.r_type);
----------------
int3 wrote:
the static cast here is correct. `read32le` returns an unsigned int32_t but addends can be negative, so we need to cast to int32_t to handle them correctly.
> Does it make sense to factor this out by adding a new address variable and return address + pcrelOffset(rel.r_type); at the end?
sure, done
https://github.com/llvm/llvm-project/pull/164439
More information about the llvm-commits
mailing list