diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 8 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 21 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 12 | ||||
-rw-r--r-- | ld/ld.texinfo | 5 | ||||
-rw-r--r-- | ld/pe-dll.c | 8 |
5 files changed, 41 insertions, 13 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index e98129d..4582adb 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2013-11-22 Cory Fields <cory@coryfields.com> + + * pe-dll.c (fill_edata): Only use a real timestamp if + --insert-timestamp was used. + * emultempl/pe.em: Add the --insert-timestamp option. + * emultempl/pep.em: Likewise for 64bit. + * ld.texinfo: Document the --insert-timestamp option. + 2013-11-22 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> * scripttempl/avr.sc: Set .data section's LMA to next available diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 4df7753..5d6da9e 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -130,6 +130,7 @@ 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; +static bfd_boolean insert_timestamp = FALSE; #ifdef DLL_SUPPORT static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable. */ @@ -239,8 +240,7 @@ fragment <<EOF (OPTION_EXCLUDE_LIBS + 1) #define OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC \ (OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC + 1) -#define OPTION_LARGE_ADDRESS_AWARE \ - (OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC + 1) +#define OPTION_LARGE_ADDRESS_AWARE (OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC + 1) #define OPTION_DISABLE_LARGE_ADDRESS_AWARE \ (OPTION_LARGE_ADDRESS_AWARE + 1) #define OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1 \ @@ -251,15 +251,13 @@ fragment <<EOF (OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2 + 1) #define OPTION_USE_NUL_PREFIXED_IMPORT_TABLES \ (OPTION_EXCLUDE_MODULES_FOR_IMPLIB + 1) -#define OPTION_NO_LEADING_UNDERSCORE \ - (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1) -#define OPTION_LEADING_UNDERSCORE \ - (OPTION_NO_LEADING_UNDERSCORE + 1) +#define OPTION_NO_LEADING_UNDERSCORE (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1) +#define OPTION_LEADING_UNDERSCORE (OPTION_NO_LEADING_UNDERSCORE + 1) #define OPTION_ENABLE_LONG_SECTION_NAMES \ (OPTION_LEADING_UNDERSCORE + 1) #define OPTION_DISABLE_LONG_SECTION_NAMES \ (OPTION_ENABLE_LONG_SECTION_NAMES + 1) -/* DLLCharacteristics flags */ +/* 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) @@ -268,6 +266,8 @@ fragment <<EOF #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) +/* Determinism. */ +#define OPTION_INSERT_TIMESTAMP (OPTION_TERMINAL_SERVER_AWARE + 1) static void gld${EMULATION_NAME}_add_options @@ -301,6 +301,7 @@ gld${EMULATION_NAME}_add_options OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE}, {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE}, + {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP}, #ifdef DLL_SUPPORT /* getopt allows abbreviations, so we do this to stop it from treating -o as an abbreviation for this option. */ @@ -438,6 +439,8 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --support-old-code Support interworking with old code\n")); fprintf (file, _(" --[no-]leading-underscore Set explicit symbol underscore prefix mode\n")); fprintf (file, _(" --thumb-entry=<symbol> Set the entry point to be Thumb <symbol>\n")); + fprintf (file, _(" --insert-timestamp Use a real timestamp rather than zero.\n")); + fprintf (file, _(" This makes binaries non-deterministic\n")); #ifdef DLL_SUPPORT fprintf (file, _(" --add-stdcall-alias Export symbols with and without @nn\n")); fprintf (file, _(" --disable-stdcall-fixup Don't link _sym to _sym@nn\n")); @@ -754,6 +757,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_LEADING_UNDERSCORE: pe_leading_underscore = 1; break; + case OPTION_INSERT_TIMESTAMP: + insert_timestamp = TRUE; + break; #ifdef DLL_SUPPORT case OPTION_OUT_DEF: pe_out_def_filename = xstrdup (optarg); @@ -1255,6 +1261,7 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pe; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + pe_data (link_info.output_bfd)->insert_timestamp = insert_timestamp; /* At this point we must decide whether to use long section names in the output or not. If the user hasn't explicitly specified diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 3e8b65e..b738800 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -18,8 +18,7 @@ esac rm -f e${EMULATION_NAME}.c (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-) fragment <<EOF -/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. +/* Copyright 2006-2013 Free Software Foundation, Inc. Written by Kai Tietz, OneVision Software GmbH&CoKg. This file is part of the GNU Binutils. @@ -146,6 +145,7 @@ 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; +static bfd_boolean insert_timestamp = FALSE; #ifdef DLL_SUPPORT static int pep_enable_stdcall_fixup = 1; /* 0=disable 1=enable (default). */ @@ -241,6 +241,7 @@ enum options OPTION_NO_SEH, OPTION_NO_BIND, OPTION_WDM_DRIVER, + OPTION_INSERT_TIMESTAMP, OPTION_TERMINAL_SERVER_AWARE }; @@ -316,6 +317,7 @@ gld${EMULATION_NAME}_add_options {"no-bind", no_argument, NULL, OPTION_NO_BIND}, {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER}, {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE}, + {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP}, {NULL, no_argument, NULL, 0} }; @@ -402,6 +404,8 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --subsystem <name>[:<version>] Set required OS subsystem [& version]\n")); fprintf (file, _(" --support-old-code Support interworking with old code\n")); fprintf (file, _(" --[no-]leading-underscore Set explicit symbol underscore prefix mode\n")); + fprintf (file, _(" --insert-timestamp Use a real timestamp rather than zero.\n")); + fprintf (file, _(" This makes binaries non-deterministic\n")); #ifdef DLL_SUPPORT fprintf (file, _(" --add-stdcall-alias Export symbols with and without @nn\n")); fprintf (file, _(" --disable-stdcall-fixup Don't link _sym to _sym@nn\n")); @@ -707,6 +711,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_LEADING_UNDERSCORE: pep_leading_underscore = 1; break; + case OPTION_INSERT_TIMESTAMP: + insert_timestamp = TRUE; + break; #ifdef DLL_SUPPORT case OPTION_OUT_DEF: pep_out_def_filename = xstrdup (optarg); @@ -1219,6 +1226,7 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pep; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + pe_data (link_info.output_bfd)->insert_timestamp = insert_timestamp; /* At this point we must decide whether to use long section names in the output or not. If the user hasn't explicitly specified diff --git a/ld/ld.texinfo b/ld/ld.texinfo index e4788f6..c925ecb 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2657,6 +2657,11 @@ The driver uses the MS Windows Driver Model. @item --tsaware The image is Terminal Server aware. +@kindex --insert-timestamp +@item --insert-timestamp +Insert a real timestamp into the image, rather than the default value +of zero. This will result in a slightly different results with each +invocation, which could be helpful for distributing unique images. @end table @c man end diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 7d5f90d..8777efb 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1169,9 +1169,6 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) unsigned char *enameptrs; unsigned char *eordinals; char *enamestr; - time_t now; - - time (&now); edata_d = xmalloc (edata_sz); @@ -1186,7 +1183,10 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) + edata_s->output_section->vma - image_base) memset (edata_d, 0, edata_sz); - bfd_put_32 (abfd, now, edata_d + 4); + + if (pe_data (abfd)->insert_timestamp) + H_PUT_32 (abfd, time (0), edata_d + 4); + if (pe_def_file->version_major != -1) { bfd_put_16 (abfd, pe_def_file->version_major, edata_d + 8); |