+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
@ifinfo
@format
START-INFO-DIR-ENTRY
-* Ld:: The GNU linker.
+* Ld: (ld). The GNU linker.
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@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
@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
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
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
*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
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
@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
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,
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,
}
}
-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;
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);
}
}
}
}
}
-/* 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)
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 ();
}
}
break;
- case lang_input_statement_enum:
- /* A standard input statement, has no wildcards */
- break;
}
}
}
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
{
asection *s;
+ if (file->just_syms_flag)
+ continue;
+
for (s = file->the_bfd->sections;
s != (asection *) NULL;
s = s->next)
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 ();