Wed Mar 27 12:33:24 1996 Ian Lance Taylor <ian@cygnus.com>
+ * ld.h (DISCARD_SECTION_NAME): Define to "/DISCARD/".
+ * ldlang.c (init_os): Fail on an attempt to initialize any section
+ named DISCARD_SECTION_NAME.
+ (wild_doit): Discard input sections assigned to an output section
+ named DISCARD_SECTION_NAME.
+ * ld.texinfo: Document use of /DISCARD/.
+
* ldlang.c: Fix some indentation and comments.
Tue Mar 26 18:14:49 1996 Ian Lance Taylor <ian@cygnus.com>
preceding @samp{-L} options. Multiple @samp{-T} options accumulate.
@kindex -t
-@cindex verbose
@cindex input files, displaying
@item -t
Print the names of the input files as @code{ld} processes them.
@samp{-r} for the others.
@kindex --verbose
-@cindex version
+@cindex verbose
@item --verbose
Display the version number for @code{ld} and list the linker emulations
-supported. Display which input files can and cannot be opened.
+supported. Display which input files can and cannot be opened. Display
+the linker script if using a default builtin script.
@kindex -v
@kindex -V
@code{ld} symbol name syntax must be quoted.
@xref{Symbols, , Symbol Names}.
+The special @var{secname} @samp{/DISCARD/} may be used to discard input
+sections. Any sections which are assigned to an output section named
+@samp{/DISCARD/} are not included in the final link output.
+
The linker will not create output sections which do not have any
contents. This is for convenience when referring to input sections that
may or may not exist. For example,
init_os (s)
lang_output_section_statement_type * s;
{
-/* asection *section = bfd_get_section_by_name(output_bfd, s->name);*/
- section_userdata_type *new =
- (section_userdata_type *)
- stat_alloc (sizeof (section_userdata_type));
+ section_userdata_type *new;
+
+ if (strcmp (s->name, DISCARD_SECTION_NAME) == 0)
+ einfo ("%P%F: Illegal use of `%s' section", DISCARD_SECTION_NAME);
+
+ new = ((section_userdata_type *)
+ stat_alloc (sizeof (section_userdata_type)));
s->bfd_section = bfd_get_section_by_name (output_bfd, s->name);
if (s->bfd_section == (asection *) NULL)
/* vma to allow us to output a section through itself */
s->bfd_section->output_offset = 0;
get_userdata (s->bfd_section) = (PTR) new;
-
}
\f
/* The wild routines.
lang_output_section_statement_type *output;
lang_input_statement_type *file;
{
+ /* Input sections which are assigned to a section named
+ DISCARD_SECTION_NAME are discarded. */
+ if (strcmp (output->name, DISCARD_SECTION_NAME) == 0)
+ {
+ if (section != NULL && section->output_section == NULL)
+ {
+ /* This prevents future calls from assigning this section. */
+ section->output_section = bfd_abs_section_ptr;
+ }
+ return;
+ }
+
if (output->bfd_section == NULL)
init_os (output);
if (section->alignment_power > output->bfd_section->alignment_power)
output->bfd_section->alignment_power = section->alignment_power;
- /* If supplied an aligment, then force it */
+ /* If supplied an aligment, then force it. */
if (output->section_alignment != -1)
output->bfd_section->alignment_power = output->section_alignment;
}