* [PATCH] Minor Cygwin/ld Makefile tweak
@ 2014-03-17 14:17 Christopher Faylor
2014-03-17 16:36 ` Nicholas Clifton
2014-03-17 17:40 ` [PATCH] Enable Windows --auto-image-base to take an argument Christopher Faylor
0 siblings, 2 replies; 6+ messages in thread
From: Christopher Faylor @ 2014-03-17 14:17 UTC (permalink / raw)
To: binutils
ld's makefile currently tries to use the in-tree version of
windres which obviously won't work if you're cross-compiling.
Ok to check in the below change?
cgf
2014-03-17 Christopher Faylor <me.cygwin2014@cgf.cx>
* Makefile.am: Use host version of windres.
* Makefile.in: Regenerate.
diff --git a/ld/Makefile.am b/ld/Makefile.am
index fe674c4..e89a6c1 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -1927,7 +1927,7 @@ eshlelf64_nbsd.c: $(srcdir)/emulparams/shlelf64_nbsd.sh \
# Rule to create a manifest file for Cygwin and Mingw.
default-manifest.o: $(srcdir)/emultempl/default-manifest.rc
- ../binutils/windres -o $@ $<
+ ${WINDRES} -o $@ $<
# We need this for automake to use YLWRAP.
EXTRA_ld_new_SOURCES = deffilep.y ldlex.l
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 46126f8..0c14694 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -3359,7 +3359,7 @@ eshlelf64_nbsd.c: $(srcdir)/emulparams/shlelf64_nbsd.sh \
# Rule to create a manifest file for Cygwin and Mingw.
default-manifest.o: $(srcdir)/emultempl/default-manifest.rc
- ../binutils/windres -o $@ $<
+ ${WINDRES} -o $@ $<
check-DEJAGNU: site.exp
srcroot=`cd $(srcdir) && pwd`; export srcroot; \
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Minor Cygwin/ld Makefile tweak
2014-03-17 14:17 [PATCH] Minor Cygwin/ld Makefile tweak Christopher Faylor
@ 2014-03-17 16:36 ` Nicholas Clifton
2014-03-17 17:40 ` [PATCH] Enable Windows --auto-image-base to take an argument Christopher Faylor
1 sibling, 0 replies; 6+ messages in thread
From: Nicholas Clifton @ 2014-03-17 16:36 UTC (permalink / raw)
To: binutils
Hi Chris,
> 2014-03-17 Christopher Faylor <me.cygwin2014@cgf.cx>
>
> * Makefile.am: Use host version of windres.
> * Makefile.in: Regenerate.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Enable Windows --auto-image-base to take an argument
2014-03-17 14:17 [PATCH] Minor Cygwin/ld Makefile tweak Christopher Faylor
2014-03-17 16:36 ` Nicholas Clifton
@ 2014-03-17 17:40 ` Christopher Faylor
2014-03-18 0:46 ` Alan Modra
2014-03-19 16:11 ` Nicholas Clifton
1 sibling, 2 replies; 6+ messages in thread
From: Christopher Faylor @ 2014-03-17 17:40 UTC (permalink / raw)
To: binutils
I've been carrying this patch in the cygwin version of ld for a
while. Ok to apply?
cgf
commit 606e9fc6a35cf48cc71d7d4ebc4cabc3f02b488e
Author: Chris Faylor <me.cygwin2011@cgf.cx>
Date: Mon Mar 17 13:38:52 2014 -0400
2014-03-17 Christopher Faylor <me.cygwin2013@cgf.cx>
* 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/emultempl/pe.em b/ld/emultempl/pe.em
index 67df2bc..c18cb26 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 <file> Generate import library\n"));
fprintf (file, _(" --output-def <file> 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_<SYMBOL> 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[=<address>] 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=<string> When linking dynamically to a dll without\n\
an importlib, use <string><basename>.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 2c39d3c..8a41ee8 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Enable Windows --auto-image-base to take an argument
2014-03-17 17:40 ` [PATCH] Enable Windows --auto-image-base to take an argument Christopher Faylor
@ 2014-03-18 0:46 ` Alan Modra
2014-03-18 15:06 ` Christopher Faylor
2014-03-19 16:11 ` Nicholas Clifton
1 sibling, 1 reply; 6+ messages in thread
From: Alan Modra @ 2014-03-18 0:46 UTC (permalink / raw)
To: binutils
On Mon, Mar 17, 2014 at 01:40:53PM -0400, Christopher Faylor wrote:
> +static unsigned long pe_auto_image_base = 0x61500000;
[snip]
> - return 0x61300000 + ((hash << 16) & 0x0FFC0000);
> + return pe_auto_image_base + ((hash << 16) & 0x0FFC0000);
Was the magic number (613 to 615) change deliberate or is this a typo?
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Enable Windows --auto-image-base to take an argument
2014-03-18 0:46 ` Alan Modra
@ 2014-03-18 15:06 ` Christopher Faylor
0 siblings, 0 replies; 6+ messages in thread
From: Christopher Faylor @ 2014-03-18 15:06 UTC (permalink / raw)
To: binutils
On Tue, Mar 18, 2014 at 11:16:14AM +1030, Alan Modra wrote:
>On Mon, Mar 17, 2014 at 01:40:53PM -0400, Christopher Faylor wrote:
>> +static unsigned long pe_auto_image_base = 0x61500000;
>[snip]
>> - return 0x61300000 + ((hash << 16) & 0x0FFC0000);
>> + return pe_auto_image_base + ((hash << 16) & 0x0FFC0000);
>
>Was the magic number (613 to 615) change deliberate or is this a typo?
It was deliberate. That is actually an address which is supposed to
follow the Cygwin DLL but the DLL has grown large enough that a bump
was required.
cgf
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Enable Windows --auto-image-base to take an argument
2014-03-17 17:40 ` [PATCH] Enable Windows --auto-image-base to take an argument Christopher Faylor
2014-03-18 0:46 ` Alan Modra
@ 2014-03-19 16:11 ` Nicholas Clifton
1 sibling, 0 replies; 6+ messages in thread
From: Nicholas Clifton @ 2014-03-19 16:11 UTC (permalink / raw)
To: binutils
Hi Chris,
> 2014-03-17 Christopher Faylor <me.cygwin2013@cgf.cx>
>
> * 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.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-19 16:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-17 14:17 [PATCH] Minor Cygwin/ld Makefile tweak Christopher Faylor
2014-03-17 16:36 ` Nicholas Clifton
2014-03-17 17:40 ` [PATCH] Enable Windows --auto-image-base to take an argument Christopher Faylor
2014-03-18 0:46 ` Alan Modra
2014-03-18 15:06 ` Christopher Faylor
2014-03-19 16:11 ` Nicholas Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).