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/ldlang.c | |
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/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 26 |
1 files changed, 20 insertions, 6 deletions
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; } |