Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLD][COFF] Use primary symbol table machine in Writer::writeHeader (NFC) #128442

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Feb 23, 2025

Instead of duplicating the logic from LinkerDriver::setMachine.

…NFC)

Instead of duplicating the logic from LinkerDriver::setMachine.
@llvmbot
Copy link
Member

llvmbot commented Feb 23, 2025

@llvm/pr-subscribers-lld
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld-coff

Author: Jacek Caban (cjacek)

Changes

Instead of duplicating the logic from LinkerDriver::setMachine.


Full diff: https://github.com/llvm/llvm-project/pull/128442.diff

1 Files Affected:

  • (modified) lld/COFF/Writer.cpp (+1-10)
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 58727c1615769..3efbcdb452ebe 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1758,16 +1758,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
   assert(coffHeaderOffset == buf - buffer->getBufferStart());
   auto *coff = reinterpret_cast<coff_file_header *>(buf);
   buf += sizeof(*coff);
-  switch (config->machine) {
-  case ARM64EC:
-    coff->Machine = AMD64;
-    break;
-  case ARM64X:
-    coff->Machine = ARM64;
-    break;
-  default:
-    coff->Machine = config->machine;
-  }
+  coff->Machine = ctx.symtab.isEC() ? AMD64 : ctx.symtab.machine;
   coff->NumberOfSections = ctx.outputSections.size();
   coff->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
   if (config->largeAddressAware)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants