include/ChangeLog
authorDave Korn <dave.korn@artimi.com>
Sat, 14 Mar 2009 03:30:26 +0000 (03:30 +0000)
committerDave Korn <dave.korn@artimi.com>
Sat, 14 Mar 2009 03:30:26 +0000 (03:30 +0000)
2009-03-12  Dave Korn  <dave.korn.cygwin@gmail.com>

* coff/internal.h (struct internal_extra_pe_aouthdr):  Correct type
of DllCharacteristics flags field to unsigned.
* coff/pe.h (IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE,
IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE,
IMAGE_DLL_CHARACTERISTICS_NX_COMPAT,
IMAGE_DLLCHARACTERISTICS_NO_ISOLATION,
IMAGE_DLLCHARACTERISTICS_NO_SEH,
IMAGE_DLLCHARACTERISTICS_NO_BIND,
IMAGE_DLLCHARACTERISTICS_WDM_DRIVER,
IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE):  New macros to
define flag bit values for DllCharacteristics field of PEAOUTHDR,
PEPAOUTHDR.

ld/ChangeLog
2009-03-12  Dave Korn  <dave.korn.cygwin@gmail.com>
            Danny Smith  <dannysmith@users.sourceforge.net>

* emultmpl/pe.em (pe_dll_characteristics): New variable.
(OPTION_DYNAMIC_BASE, OPTION_FORCE_INTEGRITY, OPTION_NX_COMPAT,
OPTION_NO_ISOLATION. OPTION_NO_SEH, OPTION_NO_BIND,
OPTION_WDM_DRIVER, OPTION_TERMINAL_SERVER_AWARE):
New macros for options to set DllCharacteristics flag bits.
(gld${EMULATION_NAME}_add_options): Add dynamicbase, forceinteg,
nxcompat, no-isolation, no-seh, no-bind, wdmdriver, tsaware options.
(init): Add DllCharacteristics field.
(gld_${EMULATION_NAME}_list_options): List new options.
(gld${EMULATION_NAME}_handle_option): Handle new options.
* emultmpl/pep.em (pe_dll_characteristics): New variable.
(OPTION_DYNAMIC_BASE, OPTION_FORCE_INTEGRITY, OPTION_NX_COMPAT,
OPTION_NO_ISOLATION. OPTION_NO_SEH, OPTION_NO_BIND,
OPTION_WDM_DRIVER, OPTION_TERMINAL_SERVER_AWARE):
New macros for options to set DllCharacteristics flags.
(gld${EMULATION_NAME}_add_options): Add dynamicbase, forceinteg,
nxcompat,no-isolation, no-seh, no-bind, wdmdriver, tsaware options.
(init): Add DllCharacteristics field.
(gld_${EMULATION_NAME}_list_options): List new options.
(gld${EMULATION_NAME}_handle_option): Handle new options.
* ldtexinfo : Document dynamicbase, forceinteg, nxcompat,
no-isolation, no-seh, no-bind, wdmdriver, tsaware options.

include/ChangeLog
include/coff/internal.h
include/coff/pe.h
ld/ChangeLog
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/ld.texinfo

index ccfc77665e1362f2d836b6db1bc1de70fd753bb7..aef73a3a1cba0106adf7d9b26936b83fdf39cbe0 100644 (file)
@@ -1,3 +1,18 @@
+2009-03-14  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * coff/internal.h (struct internal_extra_pe_aouthdr):  Correct type
+       of DllCharacteristics flags field to unsigned.
+       * coff/pe.h (IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE,
+       IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE,
+       IMAGE_DLL_CHARACTERISTICS_NX_COMPAT,
+       IMAGE_DLLCHARACTERISTICS_NO_ISOLATION,
+       IMAGE_DLLCHARACTERISTICS_NO_SEH,
+       IMAGE_DLLCHARACTERISTICS_NO_BIND,
+       IMAGE_DLLCHARACTERISTICS_WDM_DRIVER,
+       IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE):  New macros to
+       define flag bit values for DllCharacteristics field of PEAOUTHDR,
+       PEPAOUTHDR.
+
 2008-12-01  Cary Coutant  <ccoutant@google.com>
 
        * plugin-api.h (LDPS_BAD_HANDLE): New constant.
