-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-dlltool] Handle MIPS R4000 architecture #114621
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
This is an extract of PR #107744 |
29ef7ff
to
d2aed8f
Compare
d2aed8f
to
c2d128d
Compare
c2d128d
to
39c4e2d
Compare
@llvm/pr-subscribers-llvm-binary-utilities Author: Hervé Poussineau (hpoussin) ChangesFull diff: https://github.com/llvm/llvm-project/pull/114621.diff 3 Files Affected:
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index ff3dcf9e13ffaf..595533ff947252 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -133,6 +133,8 @@ static uint16_t getImgRelRelocation(MachineTypes Machine) {
return IMAGE_REL_ARM64_ADDR32NB;
case IMAGE_FILE_MACHINE_I386:
return IMAGE_REL_I386_DIR32NB;
+ case IMAGE_FILE_MACHINE_R4000:
+ return IMAGE_REL_MIPS_REFWORDNB;
}
}
diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index 58ff720516f384..fdd6f3ec4be54b 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -79,6 +79,7 @@ MachineTypes getEmulation(StringRef S) {
.Case("arm", IMAGE_FILE_MACHINE_ARMNT)
.Case("arm64", IMAGE_FILE_MACHINE_ARM64)
.Case("arm64ec", IMAGE_FILE_MACHINE_ARM64EC)
+ .Case("mips", IMAGE_FILE_MACHINE_R4000)
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
}
@@ -173,7 +174,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
(!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) {
Table.printHelp(outs(), "llvm-dlltool [options] file...", "llvm-dlltool",
false);
- llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64, arm64ec\n";
+ llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64, arm64ec, mips\n";
return 1;
}
diff --git a/llvm/test/tools/llvm-dlltool/machine-opt.def b/llvm/test/tools/llvm-dlltool/machine-opt.def
index 6dce8255a43db3..37eccec8831fc6 100644
--- a/llvm/test/tools/llvm-dlltool/machine-opt.def
+++ b/llvm/test/tools/llvm-dlltool/machine-opt.def
@@ -6,6 +6,8 @@
; RUN: llvm-readobj %t.a | FileCheck --check-prefix=ARM %s
; RUN: llvm-dlltool -m arm64 -d %s -l %t.a
; RUN: llvm-readobj %t.a | FileCheck --check-prefix=ARM64 %s
+; RUN: llvm-dlltool -m mips -d %s -l %t.a
+; RUN: llvm-readobj %t.a | FileCheck --check-prefix=MIPS %s
LIBRARY test.dll
EXPORTS
@@ -15,3 +17,4 @@ TestFunction
; X86_64: Format: COFF-x86-64
; ARM: Format: COFF-ARM{{$}}
; ARM64: Format: COFF-ARM64
+; MIPS: Format: COFF-MIPS
|
@@ -79,6 +79,7 @@ MachineTypes getEmulation(StringRef S) { | |||
.Case("arm", IMAGE_FILE_MACHINE_ARMNT) | |||
.Case("arm64", IMAGE_FILE_MACHINE_ARM64) | |||
.Case("arm64ec", IMAGE_FILE_MACHINE_ARM64EC) | |||
.Case("mips", IMAGE_FILE_MACHINE_R4000) |
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.
Hmm, we should cross-check this with binutils - if it should be r4000 or mips as there was a MIPS16 and a MIPSv2 machine type that PE/COFF has supported over the years.
binutils
|
What do you think of |
I don't care. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Why r4000 is better than mips here? |
Oh, I see: https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
|
No description provided.