[lld] [LLD][COFF] Prepare both load configs on ARM64X (PR #120326)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 29 03:44:13 PST 2024
https://github.com/cjacek updated https://github.com/llvm/llvm-project/pull/120326
>From 878f22615fc2f958abdaa53ce8df91b6dd336224 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Sun, 8 Dec 2024 15:12:03 +0100
Subject: [PATCH] [LLD][COFF] Prepare both load configs on ARM64X
---
lld/COFF/Writer.cpp | 34 +++++++++++++++++--------------
lld/test/COFF/arm64x-loadconfig.s | 2 ++
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index e6b239c83dd4a2..5946c2944aa212 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -282,7 +282,8 @@ class Writer {
uint32_t getSizeOfInitializedData();
void prepareLoadConfig();
- template <typename T> void prepareLoadConfig(T *loadConfig);
+ template <typename T>
+ void prepareLoadConfig(SymbolTable &symtab, T *loadConfig);
std::unique_ptr<FileOutputBuffer> &buffer;
std::map<PartialSectionKey, PartialSection *> partialSections;
@@ -2637,22 +2638,25 @@ void Writer::fixTlsAlignment() {
}
void Writer::prepareLoadConfig() {
- if (!ctx.symtab.loadConfigSym)
- return;
+ ctx.forEachSymtab([&](SymbolTable &symtab) {
+ if (!symtab.loadConfigSym)
+ return;
- OutputSection *sec =
- ctx.getOutputSection(ctx.symtab.loadConfigSym->getChunk());
- uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
- uint8_t *symBuf =
- secBuf + (ctx.symtab.loadConfigSym->getRVA() - sec->getRVA());
+ OutputSection *sec = ctx.getOutputSection(symtab.loadConfigSym->getChunk());
+ uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
+ uint8_t *symBuf = secBuf + (symtab.loadConfigSym->getRVA() - sec->getRVA());
- if (ctx.config.is64())
- prepareLoadConfig(reinterpret_cast<coff_load_configuration64 *>(symBuf));
- else
- prepareLoadConfig(reinterpret_cast<coff_load_configuration32 *>(symBuf));
+ if (ctx.config.is64())
+ prepareLoadConfig(symtab,
+ reinterpret_cast<coff_load_configuration64 *>(symBuf));
+ else
+ prepareLoadConfig(symtab,
+ reinterpret_cast<coff_load_configuration32 *>(symBuf));
+ });
}
-template <typename T> void Writer::prepareLoadConfig(T *loadConfig) {
+template <typename T>
+void Writer::prepareLoadConfig(SymbolTable &symtab, T *loadConfig) {
size_t loadConfigSize = loadConfig->Size;
#define RETURN_IF_NOT_CONTAINS(field) \
@@ -2665,12 +2669,12 @@ template <typename T> void Writer::prepareLoadConfig(T *loadConfig) {
if (loadConfigSize >= offsetof(T, field) + sizeof(T::field))
#define CHECK_VA(field, sym) \
- if (auto *s = dyn_cast<DefinedSynthetic>(ctx.symtab.findUnderscore(sym))) \
+ if (auto *s = dyn_cast<DefinedSynthetic>(symtab.findUnderscore(sym))) \
if (loadConfig->field != ctx.config.imageBase + s->getRVA()) \
Warn(ctx) << #field " not set correctly in '_load_config_used'";
#define CHECK_ABSOLUTE(field, sym) \
- if (auto *s = dyn_cast<DefinedAbsolute>(ctx.symtab.findUnderscore(sym))) \
+ if (auto *s = dyn_cast<DefinedAbsolute>(symtab.findUnderscore(sym))) \
if (loadConfig->field != s->getVA()) \
Warn(ctx) << #field " not set correctly in '_load_config_used'";
diff --git a/lld/test/COFF/arm64x-loadconfig.s b/lld/test/COFF/arm64x-loadconfig.s
index 0d4fe0ed6d6e0a..6023828a2746f7 100644
--- a/lld/test/COFF/arm64x-loadconfig.s
+++ b/lld/test/COFF/arm64x-loadconfig.s
@@ -4,6 +4,7 @@
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows test.s -o test.obj
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows loadconfig.s -o loadconfig.obj
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows loadconfig-short.s -o loadconfig-short.obj
+// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows loadconfig-short.s -o loadconfig-short-arm64ec.obj
// RUN: lld-link -machine:arm64x -out:out.dll -dll -noentry loadconfig.obj test.obj
@@ -43,6 +44,7 @@
// HEADERS-NEXT: VirtualSize: 0x38
// RUN: lld-link -machine:arm64x -out:out-short.dll -dll -noentry loadconfig-short.obj 2>&1 | FileCheck --check-prefix=WARN-RELOC-SIZE %s
+// RUN: lld-link -machine:arm64x -out:out-short.dll -dll -noentry loadconfig-short-arm64ec.obj 2>&1 | FileCheck --check-prefix=WARN-RELOC-SIZE %s
// WARN-RELOC-SIZE: lld-link: warning: '_load_config_used' structure too small to include dynamic relocations
#--- test.s
More information about the llvm-commits
mailing list