index 4c4eab9fda0028ac578c73c13031ee61dc446ce4..2c9ae46c5545c2ac68e78366c85451941067c10e 100644 (file)
@@ -185,7 +185,7 @@ struct internal_extra_pe_aouthdr
      3 - WINDOWS_CUI runs in Windows char sub. (console app)
      5 - OS2_CUI runs in OS/2 character subsystem
      7 - POSIX_CUI runs in Posix character subsystem */
-  short   DllCharacteristics;  /* flags for DLL init, use 0 */
+  unsigned short DllCharacteristics; /* flags for DLL init  */
   bfd_vma SizeOfStackReserve;  /* amount of memory to reserve  */
   bfd_vma SizeOfStackCommit;   /* amount of memory initially committed for 
                                   initial thread's stack, default is 0x1000 */
index 734b11ab9c70c653caebe61dce20e28dab669e06..a7fdd76a3c758957477f1a937edd82423808f89c 100644 (file)
 #define IMAGE_FILE_UP_SYSTEM_ONLY            0x4000
 #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
 
+/* DllCharacteristics flag bits.  The inconsistent naming may seem
+   odd, but that is how they are defined in the PE specification.  */
+#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE          0x0040
+#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY       0x0080
+#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT             0x0100
+#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION           0x0200
+#define IMAGE_DLLCHARACTERISTICS_NO_SEH                 0x0400
+#define IMAGE_DLLCHARACTERISTICS_NO_BIND                0x0800
+#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER             0x2000
+#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE  0x8000
+
 /* Additional flags to be set for section headers to allow the NT loader to
    read and write to the section data (to replace the addresses of data in
    dlls for one thing); also to execute the section in .text's case.  */
index 860cb8282acfdee7898d09b20c7b780a1a80e7f8..86cdeb8bcc8656f5d74e61fe55bdbdbc2965c62c 100644 (file)
@@ -1,3 +1,29 @@
+2009-03-14  Dave Korn  <dave.korn.cygwin@gmail.com>
+            Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * emultmpl/pe.em (pe_dll_characteristics): New variable.
+       (OPTION_DYNAMIC_BASE, OPTION_FORCE_INTEGRITY, OPTION_NX_COMPAT,
+       OPTION_NO_ISOLATION. OPTION_NO_SEH, OPTION_NO_BIND,
+       OPTION_WDM_DRIVER, OPTION_TERMINAL_SERVER_AWARE):
+       New macros for options to set DllCharacteristics flag bits.
+       (gld${EMULATION_NAME}_add_options): Add dynamicbase, forceinteg,
+       nxcompat, no-isolation, no-seh, no-bind, wdmdriver, tsaware options.
+       (init): Add DllCharacteristics field.
+       (gld_${EMULATION_NAME}_list_options): List new options.
+       (gld${EMULATION_NAME}_handle_option): Handle new options.
+       * emultmpl/pep.em (pe_dll_characteristics): New variable.
+       (OPTION_DYNAMIC_BASE, OPTION_FORCE_INTEGRITY, OPTION_NX_COMPAT,
+       OPTION_NO_ISOLATION. OPTION_NO_SEH, OPTION_NO_BIND,
+       OPTION_WDM_DRIVER, OPTION_TERMINAL_SERVER_AWARE):
+       New macros for options to set DllCharacteristics flags.
+       (gld${EMULATION_NAME}_add_options): Add dynamicbase, forceinteg,
+       nxcompat,no-isolation, no-seh, no-bind, wdmdriver, tsaware options.
+       (init): Add DllCharacteristics field.
+       (gld_${EMULATION_NAME}_list_options): List new options.
+       (gld${EMULATION_NAME}_handle_option): Handle new options.
+       * ldtexinfo : Document dynamicbase, forceinteg, nxcompat,
+       no-isolation, no-seh, no-bind, wdmdriver, tsaware options.
+
 2009-03-06  Nick Clifton  <nickc@redhat.com>
 
        * po/es.po: Updated Spanish translation.
