This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [patch/RFC] ld/pe-dll.c: mark .reloc section as discardable unless building a relocatable dll
- From: Christopher Faylor <cgf at redhat dot com>
- To: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Cc: binutils <binutils at sources dot redhat dot com>,Charles Wilson <cwilson at ece dot gatech dot edu>
- Date: Sun, 27 Jul 2003 12:12:12 -0400
- Subject: Re: [patch/RFC] ld/pe-dll.c: mark .reloc section as discardable unless building a relocatable dll
- References: <20030727100456.4488.qmail@web21412.mail.yahoo.com>
On Sun, Jul 27, 2003 at 08:04:56PM +1000, Danny Smith wrote:
>Hi,
>
>{Charles, I am cc'ing you because of prior posts re: non-relocatable dll's)
>
>1) The patch to allow pe .exe files to export symbols
>
>http://sources.redhat.com/ml/binutils-cvs/2003-04/msg00024.html.
>
>has changed the meaning of the -dll switch.
>
>Previously, the -dll switch just set the image base to the dll default. It did not
>enable any of the relocatability magic.
>
>In past, the -dll switch could be use to produce a
>non-relocatable dll with something like this:
>
>$ dlltool --def code1.def --dllname dll1-nr.dll --output-lib libdll1.a --output-exp dll1.exp
>$ gcc -mdll -o dll1-nr.dll dll1.exp code1.c
>
>where the -mdll gcc switch passed this to ld:
>--dll -e _DllMainCRTStartup@12
>
>Now, the --dll switch does exactly the same thing as --shared: it produces a
>.reloc section and a relocatable dll
>
>We can still change a relocatable dll to a non-relocatable one by
>stripping the .reloc section, eg:
>strip -R .reloc foo.dll, but this is not explicitly documented.
>
>2) The patch to allow .exe fills to export symbols also put a .reloc section
>into .exe files that export symbols. As far as I can see, this .reloc
>info is not needed for .exe's, and can be discarded with strip -R .reloc
>with no adverse effects.
Hmm. Does this mean that exes can't be relocatable? I could see a
reason to make an exe which exports symbols relocatable in the off
chance that you wanted to use the exe as a dll and reference symbols in
the exe as you would for a DLL. It's a very uncommon usage but it seems
like this patch would get rid of that. Do the MS tools allow anything
like this? It's been a while since I read the link documentation.
>OK, the MS linker has a switch /FIXED which keeps, but flags the .reloc
>section as MEM_DISCARDABLE when run in 'debug' mode, but strips the
>.reloc section when run in 'release' mode. This allow testing and
>tweaking of the image base whilst debugging, but optimisimg by
>discarding the .reloc section for release. Also, when exporting symbols
>from .exe files, , by default, the MS linker marks the .reloc section as
>MEM_DISCARDABLE in debug mode, and strips the section in relaese mode.
>
>The following patch marks the .reloc section with the SEC_DEBUGGING flag
>(equivalent to MEM_DISCARDABLE for pe targets) to make discarding of
>.reloc sections for non-reloc .dlls and .exes easier,
Does the effect of this patch mean that normal stripping (which removes
debug info) will make the DLL non-relocatable?
cgf