From 18e9a809e864e68ed999f3a9a06dce55b7a2c0f4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 21 Apr 2021 17:38:52 +0100 Subject: [PATCH] Extend the description of PE header flags. PR 27760 include * coff/pe.h (IMAGE_DLLCHARACTERISTICS_APPCONTAINER): Define. (IMAGE_DLLCHARACTERISTICS_GUARD_CF): Define. bfd * peXXigen.c (_bfd_XX_print_private_bfd_data_common): Add display of IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP, IMAGE_FILE_NET_RUN_FROM_SWAP and IMAGE_FILE_UP_SYSTEM_ONLY flags. Decode the contents of the DllCharacteristics field. --- bfd/ChangeLog | 8 ++++++++ bfd/peXXigen.c | 31 +++++++++++++++++++++++++++++++ include/ChangeLog | 6 ++++++ include/coff/pe.h | 2 ++ 4 files changed, 47 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 85f4f37de1e..db31bdb2669 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2021-04-21 Eli Zaretskii + + PR 27760 + * peXXigen.c (_bfd_XX_print_private_bfd_data_common): Add display + of IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP, + IMAGE_FILE_NET_RUN_FROM_SWAP and IMAGE_FILE_UP_SYSTEM_ONLY flags. + Decode the contents of the DllCharacteristics field. + 2021-04-21 Nick Clifton PR 27759 diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index b9a679a3701..c41c3299277 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -2720,8 +2720,11 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile) PF (IMAGE_FILE_BYTES_REVERSED_LO, "little endian"); PF (IMAGE_FILE_32BIT_MACHINE, "32 bit words"); PF (IMAGE_FILE_DEBUG_STRIPPED, "debugging information removed"); + PF (IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP, "copy to swap file if on removable media"); + PF (IMAGE_FILE_NET_RUN_FROM_SWAP, "copy to swap file if on network media"); PF (IMAGE_FILE_SYSTEM, "system file"); PF (IMAGE_FILE_DLL, "DLL"); + PF (IMAGE_FILE_UP_SYSTEM_ONLY, "run only on uniprocessor machine"); PF (IMAGE_FILE_BYTES_REVERSED_HI, "big endian"); #undef PF @@ -2848,6 +2851,34 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile) if (subsystem_name) fprintf (file, "\t(%s)", subsystem_name); fprintf (file, "\nDllCharacteristics\t%08x\n", i->DllCharacteristics); + if (i->DllCharacteristics) + { + unsigned short dllch = i->DllCharacteristics; + const char *indent = "\t\t\t\t\t"; + + if (dllch & IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA) + fprintf (file, "%sHIGH_ENTROPY_VA\n", indent); + if (dllch & IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE) + fprintf (file, "%sDYNAMIC_BASE\n", indent); + if (dllch & IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY) + fprintf (file, "%sFORCE_INTEGRITY\n", indent); + if (dllch & IMAGE_DLL_CHARACTERISTICS_NX_COMPAT) + fprintf (file, "%sNX_COMPAT\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_NO_ISOLATION) + fprintf (file, "%sNO_ISOLATION\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_NO_SEH) + fprintf (file, "%sNO_SEH\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_NO_BIND) + fprintf (file, "%sNO_BIND\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_APPCONTAINER) + fprintf (file, "%sAPPCONTAINER\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_WDM_DRIVER) + fprintf (file, "%sWDM_DRIVER\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_GUARD_CF) + fprintf (file, "%sGUARD_CF\n", indent); + if (dllch & IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE) + fprintf (file, "%sTERMINAL_SERVICE_AWARE\n", indent); + } fprintf (file, "SizeOfStackReserve\t"); bfd_fprintf_vma (abfd, file, i->SizeOfStackReserve); fprintf (file, "\nSizeOfStackCommit\t"); diff --git a/include/ChangeLog b/include/ChangeLog index 83ae2cb84cc..20aefde3397 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,9 @@ +2021-04-21 Eli Zaretskii + + PR 27760 + * coff/pe.h (IMAGE_DLLCHARACTERISTICS_APPCONTAINER): Define. + (IMAGE_DLLCHARACTERISTICS_GUARD_CF): Define. + 2021-04-16 Alan Modra PR 27567 diff --git a/include/coff/pe.h b/include/coff/pe.h index d6e84691677..9e1ea4b5aa4 100644 --- a/include/coff/pe.h +++ b/include/coff/pe.h @@ -49,7 +49,9 @@ #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800 +#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000 +#define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000 /* Additional flags to be set for section headers to allow the NT loader to -- 2.30.2