[LLD][COFF] Implement ARM64X relocations for the exception table (#123723)
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index ff3c898..11e7cf43 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -1167,7 +1167,7 @@
}
uint64_t Arm64XRelocVal::get() const {
- return (sym ? sym->getRVA() : 0) + value;
+ return (sym ? sym->getRVA() : 0) + (chunk ? chunk->getRVA() : 0) + value;
}
size_t Arm64XDynamicRelocEntry::getSize() const {
@@ -1230,6 +1230,17 @@
size = alignTo(size, sizeof(uint32_t));
}
+// Set the reloc value. The reloc entry must be allocated beforehand.
+void DynamicRelocsChunk::set(uint32_t rva, Arm64XRelocVal value) {
+ auto entry =
+ llvm::find_if(arm64xRelocs, [rva](const Arm64XDynamicRelocEntry &e) {
+ return e.offset.get() == rva;
+ });
+ assert(entry != arm64xRelocs.end());
+ assert(!entry->value.get());
+ entry->value = value;
+}
+
void DynamicRelocsChunk::writeTo(uint8_t *buf) const {
auto table = reinterpret_cast<coff_dynamic_reloc_table *>(buf);
table->Version = 1;