index 58ec809dfe20536f699baf492c5371bd0b81d07c..04d722952491b8da951501fa6e55fee593020e05 100644 (file)
@@ -126,6 +126,7 @@ static flagword real_flags = 0;
 static int support_old_code = 0;
 static char * thumb_entry_symbol = NULL;
 static lang_assignment_statement_type *image_base_statement = 0;
+static unsigned short pe_dll_characteristics = 0;
 
 #ifdef DLL_SUPPORT
 static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable.  */
@@ -229,6 +230,15 @@ fragment <<EOF
                                        (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1)
 #define OPTION_DISABLE_LONG_SECTION_NAMES \
                                        (OPTION_ENABLE_LONG_SECTION_NAMES + 1)
+/* DLLCharacteristics flags */
+#define OPTION_DYNAMIC_BASE            (OPTION_DISABLE_LONG_SECTION_NAMES + 1)
+#define OPTION_FORCE_INTEGRITY         (OPTION_DYNAMIC_BASE + 1)
+#define OPTION_NX_COMPAT               (OPTION_FORCE_INTEGRITY + 1)
+#define OPTION_NO_ISOLATION            (OPTION_NX_COMPAT + 1) 
+#define OPTION_NO_SEH                  (OPTION_NO_ISOLATION + 1)
+#define OPTION_NO_BIND                 (OPTION_NO_SEH + 1)
+#define OPTION_WDM_DRIVER              (OPTION_NO_BIND + 1)
+#define OPTION_TERMINAL_SERVER_AWARE   (OPTION_WDM_DRIVER + 1)
 
 static void
 gld${EMULATION_NAME}_add_options
@@ -290,6 +300,14 @@ gld${EMULATION_NAME}_add_options
     {"large-address-aware", no_argument, NULL, OPTION_LARGE_ADDRESS_AWARE},
     {"enable-long-section-names", no_argument, NULL, OPTION_ENABLE_LONG_SECTION_NAMES},
     {"disable-long-section-names", no_argument, NULL, OPTION_DISABLE_LONG_SECTION_NAMES},
+    {"dynamicbase",no_argument, NULL, OPTION_DYNAMIC_BASE},
+    {"forceinteg", no_argument, NULL, OPTION_FORCE_INTEGRITY},
+    {"nxcompat", no_argument, NULL, OPTION_NX_COMPAT},
+    {"no-isolation", no_argument, NULL, OPTION_NO_ISOLATION},
+    {"no-seh", no_argument, NULL, OPTION_NO_SEH},
+    {"no-bind", no_argument, NULL, OPTION_NO_BIND},
+    {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
+    {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},
     {NULL, no_argument, NULL, 0}
   };
 
@@ -339,6 +357,7 @@ static definfo init[] =
   D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
   D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
   D(LoaderFlags,"__loader_flags__", 0x0),
+  D(DllCharacteristics, "__dll_characteristics__", 0x0), 
   { NULL, 0, 0, NULL, 0 }
 };
 
@@ -401,6 +420,16 @@ gld_${EMULATION_NAME}_list_options (FILE *file)
                                        executable image files\n"));
   fprintf (file, _("  --disable-long-section-names       Never use long COFF section names, even\n\
                                        in object files\n"));
+  fprintf (file, _("  --dynamicbase                     Image base address may be relocated using\n\
+                                      address space layout randomization (ASLR)\n"));
+  fprintf (file, _("  --forceinteg              Code integrity checks are enforced\n"));
+  fprintf (file, _("  --nxcompat                Image is compatible with data execution prevention\n"));
+  fprintf (file, _("  --no-isolation            Image understands isolation but do not isolate the image\n"));
+  fprintf (file, _("  --no-seh                  Image does not use SEH. No SE handler may\n\
+                                      be called in this image\n"));
+  fprintf (file, _("  --no-bind                         Do not bind this image\n"));
+  fprintf (file, _("  --wdmdriver               Driver uses the WDM model\n"));
+  fprintf (file, _("  --tsaware                 Image is Terminal Server aware\n"));
 }
 
 
