[llvm] [llvm-dlltool] Handle MIPS architecture (PR #114621)
Hervé Poussineau via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 23 13:34:21 PST 2024
https://github.com/hpoussin updated https://github.com/llvm/llvm-project/pull/114621
>From 39c4e2d85e535587affd163c23aa318f294d51b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= <hpoussin at reactos.org>
Date: Sun, 22 Oct 2023 17:10:19 +0200
Subject: [PATCH 1/2] [llvm-dlltool] Handle MIPS architecture
---
llvm/lib/Object/COFFImportFile.cpp | 2 ++
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp | 3 ++-
llvm/test/tools/llvm-dlltool/machine-opt.def | 3 +++
3 files changed, 7 insertions(+), 1 deletion(-)
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
>From ad5d9b19bc448f8ce17967af33dee1359cb5efea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= <hpoussin at reactos.org>
Date: Mon, 23 Dec 2024 22:33:29 +0100
Subject: [PATCH 2/2] [llvm-dlltool] Use 'r4000' instead of 'mips' as emulation
name
---
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp | 6 ++++--
llvm/test/tools/llvm-dlltool/machine-opt.def | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index fdd6f3ec4be54b..2c8194d8505e86 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -79,7 +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)
+ .Case("r4000", IMAGE_FILE_MACHINE_R4000)
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
}
@@ -94,6 +94,8 @@ MachineTypes getMachine(Triple T) {
case Triple::aarch64:
return T.isWindowsArm64EC() ? COFF::IMAGE_FILE_MACHINE_ARM64EC
: COFF::IMAGE_FILE_MACHINE_ARM64;
+ case Triple::mipsel:
+ return COFF::IMAGE_FILE_MACHINE_R4000;
default:
return COFF::IMAGE_FILE_MACHINE_UNKNOWN;
}
@@ -174,7 +176,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, mips\n";
+ llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64, arm64ec, r4000\n";
return 1;
}
diff --git a/llvm/test/tools/llvm-dlltool/machine-opt.def b/llvm/test/tools/llvm-dlltool/machine-opt.def
index 37eccec8831fc6..fcb85299d7bee0 100644
--- a/llvm/test/tools/llvm-dlltool/machine-opt.def
+++ b/llvm/test/tools/llvm-dlltool/machine-opt.def
@@ -6,7 +6,7 @@
; 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-dlltool -m r4000 -d %s -l %t.a
; RUN: llvm-readobj %t.a | FileCheck --check-prefix=MIPS %s
LIBRARY test.dll
More information about the llvm-commits
mailing list