[mach-o] refactor x86_64 relocation handling.
This is first step in reworking how mach-o relocations are processed.
The existing KindHandler is going to become a delgate/helper object for
processing architecture specific references. The KindHandler knows how
to convert mach-o relocations into References and back, as well, as fixing
up the content the relocation is on.
One of the messy things about mach-o relocations is that they sometime
come in pairs, but the pairs still convert to one lld::Reference. So, the
conversion has to detect pairs (arch specific) and change the stride.
llvm-svn: 211921
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index 726092c..f187df9 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -498,6 +498,7 @@
}
void Util::appendSection(SectionInfo *si, NormalizedFile &file) {
+ const bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
// Add new empty section to end of file.sections.
Section temp;
file.sections.push_back(std::move(temp));
@@ -528,9 +529,14 @@
if ( ref->target() != nullptr )
targetAddress = _atomToAddress[ref->target()];
uint64_t fixupAddress = _atomToAddress[ai.atom] + offset;
- _context.kindHandler().applyFixup(
+ if ( rMode ) {
+ // FIXME: Need a handler method to update content for .o file
+ // output and any needed section relocations.
+ } else {
+ _context.kindHandler().applyFixup(
ref->kindNamespace(), ref->kindArch(), ref->kindValue(),
ref->addend(), &atomContent[offset], fixupAddress, targetAddress);
+ }
}
}
}