diff options
author | Alan Modra <amodra@gmail.com> | 2004-05-28 05:42:30 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2004-05-28 05:42:30 +0000 |
commit | 164e712d71c3e73cf048b45615b8f3f2f1fc4b84 (patch) | |
tree | af51365646945b52fa48e5eebdd14b134562df8a /ld/ldlang.c | |
parent | 652ca075fb8a0fa8dfaed984df1e8ca250f6fcce (diff) | |
download | gdb-164e712d71c3e73cf048b45615b8f3f2f1fc4b84.zip gdb-164e712d71c3e73cf048b45615b8f3f2f1fc4b84.tar.gz gdb-164e712d71c3e73cf048b45615b8f3f2f1fc4b84.tar.bz2 |
* ldlang.c (lang_add_section): Don't twidlle SEC_EXCLUDE here.
(output_section_callback): Nor SEC_KEEP here.
(gc_section_callback): Twiddle SEC_EXCLUDE here.
(lang_gc_wild): Delete. Fold into..
(lang_gc_sections_1): ..here. Only call bfd_gc_sections when garbage
collecting.
(lang_process): Always call lang_gc_sections.
(lang_place_orphans): Handle SEC_EXCLUDE sections.
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Remove
SEC_EXCLUDE code.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index b4c2559..991a647 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1089,23 +1089,9 @@ lang_add_section (lang_statement_list_type *ptr, lang_output_section_statement_type *output, lang_input_statement_type *file) { - flagword flags; + flagword flags = section->flags; bfd_boolean discard; - flags = bfd_get_section_flags (section->owner, section); - - /* SEC_EXCLUDE is ignored when doing a relocatable link, except in - the special case of debug info. (See bfd/stabs.c) */ - if (link_info.relocatable && (flags & SEC_DEBUGGING) == 0) - { - flags &= ~SEC_EXCLUDE; - - /* Write the modified flag back, to simplify later linker - code. */ - if (section->owner != NULL) - bfd_set_section_flags (section->owner, section, flags); - } - /* Discard sections marked with SEC_EXCLUDE. */ discard = (flags & SEC_EXCLUDE) != 0; @@ -1349,11 +1335,6 @@ output_section_callback (lang_wild_statement_type *ptr, if (unique_section_p (section)) return; - /* If the wild pattern was marked KEEP, the member sections - should be as well. */ - if (ptr->keep_sections) - section->flags |= SEC_KEEP; - before = wild_sort (ptr, sec, file, section); /* Here BEFORE points to the lang_input_section which @@ -4029,9 +4010,10 @@ lang_place_orphans (void) around for a sensible place for it to go. */ if (file->just_syms_flag) - { - abort (); - } + abort (); + + if ((s->flags & SEC_EXCLUDE) != 0) + s->output_section = bfd_abs_section_ptr; else if (strcmp (s->name, "COMMON") == 0) { /* This is a lonely common section which must have @@ -4271,8 +4253,7 @@ lang_reset_memory_regions (void) o->_raw_size = 0; } -/* If the wild pattern was marked KEEP, the member sections - should be as well. */ +/* Worker for lang_gc_sections_1. */ static void gc_section_callback (lang_wild_statement_type *ptr, @@ -4281,18 +4262,18 @@ gc_section_callback (lang_wild_statement_type *ptr, lang_input_statement_type *file ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { + /* SEC_EXCLUDE is ignored when doing a relocatable link, except in + the special case of debug info. (See bfd/stabs.c) + Twiddle the flag here, to simplify later linker code. */ + if (link_info.relocatable && (section->flags & SEC_DEBUGGING) == 0) + section->flags &= ~SEC_EXCLUDE; + + /* If the wild pattern was marked KEEP, the member sections + should be as well. */ if (ptr->keep_sections) section->flags |= SEC_KEEP; } -/* Handle a wild statement, marking it against GC. */ - -static void -lang_gc_wild (lang_wild_statement_type *s) -{ - walk_wild (s, gc_section_callback, NULL); -} - /* Iterate over sections marking them against GC. */ static void @@ -4303,7 +4284,7 @@ lang_gc_sections_1 (lang_statement_union_type *s) switch (s->header.type) { case lang_wild_statement_enum: - lang_gc_wild (&s->wild_statement); + walk_wild (&s->wild_statement, gc_section_callback, NULL); break; case lang_constructors_statement_enum: lang_gc_sections_1 (constructor_list.head); @@ -4347,7 +4328,8 @@ lang_gc_sections (void) } } - bfd_gc_sections (output_bfd, &link_info); + if (command_line.gc_sections) + bfd_gc_sections (output_bfd, &link_info); } void @@ -4395,8 +4377,7 @@ lang_process (void) ldctor_build_sets (); /* Remove unreferenced sections if asked to. */ - if (command_line.gc_sections) - lang_gc_sections (); + lang_gc_sections (); /* Size up the common data. */ lang_common (); |