diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-05-11 20:29:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-05-11 20:29:21 +0000 |
commit | f9d3d71ae87f7fd6863696306e2cd08f5f6e4c74 (patch) | |
tree | ff35b0c3da2d648e22a24b6439b57d6af49aca66 /ld | |
parent | 4fa4476bf86ec660c4a7c279e91d7df7f7ec24f3 (diff) | |
download | gdb-f9d3d71ae87f7fd6863696306e2cd08f5f6e4c74.zip gdb-f9d3d71ae87f7fd6863696306e2cd08f5f6e4c74.tar.gz gdb-f9d3d71ae87f7fd6863696306e2cd08f5f6e4c74.tar.bz2 |
Don't create unnecessary output sections.
* ldlang.c (out_bfd_get_section_by_name): Remove.
(wild_section): Call bfd_get_section_by_name rather than
our_bfd_get_section_by_name. Don't call wild_doit if there is no
section.
(lang_create_output_section_statements): Remove.
(map_input_to_output_sections): For several cases, call init_os if
it has not already been called.
(lang_size_sections): If output section was not created, skip it.
(lang_process): Don't call lan_create_output_section_statements.
(lang_place_orphans): Skip files with just_syms_flags set to true.
* ld.texinfo: Document change.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 15 | ||||
-rw-r--r-- | ld/ld.texinfo | 45 | ||||
-rw-r--r-- | ld/ldlang.c | 69 |
3 files changed, 72 insertions, 57 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index b0e5519..d37570a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,18 @@ +Wed May 11 16:24:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Don't create unnecessary output sections. + * ldlang.c (out_bfd_get_section_by_name): Remove. + (wild_section): Call bfd_get_section_by_name rather than + our_bfd_get_section_by_name. Don't call wild_doit if there is no + section. + (lang_create_output_section_statements): Remove. + (map_input_to_output_sections): For several cases, call init_os if + it has not already been called. + (lang_size_sections): If output section was not created, skip it. + (lang_process): Don't call lan_create_output_section_statements. + (lang_place_orphans): Skip files with just_syms_flags set to true. + * ld.texinfo: Document change. + Tue May 10 14:31:16 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * ldlang.c (wild_doit): Don't bother initializing the vma and diff --git a/ld/ld.texinfo b/ld/ld.texinfo index d2714c0..65a9d10 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -9,7 +9,7 @@ @ifinfo @format START-INFO-DIR-ENTRY -* Ld:: The GNU linker. +* Ld: (ld). The GNU linker. END-INFO-DIR-ENTRY @end format @end ifinfo @@ -98,6 +98,9 @@ This file documents the GNU linker ld. @ifset H8300 * H8/300:: ld and the H8/300 @end ifset +@ifset Hitachi +* Hitachi:: ld and other Hitachi micros +@end ifset @ifset I960 * i960:: ld and the Intel 960 family @end ifset @@ -1432,6 +1435,15 @@ 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 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, +@example +.foo @{ *(.foo @} +@end example +will only create a @samp{.foo} section in the output file if there is a +@samp{.foo} section in at least one input file. + @node Section Placement @subsection Section Placement @@ -1713,7 +1725,7 @@ optional portions: SECTIONS @{ @dots{} @var{secname} @var{start} BLOCK(@var{align}) (NOLOAD) : AT ( @var{ldadr} ) - @{ @var{contents} @} =@var{fill} >@var{region} + @{ @var{contents} @} >@var{region} =@var{fill} @dots{} @} @end smallexample @@ -1722,7 +1734,7 @@ SECTIONS @{ Definition}, and @pxref{Section Placement} for details on @var{contents}. The remaining elements---@var{start}, @code{BLOCK(@var{align)}}, @code{(NOLOAD)}, @code{AT ( @var{ldadr} )}, -@code{=@var{fill}}, and @code{>@var{region}}---are all optional. +@code{>@var{region}}, and @code{=@var{fill}}---are all optional. @table @code @cindex start address, section @@ -1816,6 +1828,13 @@ for (dst = _bstart; dst< _bend; dst++) *dst = 0; @end smallexample +@kindex >@var{region} +@cindex section, assigning to memory region +@cindex memory regions and sections +@item >@var{region} +Assign this section to a previously defined region of memory. +@xref{MEMORY}. + @kindex =@var{fill} @cindex section fill pattern @cindex fill pattern, entire section @@ -1828,13 +1847,6 @@ significant bytes of the value, repeated as necessary. You can also change the fill value with a @code{FILL} statement in the @var{contents} of a section definition. -@kindex >@var{region} -@cindex section, assigning to memory region -@cindex memory regions and sections -@item >@var{region} -Assign this section to a previously defined region of memory. -@xref{MEMORY}. - @end table @node Entry Point @@ -2072,6 +2084,19 @@ top page of memory). @end ifclear @end ifset +@ifclear GENERIC +@ifset Hitachi +@c This stuff is pointless to say unless you're especially concerned +@c with Hitachi chips; don't enable it for generic case, please. +@node Hitachi +@chapter @code{ld} and other Hitachi chips + +@code{ld} also supports the H8/300H, the H8/500, and the Hitachi SH. No +special features, commands, or command-line options are required for +these chips. +@end ifset +@end ifclear + @ifset I960 @ifclear GENERIC @raisesections diff --git a/ld/ldlang.c b/ld/ldlang.c index c001dd9..98a0e8d 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -81,8 +81,6 @@ static void wild_doit PARAMS ((lang_statement_list_type *ptr, asection *section, lang_output_section_statement_type *output, lang_input_statement_type *file)); -static asection *our_bfd_get_section_by_name PARAMS ((bfd *abfd, - const char *section)); static void wild_section PARAMS ((lang_wild_statement_type *ptr, const char *section, lang_input_statement_type *file, @@ -98,7 +96,6 @@ static void ldlang_open_output PARAMS ((lang_statement_union_type *statement)); static void open_input_bfds PARAMS ((lang_statement_union_type *statement)); static void lang_reasonable_defaults PARAMS ((void)); static void lang_place_undefineds PARAMS ((void)); -static void lang_create_output_section_statements PARAMS ((void)); static void map_input_to_output_sections PARAMS ((lang_statement_union_type *s, const char *target, @@ -701,14 +698,6 @@ wild_doit (ptr, section, output, file) } } -static asection * -our_bfd_get_section_by_name (abfd, section) - bfd * abfd; - CONST char *section; -{ - return bfd_get_section_by_name (abfd, section); -} - static void wild_section (ptr, section, file, output) lang_wild_statement_type * ptr; @@ -723,21 +712,21 @@ wild_section (ptr, section, file, output) if (section == (char *) NULL) { /* Do the creation to all sections in the file */ - for (s = file->the_bfd->sections; s != (asection *) NULL; s = s->next) - { - /* except for bss */ - if ((s->flags & SEC_IS_COMMON) == 0) + for (s = file->the_bfd->sections; s != NULL; s = s->next) { - wild_doit (&ptr->children, s, output, file); + /* except for bss */ + if ((s->flags & SEC_IS_COMMON) == 0) + { + wild_doit (&ptr->children, s, output, file); + } } - } } else { /* Do the creation to the named section only */ - wild_doit (&ptr->children, - our_bfd_get_section_by_name (file->the_bfd, section), - output, file); + s = bfd_get_section_by_name (file->the_bfd, section); + if (s != NULL) + wild_doit (&ptr->children, s, output, file); } } } @@ -1038,27 +1027,6 @@ lang_place_undefineds () } } -/* Copy important data from out internal form to the bfd way. Also - create a section for the dummy file - */ - -static void -lang_create_output_section_statements () -{ - lang_statement_union_type *os; - - for (os = lang_output_section_statement.head; - os != (lang_statement_union_type *) NULL; - os = os->output_section_statement.next) - { - lang_output_section_statement_type *s = - &os->output_section_statement; - - init_os (s); - } - -} - /* Open input files and attatch to output sections */ static void map_input_to_output_sections (s, target, output_section_statement) @@ -1100,6 +1068,10 @@ map_input_to_output_sections (s, target, output_section_statement) case lang_reloc_statement_enum: case lang_assignment_statement_enum: case lang_padding_statement_enum: + case lang_input_statement_enum: + if (output_section_statement != NULL + && output_section_statement->bfd_section == NULL) + init_os (output_section_statement); break; case lang_afile_asection_pair_statement_enum: FAIL (); @@ -1119,9 +1091,6 @@ map_input_to_output_sections (s, target, output_section_statement) } } break; - case lang_input_statement_enum: - /* A standard input statement, has no wildcards */ - break; } } } @@ -1639,6 +1608,12 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax) bfd_vma after; lang_output_section_statement_type *os = &s->output_section_statement; + if (os->bfd_section == NULL) + { + /* This section was never actually created. */ + break; + } + /* If this is a COFF shared library section, use the size and address from the input section. FIXME: This is COFF specific; it would be cleaner if there were some other way @@ -2256,6 +2231,9 @@ lang_place_orphans () { asection *s; + if (file->just_syms_flag) + continue; + for (s = file->the_bfd->sections; s != (asection *) NULL; s = s->next) @@ -2516,9 +2494,6 @@ lang_process () current_target = default_target; lang_for_each_statement (ldlang_open_output); /* Open the output file */ - /* For each output section statement, create a section in the output - file */ - lang_create_output_section_statements (); ldemul_create_output_section_statements (); |