[llvm] [objcopy] Add aliases to some llvm-objcopy --subsystem options (PR #98036)
Victor Campos via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 05:13:56 PDT 2024
https://github.com/vhscampos updated https://github.com/llvm/llvm-project/pull/98036
>From b943835fdcf780f804bb5e44c5bbbc4401642403 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Fri, 5 Jul 2024 15:29:16 +0100
Subject: [PATCH 1/2] [objcopy] Add aliases to some llvm-objcopy --subsystem
options
GNU objcopy has some --subsystem options that aren't present in LLVM's.
They are in fact just aliases to some of the existing options.
For the sake of compatibility with the GNU toolchain, this patch adds
these aliases to LLVM objcopy.
The alias list is not exhaustive as this is an incremental change.
---
llvm/test/tools/llvm-objcopy/COFF/subsystem.test | 9 +++++++++
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | 11 ++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/llvm/test/tools/llvm-objcopy/COFF/subsystem.test b/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
index 4d73ed83941c7..92d49e80a8d00 100644
--- a/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
+++ b/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
@@ -30,6 +30,15 @@
# INVALID-MAJOR-NUMBER: 'foo' is not a valid subsystem major version
# INVALID-MINOR-NUMBER: 'bar' is not a valid subsystem minor version
+# RUN: llvm-objcopy --subsystem=efi_application %t.in.exe
+# RUN: llvm-objcopy --subsystem=efi-app %t.in.exe
+
+# RUN: llvm-objcopy --subsystem=efi_boot_service_driver %t.in.exe
+# RUN: llvm-objcopy --subsystem=efi-bsd %t.in.exe
+
+# RUN: llvm-objcopy --subsystem=efi_runtime_driver %t.in.exe
+# RUN: llvm-objcopy --subsystem=efi-rtd %t.in.exe
+
--- !COFF
OptionalHeader:
AddressOfEntryPoint: 4096
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index 4ab3b7265f2f6..7e7ed2a23889c 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -678,12 +678,13 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
.Case("boot_application",
COFF::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION)
.Case("console", COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI)
- .Case("efi_application", COFF::IMAGE_SUBSYSTEM_EFI_APPLICATION)
- .Case("efi_boot_service_driver",
- COFF::IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER)
+ .Cases("efi_application", "efi-app",
+ COFF::IMAGE_SUBSYSTEM_EFI_APPLICATION)
+ .Cases("efi_boot_service_driver", "efi-bsd",
+ COFF::IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER)
.Case("efi_rom", COFF::IMAGE_SUBSYSTEM_EFI_ROM)
- .Case("efi_runtime_driver",
- COFF::IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER)
+ .Cases("efi_runtime_driver", "efi-rtd",
+ COFF::IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER)
.Case("native", COFF::IMAGE_SUBSYSTEM_NATIVE)
.Case("posix", COFF::IMAGE_SUBSYSTEM_POSIX_CUI)
.Case("windows", COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI)
>From 22529c2db858793a9572728096df9944c3f07ba7 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Tue, 9 Jul 2024 13:13:27 +0100
Subject: [PATCH 2/2] fixup! [objcopy] Add aliases to some llvm-objcopy
--subsystem options
---
.../tools/llvm-objcopy/COFF/subsystem.test | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/llvm/test/tools/llvm-objcopy/COFF/subsystem.test b/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
index 92d49e80a8d00..6c12857a42a16 100644
--- a/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
+++ b/llvm/test/tools/llvm-objcopy/COFF/subsystem.test
@@ -30,14 +30,20 @@
# INVALID-MAJOR-NUMBER: 'foo' is not a valid subsystem major version
# INVALID-MINOR-NUMBER: 'bar' is not a valid subsystem minor version
-# RUN: llvm-objcopy --subsystem=efi_application %t.in.exe
-# RUN: llvm-objcopy --subsystem=efi-app %t.in.exe
+# RUN: llvm-objcopy --subsystem=efi_application %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-APPLICATION
+# RUN: llvm-objcopy --subsystem=efi-app %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-APPLICATION
-# RUN: llvm-objcopy --subsystem=efi_boot_service_driver %t.in.exe
-# RUN: llvm-objcopy --subsystem=efi-bsd %t.in.exe
+# EFI-APPLICATION: Subsystem: IMAGE_SUBSYSTEM_EFI_APPLICATION
-# RUN: llvm-objcopy --subsystem=efi_runtime_driver %t.in.exe
-# RUN: llvm-objcopy --subsystem=efi-rtd %t.in.exe
+# RUN: llvm-objcopy --subsystem=efi_boot_service_driver %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-BOOT-SERVICE-DRIVER
+# RUN: llvm-objcopy --subsystem=efi-bsd %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-BOOT-SERVICE-DRIVER
+
+# EFI-BOOT-SERVICE-DRIVER: Subsystem: IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
+
+# RUN: llvm-objcopy --subsystem=efi_runtime_driver %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-RUNTIME-DRIVER
+# RUN: llvm-objcopy --subsystem=efi-rtd %t.in.exe - | llvm-readobj --file-headers - | FileCheck %s --check-prefix=EFI-RUNTIME-DRIVER
+
+# EFI-RUNTIME-DRIVER: Subsystem: IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
--- !COFF
OptionalHeader:
More information about the llvm-commits
mailing list