[lld] [LLD][COFF] Add basic ARM64X dynamic relocations support (PR #118035)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 08:21:31 PST 2024
================
@@ -2555,6 +2566,33 @@ void Writer::addBaserelBlocks(std::vector<Baserel> &v) {
relocSec->addChunk(make<BaserelChunk>(page, &v[i], &v[0] + j));
}
+void Writer::createDynamicRelocs() {
+ if (!ctx.dynamicRelocs)
+ return;
+
+ const uint32_t coffHeaderOffset = dosStubSize + sizeof(PEMagic);
+ const uint32_t peHeaderOffset = coffHeaderOffset + sizeof(coff_file_header);
+ const uint32_t dataDirOffset = peHeaderOffset + sizeof(pe32plus_header);
+
+ // Adjust the Machine field in the COFF header to AMD64.
+ ctx.dynamicRelocs->add(IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof(uint16_t),
+ coffHeaderOffset + offsetof(coff_file_header, Machine),
+ AMD64);
+
+ // Adjust the load config directory.
----------------
cjacek wrote:
Ultimately, on ARM64X, we should define two separate load configs: native and EC. The native load config is written to the header, and ARM64X relocations "adjust" it to reference the EC load config. If the EC load config is missing, as in the test from this PR, MSVC emits a warning (this part is not yet implemented) and resets the header value so that the EC view has no load config.
Testing and supporting two load configs isn’t currently possible in lld-link due to duplicated `_load_config_used` symbols. We need support for separated namespaces first.
https://github.com/llvm/llvm-project/pull/118035
More information about the llvm-commits
mailing list