diff options
author | Ian Lance Taylor <ian@airs.com> | 1996-03-27 18:17:28 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1996-03-27 18:17:28 +0000 |
commit | cf2e4f5fdee71e74fac6d295e642375db2e9c4c4 (patch) | |
tree | 26bb5872e3ba2fe812702fbb0d1a6fbf920256d4 /ld | |
parent | 64664e69cb97239f938f8eacd317f4feb7a268a9 (diff) | |
download | gdb-cf2e4f5fdee71e74fac6d295e642375db2e9c4c4.zip gdb-cf2e4f5fdee71e74fac6d295e642375db2e9c4c4.tar.gz gdb-cf2e4f5fdee71e74fac6d295e642375db2e9c4c4.tar.bz2 |
* 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/.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 7 | ||||
-rw-r--r-- | ld/ld.texinfo | 10 | ||||
-rw-r--r-- | ld/ldlang.c | 26 |
3 files changed, 34 insertions, 9 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index c01cb83..f535eb5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -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> diff --git a/ld/ld.texinfo b/ld/ld.texinfo index d4f8187..32d7497 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -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, diff --git a/ld/ldlang.c b/ld/ldlang.c index c134d0d..0af6ec6 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -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; - } /* 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; } |