From: Chris Faylor Date: Fri, 21 Mar 2014 17:33:43 +0000 (-0400) Subject: 2014-03-21 Christopher Faylor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0e6d77b3fb64561ca66535f8ed6ca523eac923e;p=binutils-gdb.git 2014-03-21 Christopher Faylor * ld.texinfo: Document change in handling of --enable-auto-image-base. * emultempl/pe.em (pe_auto_image_base): Set to default base. (gld_${EMULATION_NAME}_list_options): Change usage message to reflect optional --enable-auto-image-base argument. (gld${EMULATION_NAME}_handle_option): Handle optional --enable-auto-image-base argument. (compute_dll_image_base): Eliminate constant. Use pe_auto_image_base. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 5544956e52d..292459b4d34 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2014-03-17 Christopher Faylor + + * ld.texinfo: Document change in handling of --enable-auto-image-base. + * emultempl/pe.em (pe_auto_image_base): Set to default base. + (gld_${EMULATION_NAME}_list_options): Change usage message to reflect + optional --enable-auto-image-base argument. + (gld${EMULATION_NAME}_handle_option): Handle optional + --enable-auto-image-base argument. + (compute_dll_image_base): Eliminate constant. Use pe_auto_image_base. + 2014-03-19 Nick Clifton * Makefile.am (default-manifest.o): Use WINDRES_FOR_TARGET. diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 67df2bc4dba..c18cb266beb 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -137,6 +137,7 @@ static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable. */ static char *pe_out_def_filename = NULL; static char *pe_implib_filename = NULL; static int pe_enable_auto_image_base = 0; +static unsigned long pe_auto_image_base = 0x61500000; static char *pe_dll_search_prefix = NULL; #endif @@ -322,7 +323,7 @@ gld${EMULATION_NAME}_add_options treating -c as an abbreviation for these --compat-implib. */ {"compat-implib", no_argument, NULL, OPTION_IMP_COMPAT}, {"compat-implib", no_argument, NULL, OPTION_IMP_COMPAT}, - {"enable-auto-image-base", no_argument, NULL, OPTION_ENABLE_AUTO_IMAGE_BASE}, + {"enable-auto-image-base", optional_argument, NULL, OPTION_ENABLE_AUTO_IMAGE_BASE}, {"disable-auto-image-base", no_argument, NULL, OPTION_DISABLE_AUTO_IMAGE_BASE}, {"dll-search-prefix", required_argument, NULL, OPTION_DLL_SEARCH_PREFIX}, {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES}, @@ -455,11 +456,12 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --kill-at Remove @nn from exported symbols\n")); fprintf (file, _(" --out-implib Generate import library\n")); fprintf (file, _(" --output-def Generate a .DEF file for the built DLL\n")); - fprintf (file, _(" --warn-duplicate-exports Warn about duplicate exports.\n")); + fprintf (file, _(" --warn-duplicate-exports Warn about duplicate exports\n")); fprintf (file, _(" --compat-implib Create backward compatible import libs;\n\ create __imp_ as well.\n")); - fprintf (file, _(" --enable-auto-image-base Automatically choose image base for DLLs\n\ - unless user specifies one\n")); + fprintf (file, _(" --enable-auto-image-base[=
] Automatically choose image base for DLLs\n\ + (optionally starting with address) unless\n\ + specifically set with --image-base\n")); fprintf (file, _(" --disable-auto-image-base Do not auto-choose image base. (default)\n")); fprintf (file, _(" --dll-search-prefix= When linking dynamically to a dll without\n\ an importlib, use .dll\n\ @@ -802,6 +804,12 @@ gld${EMULATION_NAME}_handle_option (int optc) break; case OPTION_ENABLE_AUTO_IMAGE_BASE: pe_enable_auto_image_base = 1; + if (optarg && *optarg) + { + char *end; + pe_auto_image_base = strtoul(optarg, &end, 0); + /* XXX should check that we actually parsed something */ + } break; case OPTION_DISABLE_AUTO_IMAGE_BASE: pe_enable_auto_image_base = 0; @@ -911,7 +919,7 @@ static unsigned long compute_dll_image_base (const char *ofile) { unsigned long hash = strhash (ofile); - return 0x61300000 + ((hash << 16) & 0x0FFC0000); + return pe_auto_image_base + ((hash << 16) & 0x0FFC0000); } #endif diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 2c39d3c1ead..8a41ee8725e 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2415,11 +2415,12 @@ creation step. @kindex --enable-auto-image-base @item --enable-auto-image-base -Automatically choose the image base for DLLs, unless one is specified -using the @code{--image-base} argument. By using a hash generated -from the dllname to create unique image bases for each DLL, in-memory -collisions and relocations which can delay program execution are -avoided. +@itemx --enable-auto-image-base=@var{value} +Automatically choose the image base for DLLs, optionally starting with base +@var{value}, unless one is specified using the @code{--image-base} argument. +By using a hash generated from the dllname to create unique image bases +for each DLL, in-memory collisions and relocations which can delay program +execution are avoided. [This option is specific to the i386 PE targeted port of the linker] @kindex --disable-auto-image-base