This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] More aggressive --gc-sections
- From: law at redhat dot com
- To: Eric Botcazou <ebotcazou at act-europe dot fr>
- Cc: binutils at sources dot redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Thu, 18 Mar 2004 10:09:17 -0700
- Subject: Re: [PATCH] More aggressive --gc-sections
- Reply-to: law at redhat dot com
In message <email@example.com>, Eric Botcazou writes:
>This is the minimal set of patches needed in order to make --gc-sections
>works for dynamically linked Ada programs using DWARF-2 EH on x86/Linux.
>For a description of the mechanism, see:
>The GCC part was bootstrapped/regtested on mainline, the binutils part was
>tested on mainline, with no new regressions. I ran the ACATS and libstdc++
>testsuites with -function-sections -fdata-sections -Wl,--gc-sections too.
>I don't expect these patches to be accepted, rather to serve as a starting
>point for the discussion. What do you think about the approach? What
>criteria should the patches meet to be accepted both in GCC and binutils?
>Thanks in advance.
> * except.h (output_function_exception_table): New prototype.
> * output.h (default_exception_section): New prototype.
> * target.h (struct gcc_target) <exception_section>: New prototype.
> * except.c (PTR_SIZE): New macro.
> (default_exception_section): New prototype.
> If named sections are supported and flag_function_sections is set,
> use a function-specific section.
> (output_function_exception_table): New prototype.
> Adjust call to targetm.asm_out.exception_section. Keep track of the LD
> label. If flag_function_sections is set, emit a reference to the LDSA
> label in the function section.
> * passes.c (rest_of_handle_final): Adjust calls to
> * Makefile.in (LIBGCC2_CFLAGS): Add -ffunction-sections -fdata-sections
> * ada/Makefile.in (GNATLIBCFLAGS): Likewise.
> * ada/Make-lang.in (GNATLIBCFLAGS): Likewise.
> * elflink.h (elf_gc_mark_dynamic_ref_symbol): New function.
> (elf_gc_sections): Do not gracefully fail if dynamic sections have
> been created. Instead call elf_gc_mark_dynamic_ref_symbol to
> mark dynamically referenced symbols. Do not mark the whole graph
> rooted at .eh_frame, only the section proper.
> * scripttempl/elf.sc (.text): Add KEEP for .text.*personality*.
> (.data): Add KEEP for .gnu.linkonce.d.*personality*.
> (.gcc_except_table): Add KEEP for self and accept .gcc_except_table.*.
If you wanted to improve the long term maintainability of this code as
well as its compatibility with non-GC'd code you could put the special
GC related relocations into their own special section from the main
That's something Richard and I have talked about for a long long time, but
never got around to doing...