From 2ee332e4371dd0448d5cfc956664e0b9e6da8579 Mon Sep 17 00:00:00 2001 From: belliash Date: Sun, 16 Aug 2020 13:29:20 +0200 Subject: [PATCH] Add COFF/PE XT subsystem support for GNU linker. --- .../001-add-coffpe-xt-support.patch | 117 ++++++++++++++++++ ...patch => 002-enable-gold-on-mingw32.patch} | 0 2 files changed, 117 insertions(+) create mode 100644 patches/binutils/binutils-2_35/001-add-coffpe-xt-support.patch rename patches/binutils/binutils-2_35/{001-enable-gold-on-mingw32.patch => 002-enable-gold-on-mingw32.patch} (100%) diff --git a/patches/binutils/binutils-2_35/001-add-coffpe-xt-support.patch b/patches/binutils/binutils-2_35/001-add-coffpe-xt-support.patch new file mode 100644 index 0000000..4afa897 --- /dev/null +++ b/patches/binutils/binutils-2_35/001-add-coffpe-xt-support.patch @@ -0,0 +1,117 @@ +diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c +index 5149ef582b..f09e4b7382 100644 +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -2952,6 +2952,22 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile) + case IMAGE_SUBSYSTEM_XBOX: + subsystem_name = "XBOX"; + break; ++ /* These are the XT specific subsystems */ ++ case IMAGE_SUBSYSTEM_XT_DRIVER: ++ subsystem_name = "XT driver"; ++ break; ++ case IMAGE_SUBSYSTEM_XT_NATIVE: ++ subsystem_name = "XT native"; ++ break; ++ case IMAGE_SUBSYSTEM_XT_GDIAPP: ++ subsystem_name = "XT GDI application"; ++ break; ++ case IMAGE_SUBSYSTEM_XT_CLIAPP: ++ subsystem_name = "XT CLI application"; ++ break; ++ case IMAGE_SUBSYSTEM_XT_PSXAPP: ++ subsystem_name = "XT PSX application"; ++ break; + /* Added default case for clarity - subsystem_name is NULL anyway. */ + default: + subsystem_name = NULL; +diff --git a/binutils/objcopy.c b/binutils/objcopy.c +index 3866c7f458..55e069831b 100644 +--- a/binutils/objcopy.c ++++ b/binutils/objcopy.c +@@ -4860,7 +4860,12 @@ set_pe_subsystem (const char *s) + { "efi-bsd", 1, IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER }, + { "efi-rtd", 1, IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER }, + { "sal-rtd", 1, IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER }, +- { "xbox", 0, IMAGE_SUBSYSTEM_XBOX } ++ { "xbox", 0, IMAGE_SUBSYSTEM_XBOX }, ++ { "xt-driver", 0, IMAGE_SUBSYSTEM_XT_DRIVER }, ++ { "xt-native", 0, IMAGE_SUBSYSTEM_XT_NATIVE }, ++ { "xt-gdiapp", 0, IMAGE_SUBSYSTEM_XT_GDIAPP }, ++ { "xt-cliapp", 0, IMAGE_SUBSYSTEM_XT_CLIAPP }, ++ { "xt-psxapp", 0, IMAGE_SUBSYSTEM_XT_PSXAPP } + }; + short value; + char *copy; +diff --git a/include/coff/pe.h b/include/coff/pe.h +index c83a958eee..deeea6b49a 100644 +--- a/include/coff/pe.h ++++ b/include/coff/pe.h +@@ -169,6 +169,11 @@ + #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 + #define IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 + #define IMAGE_SUBSYSTEM_XBOX 14 ++#define IMAGE_SUBSYSTEM_XT_DRIVER 21 ++#define IMAGE_SUBSYSTEM_XT_NATIVE 22 ++#define IMAGE_SUBSYSTEM_XT_GDIAPP 23 ++#define IMAGE_SUBSYSTEM_XT_CLIAPP 24 ++#define IMAGE_SUBSYSTEM_XT_PSXAPP 25 + + /* NT allows long filenames, we want to accommodate this. + This may break some of the bfd functions. */ +diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em +index 3899c9d92c..c9277ded20 100644 +--- a/ld/emultempl/pe.em ++++ b/ld/emultempl/pe.em +@@ -539,6 +539,11 @@ set_entry_point (void) + { 7, "__PosixProcessStartup"}, + { 9, "WinMainCRTStartup" }, + {14, "mainCRTStartup" }, ++ {21, "XtDriverStartup" }, ++ {22, "XtProcessStartup" }, ++ {23, "XtgMainProcessStartup" }, ++ {24, "XtcMainProcessStartup" }, ++ {25, "XtpMainProcessStartup" }, + { 0, NULL } + }; + +@@ -606,6 +611,11 @@ set_pe_subsystem (void) + { "posix", 7}, + { "wince", 9}, + { "xbox", 14}, ++ { "xt-driver", 21}, ++ { "xt-native", 22}, ++ { "xt-gdiapp", 23}, ++ { "xt-cliapp", 24}, ++ { "xt-psxapp", 25}, + { NULL, 0 } + }; + +diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em +index a0a7023e70..001aa34769 100644 +--- a/ld/emultempl/pep.em ++++ b/ld/emultempl/pep.em +@@ -504,6 +504,11 @@ set_entry_point (void) + { 7, "__PosixProcessStartup" }, + { 9, "WinMainCRTStartup" }, + {14, "mainCRTStartup" }, ++ {21, "XtDriverStartup" }, ++ {22, "XtProcessStartup" }, ++ {23, "XtgMainProcessStartup" }, ++ {24, "XtcMainProcessStartup" }, ++ {25, "XtpMainProcessStartup" }, + { 0, NULL } + }; + +@@ -568,6 +573,11 @@ set_pep_subsystem (void) + { "posix", 7 }, + { "wince", 9 }, + { "xbox", 14 }, ++ { "xt-driver", 21}, ++ { "xt-native", 22}, ++ { "xt-gdiapp", 23}, ++ { "xt-cliapp", 24}, ++ { "xt-psxapp", 25}, + { NULL, 0 } + }; + diff --git a/patches/binutils/binutils-2_35/001-enable-gold-on-mingw32.patch b/patches/binutils/binutils-2_35/002-enable-gold-on-mingw32.patch similarity index 100% rename from patches/binutils/binutils-2_35/001-enable-gold-on-mingw32.patch rename to patches/binutils/binutils-2_35/002-enable-gold-on-mingw32.patch