* ld.h (DISCARD_SECTION_NAME): Define to "/DISCARD/".
authorIan Lance Taylor <ian@airs.com>
Wed, 27 Mar 1996 18:17:28 +0000 (18:17 +0000)
committerIan Lance Taylor <ian@airs.com>
Wed, 27 Mar 1996 18:17:28 +0000 (18:17 +0000)
* 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/.

ld/ChangeLog
ld/ld.texinfo
ld/ldlang.c

index c01cb83..f535eb5 100644 (file)
@@ -1,5 +1,12 @@
 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>
index d4f8187..32d7497 100644 (file)
@@ -781,7 +781,6 @@ exist, @code{ld} looks for it in the directories specified by any
 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.
@@ -824,10 +823,11 @@ be added to.  Use @samp{-Ur} only for the last partial link, and
 @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
@@ -1759,6 +1759,10 @@ sequence of characters, but any name which does not conform to the standard
 @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,
index c134d0d..0af6ec6 100644 (file)
@@ -603,10 +603,13 @@ static void
 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)
@@ -622,7 +625,6 @@ init_os (s)
   /* 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.
@@ -642,6 +644,18 @@ wild_doit (ptr, section, output, file)
      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);
 
@@ -673,7 +687,7 @@ wild_doit (ptr, section, output, file)
       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;
     }