[lld] f083f65 - [lld-macho][nfc] Remove TODO regarding addends
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 09:30:22 PST 2021
Author: Jez Ng
Date: 2021-03-01T12:30:08-05:00
New Revision: f083f652c3fdc97e0bda278fee8354a0cf7ff551
URL: https://github.com/llvm/llvm-project/commit/f083f652c3fdc97e0bda278fee8354a0cf7ff551
DIFF: https://github.com/llvm/llvm-project/commit/f083f652c3fdc97e0bda278fee8354a0cf7ff551.diff
LOG: [lld-macho][nfc] Remove TODO regarding addends
There was initially some concern around the correct handling of pcrel
section relocations with r_length != 2. But it looks like there are no such
relocations in practice -- x86_64's pcrel section relocs all have r_length == 2,
and ARM64 doesn't even have pcrel section relocs. So we can replace the TODO
with an assert.
Reviewed By: #lld-macho, thakis
Differential Revision: https://reviews.llvm.org/D97576
Added:
Modified:
lld/MachO/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index d11c3f404b0c..726ce1269542 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -330,8 +330,7 @@ void ObjFile::parseRelocations(const section_64 &sec,
// The implicit addend for pcrel section relocations is the pcrel offset
// in terms of the addresses in the input file. Here we adjust it so
// that it describes the offset from the start of the referent section.
- // TODO: The offset of 4 is probably not right for ARM64, nor for
- // relocations with r_length != 2.
+ assert(target->hasAttr(r.type, RelocAttrBits::BYTE4));
referentOffset =
sec.addr + relInfo.r_address + 4 + totalAddend - referentSec.addr;
} else {
More information about the llvm-commits
mailing list