@@ -707,7 +736,36 @@ gld${EMULATION_NAME}_handle_option (int optc)
     case OPTION_DISABLE_LONG_SECTION_NAMES:
       pe_use_coff_long_section_names = 0;
       break;
+/*  Get DLLCharacteristics bits  */
+    case OPTION_DYNAMIC_BASE:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE;
+      break;
+    case OPTION_FORCE_INTEGRITY:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY;
+      break;
+    case OPTION_NX_COMPAT:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_NX_COMPAT;
+      break;
+    case OPTION_NO_ISOLATION:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_ISOLATION;
+      break;
+    case OPTION_NO_SEH:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_SEH;
+      break;
+    case OPTION_NO_BIND:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_BIND;
+      break;
+    case OPTION_WDM_DRIVER:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_WDM_DRIVER;
+      break;
+    case OPTION_TERMINAL_SERVER_AWARE:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE;
+      break;
     }
+
+  /*  Set DLLCharacteristics bits  */
+  set_pe_name ("__dll_characteristics__", pe_dll_characteristics);
+
   return TRUE;
 }
 \f
index 13180a01825be39020c52302fc20182271cee79f..ee4eeeb744462f87ae10834e95816f4d53fbd542 100644 (file)
@@ -104,6 +104,7 @@ static int dll;
 static flagword real_flags = IMAGE_FILE_LARGE_ADDRESS_AWARE;
 static int support_old_code = 0;
 static lang_assignment_statement_type *image_base_statement = 0;
+static unsigned short pe_dll_characteristics = 0;
 
 #ifdef DLL_SUPPORT
 static int    pep_enable_stdcall_fixup = 1; /* 0=disable 1=enable (default).  */
@@ -179,7 +180,15 @@ enum options
   OPTION_EXCLUDE_MODULES_FOR_IMPLIB,
   OPTION_USE_NUL_PREFIXED_IMPORT_TABLES,
   OPTION_ENABLE_LONG_SECTION_NAMES,
-  OPTION_DISABLE_LONG_SECTION_NAMES
+  OPTION_DISABLE_LONG_SECTION_NAMES,
+  OPTION_DYNAMIC_BASE,
+  OPTION_FORCE_INTEGRITY,
+  OPTION_NX_COMPAT,
+  OPTION_NO_ISOLATION,
+  OPTION_NO_SEH,
+  OPTION_NO_BIND,
+  OPTION_WDM_DRIVER,
+  OPTION_TERMINAL_SERVER_AWARE
 };
 
 static void
@@ -244,7 +253,14 @@ gld${EMULATION_NAME}_add_options
 #endif
     {"enable-long-section-names", no_argument, NULL, OPTION_ENABLE_LONG_SECTION_NAMES},
     {"disable-long-section-names", no_argument, NULL, OPTION_DISABLE_LONG_SECTION_NAMES},
-    {NULL, no_argument, NULL, 0}
+    {"dynamicbase",no_argument, NULL, OPTION_DYNAMIC_BASE},
+    {"forceinteg", no_argument, NULL, OPTION_FORCE_INTEGRITY},
+    {"nxcompat", no_argument, NULL, OPTION_NX_COMPAT},
+    {"no-isolation", no_argument, NULL, OPTION_NO_ISOLATION},
+    {"no-seh", no_argument, NULL, OPTION_NO_SEH},
+    {"no-bind", no_argument, NULL, OPTION_NO_BIND},
+    {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
+    {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},    {NULL, no_argument, NULL, 0}
   };
 
   *longopts = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
@@ -288,6 +304,7 @@ static definfo init[] =
   D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
   D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
   D(LoaderFlags,"__loader_flags__", 0x0),
