mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 22:07:58 +08:00
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.
This commit is contained in:
15
ld/ChangeLog
15
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)
|
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
|
* ldlang.c (wild_doit): Don't bother initializing the vma and
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
@ifinfo
|
@ifinfo
|
||||||
@format
|
@format
|
||||||
START-INFO-DIR-ENTRY
|
START-INFO-DIR-ENTRY
|
||||||
* Ld:: The GNU linker.
|
* Ld: (ld). The GNU linker.
|
||||||
END-INFO-DIR-ENTRY
|
END-INFO-DIR-ENTRY
|
||||||
@end format
|
@end format
|
||||||
@end ifinfo
|
@end ifinfo
|
||||||
@ -98,6 +98,9 @@ This file documents the GNU linker ld.
|
|||||||
@ifset H8300
|
@ifset H8300
|
||||||
* H8/300:: ld and the H8/300
|
* H8/300:: ld and the H8/300
|
||||||
@end ifset
|
@end ifset
|
||||||
|
@ifset Hitachi
|
||||||
|
* Hitachi:: ld and other Hitachi micros
|
||||||
|
@end ifset
|
||||||
@ifset I960
|
@ifset I960
|
||||||
* i960:: ld and the Intel 960 family
|
* i960:: ld and the Intel 960 family
|
||||||
@end ifset
|
@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.
|
@code{ld} symbol name syntax must be quoted.
|
||||||
@xref{Symbols, , Symbol Names}.
|
@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
|
@node Section Placement
|
||||||
@subsection Section Placement
|
@subsection Section Placement
|
||||||
|
|
||||||
@ -1713,7 +1725,7 @@ optional portions:
|
|||||||
SECTIONS @{
|
SECTIONS @{
|
||||||
@dots{}
|
@dots{}
|
||||||
@var{secname} @var{start} BLOCK(@var{align}) (NOLOAD) : AT ( @var{ldadr} )
|
@var{secname} @var{start} BLOCK(@var{align}) (NOLOAD) : AT ( @var{ldadr} )
|
||||||
@{ @var{contents} @} =@var{fill} >@var{region}
|
@{ @var{contents} @} >@var{region} =@var{fill}
|
||||||
@dots{}
|
@dots{}
|
||||||
@}
|
@}
|
||||||
@end smallexample
|
@end smallexample
|
||||||
@ -1722,7 +1734,7 @@ SECTIONS @{
|
|||||||
Definition}, and @pxref{Section Placement} for details on
|
Definition}, and @pxref{Section Placement} for details on
|
||||||
@var{contents}. The remaining elements---@var{start},
|
@var{contents}. The remaining elements---@var{start},
|
||||||
@code{BLOCK(@var{align)}}, @code{(NOLOAD)}, @code{AT ( @var{ldadr} )},
|
@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
|
@table @code
|
||||||
@cindex start address, section
|
@cindex start address, section
|
||||||
@ -1816,6 +1828,13 @@ for (dst = _bstart; dst< _bend; dst++)
|
|||||||
*dst = 0;
|
*dst = 0;
|
||||||
@end smallexample
|
@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}
|
@kindex =@var{fill}
|
||||||
@cindex section fill pattern
|
@cindex section fill pattern
|
||||||
@cindex fill pattern, entire section
|
@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}
|
change the fill value with a @code{FILL} statement in the @var{contents}
|
||||||
of a section definition.
|
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
|
@end table
|
||||||
|
|
||||||
@node Entry Point
|
@node Entry Point
|
||||||
@ -2072,6 +2084,19 @@ top page of memory).
|
|||||||
@end ifclear
|
@end ifclear
|
||||||
@end ifset
|
@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
|
@ifset I960
|
||||||
@ifclear GENERIC
|
@ifclear GENERIC
|
||||||
@raisesections
|
@raisesections
|
||||||
|
59
ld/ldlang.c
59
ld/ldlang.c
@ -81,8 +81,6 @@ static void wild_doit PARAMS ((lang_statement_list_type *ptr,
|
|||||||
asection *section,
|
asection *section,
|
||||||
lang_output_section_statement_type *output,
|
lang_output_section_statement_type *output,
|
||||||
lang_input_statement_type *file));
|
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,
|
static void wild_section PARAMS ((lang_wild_statement_type *ptr,
|
||||||
const char *section,
|
const char *section,
|
||||||
lang_input_statement_type *file,
|
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 open_input_bfds PARAMS ((lang_statement_union_type *statement));
|
||||||
static void lang_reasonable_defaults PARAMS ((void));
|
static void lang_reasonable_defaults PARAMS ((void));
|
||||||
static void lang_place_undefineds 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
|
static void map_input_to_output_sections
|
||||||
PARAMS ((lang_statement_union_type *s,
|
PARAMS ((lang_statement_union_type *s,
|
||||||
const char *target,
|
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
|
static void
|
||||||
wild_section (ptr, section, file, output)
|
wild_section (ptr, section, file, output)
|
||||||
lang_wild_statement_type * ptr;
|
lang_wild_statement_type * ptr;
|
||||||
@ -723,7 +712,7 @@ wild_section (ptr, section, file, output)
|
|||||||
if (section == (char *) NULL)
|
if (section == (char *) NULL)
|
||||||
{
|
{
|
||||||
/* Do the creation to all sections in the file */
|
/* Do the creation to all sections in the file */
|
||||||
for (s = file->the_bfd->sections; s != (asection *) NULL; s = s->next)
|
for (s = file->the_bfd->sections; s != NULL; s = s->next)
|
||||||
{
|
{
|
||||||
/* except for bss */
|
/* except for bss */
|
||||||
if ((s->flags & SEC_IS_COMMON) == 0)
|
if ((s->flags & SEC_IS_COMMON) == 0)
|
||||||
@ -735,9 +724,9 @@ wild_section (ptr, section, file, output)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Do the creation to the named section only */
|
/* Do the creation to the named section only */
|
||||||
wild_doit (&ptr->children,
|
s = bfd_get_section_by_name (file->the_bfd, section);
|
||||||
our_bfd_get_section_by_name (file->the_bfd, section),
|
if (s != NULL)
|
||||||
output, file);
|
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 */
|
/* Open input files and attatch to output sections */
|
||||||
static void
|
static void
|
||||||
map_input_to_output_sections (s, target, output_section_statement)
|
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_reloc_statement_enum:
|
||||||
case lang_assignment_statement_enum:
|
case lang_assignment_statement_enum:
|
||||||
case lang_padding_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;
|
break;
|
||||||
case lang_afile_asection_pair_statement_enum:
|
case lang_afile_asection_pair_statement_enum:
|
||||||
FAIL ();
|
FAIL ();
|
||||||
@ -1119,9 +1091,6 @@ map_input_to_output_sections (s, target, output_section_statement)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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;
|
bfd_vma after;
|
||||||
lang_output_section_statement_type *os = &s->output_section_statement;
|
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
|
/* If this is a COFF shared library section, use the size and
|
||||||
address from the input section. FIXME: This is COFF
|
address from the input section. FIXME: This is COFF
|
||||||
specific; it would be cleaner if there were some other way
|
specific; it would be cleaner if there were some other way
|
||||||
@ -2256,6 +2231,9 @@ lang_place_orphans ()
|
|||||||
{
|
{
|
||||||
asection *s;
|
asection *s;
|
||||||
|
|
||||||
|
if (file->just_syms_flag)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (s = file->the_bfd->sections;
|
for (s = file->the_bfd->sections;
|
||||||
s != (asection *) NULL;
|
s != (asection *) NULL;
|
||||||
s = s->next)
|
s = s->next)
|
||||||
@ -2516,9 +2494,6 @@ lang_process ()
|
|||||||
current_target = default_target;
|
current_target = default_target;
|
||||||
|
|
||||||
lang_for_each_statement (ldlang_open_output); /* Open the output file */
|
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 ();
|
ldemul_create_output_section_statements ();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user