This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH [v2]: makes --gc-sections compatible with -r/-q
On Wed, Jan 09, 2008 at 04:48:58PM +0100, Tristan Gingold wrote:
> >You need to modify gc_sweep_hook to cope with -r for all targets.
> >Also, Eric's change, "Add missing guard", is not the proper fix for
> >ppc_elf_gc_sweep_hook. You should instead exit ppc_elf_gc_sweep_hook
> >immediately if -r, because that is what ppc_elf_check_relocs does.
>
> Ok, here is the new version of the patch.
>
> * makes all gc_sweep_hook coherent with check_relocs (ie exit
> immediately if -r)
That looks better, but please explain why you omitted elf32-bfin.c and
elf64-mmix.c. I'm not saying you are wrong in this (bfin is fairly
obviously ok), but I'd like confirmation that you at least looked at
these targets..
> * --gc-section -r requires a non-default entry point
> * document in --gc-section the use of -e
Does forcing the use of -e really make sense? What if I'm using
-r --gc-sections on an object file and wish to keep two functions and
everything they depend on? Wouldn't -u be a more natural option to
use in that case? Hmm, I guess a warning or error would be useful if
neither -e or -u is specified.
I'm committing the following --gc-sections overview.
* ld.texinfo (--gc-sections): Describe linker behaviour.
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.203
diff -u -p -r1.203 ld.texinfo
--- ld/ld.texinfo 1 Oct 2007 09:54:57 -0000 1.203
+++ ld/ld.texinfo 10 Jan 2008 01:06:17 -0000
@@ -1285,6 +1285,16 @@ with @samp{-r} or @samp{--emit-relocs}.
performing this garbage collection) can be restored by specifying
@samp{--no-gc-sections} on the command line.
+@samp{--gc-sections} decides which input sections are used by
+examining symbols and relocations. The section containing the entry
+symbol and all sections containing symbols undefined on the
+command-line will be kept, as will sections containing symbols
+referenced by dynamic objects. Note that when building shared
+libraries, the linker must assume that any visible symbol is
+referenced. Once this initial set of sections has been determined,
+the linker recursively marks as used any section referenced by their
+relocations. See @samp{--entry} and @samp{--undefined}.
+
@kindex --print-gc-sections
@kindex --no-print-gc-sections
@cindex garbage collection
--
Alan Modra
Australia Development Lab, IBM