+  D(DllCharacteristics, "__dll_characteristics__", 0x0), 
   { NULL, 0, 0, NULL, 0 }
 };
 
@@ -346,6 +363,16 @@ gld_${EMULATION_NAME}_list_options (FILE *file)
                                        executable image files\n"));
   fprintf (file, _("  --disable-long-section-names       Never use long COFF section names, even\n\
                                        in object files\n"));
+  fprintf (file, _("  --dynamicbase                     Image base address may be relocated using\n\
+                                      address space layout randomization (ASLR)\n"));
+  fprintf (file, _("  --forceinteg              Code integrity checks are enforced\n"));
+  fprintf (file, _("  --nxcompat                Image is compatible with data execution prevention\n"));
+  fprintf (file, _("  --no-isolation            Image understands isolation but do not isolate the image\n"));
+  fprintf (file, _("  --no-seh                  Image does not use SEH. No SE handler may\n\
+                                      be called in this image\n"));
+  fprintf (file, _("  --no-bind                         Do not bind this image\n"));
+  fprintf (file, _("  --wdmdriver               Driver uses the WDM model\n"));
+  fprintf (file, _("  --tsaware                 Image is Terminal Server aware\n"));
 #endif
 }
 
@@ -647,7 +674,36 @@ gld${EMULATION_NAME}_handle_option (int optc)
     case OPTION_DISABLE_LONG_SECTION_NAMES:
       pep_use_coff_long_section_names = 0;
       break;
+    /*  Get DLLCharacteristics bits  */
+    case OPTION_DYNAMIC_BASE:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE;
+      break;
+    case OPTION_FORCE_INTEGRITY:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY;
+      break;
+    case OPTION_NX_COMPAT:
+      pe_dll_characteristics |= IMAGE_DLL_CHARACTERISTICS_NX_COMPAT;
+      break;
+    case OPTION_NO_ISOLATION:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_ISOLATION;
+      break;
+    case OPTION_NO_SEH:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_SEH;
+      break;
+    case OPTION_NO_BIND:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_NO_BIND;
+      break;
+    case OPTION_WDM_DRIVER:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_WDM_DRIVER;
+      break;
+    case OPTION_TERMINAL_SERVER_AWARE:
+      pe_dll_characteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE;
+      break;
     }
+
+  /*  Set DLLCharacteristics bits  */
+  set_pep_name ("__dll_characteristics__", pe_dll_characteristics);
   return TRUE;
 }
 \f
index e2a70a8b7a91c7fd6f48389f216f9b1b26ff7777..32e8783be81401f42dff7f490cb3a02f42fbb809 100644 (file)
@@ -2488,6 +2488,46 @@ the subsystem version also.  Numeric values are also accepted for
 @var{which}.
 [This option is specific to the i386 PE targeted port of the linker]
 
+The following options set flags in the @code{DllCharacteristics} field
+of the PE file header:
+[These options are specific to PE targeted ports of the linker]
+
+@kindex --dynamicbase
+@item --dynamicbase
+The image base address may be relocated using address space layout
+randomization (ASLR).  This feature was introduced with MS Windows
+Vista for i386 PE targets.
+
+@kindex --forceinteg
+@item --forceinteg
+Code integrity checks are enforced.
+
+@kindex --nxcompat
+@item --nxcompat
+The image is compatible with the Data Execution Prevention.
+This feature was introduced with MS Windows XP SP2 for i386 PE targets.
+
+@kindex --no-isolation
+@item --no-isolation
+Although the image understands isolation, do not isolate the image.
+
+@kindex --no-seh
+@item --no-seh
+The image does not use SEH. No SE handler may be called from
+this image.
+
+@kindex --no-bind
+@item --no-bind
+Do not bind this image.
+
+@kindex --wdmdriver
+@item --wdmdriver
+The driver uses the MS Windows Driver Model.
+@kindex --tsaware
+@item --tsaware
+The image is Terminal Server aware.
+
 @end table
 
 @c man end