-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLD][COFF] Use primary symbol table machine in Writer::writeHeader (NFC) #128442
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
Conversation
…NFC) Instead of duplicating the logic from LinkerDriver::setMachine.
@llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-coff Author: Jacek Caban (cjacek) ChangesInstead of duplicating the logic from Full diff: https://github.com/llvm/llvm-project/pull/128442.diff 1 Files Affected:
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The logic for which symtab has which machine set in which mode is still hazy to me, but the change looks straightforward, and I presume we have relevant test coverage to be sure that this really is NFC.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
…NFC) (llvm#128442) Instead of duplicating the logic from `LinkerDriver::setMachine`.
Instead of duplicating the logic from
LinkerDriver::setMachine
.