2000-10-05 Kazu Hirata <kazu@hxi.com>

* ldlang.c: Fix formatting.
This commit is contained in:
Kazu Hirata 2000-10-05 13:03:30 +00:00
parent ce8a8b2f62
commit 08da4cac4a
2 changed files with 272 additions and 270 deletions

View File

@ -1,3 +1,7 @@
2000-10-05 Kazu Hirata <kazu@hxi.com>
* ldlang.c: Fix formatting.
2000-10-03 DJ Delorie <dj@redhat.com>
* pe-dll.c (fill_edata): initialize entire block

View File

@ -212,9 +212,7 @@ stat_alloc (size)
return obstack_alloc (&stat_obstack, size);
}
/*----------------------------------------------------------------------
Generic traversal routines for finding matching sections.
*/
/* Generic traversal routines for finding matching sections. */
static void
walk_wild_section (ptr, section, file, callback, data)
@ -348,10 +346,8 @@ walk_wild (s, section, file, callback, data)
}
}
/*----------------------------------------------------------------------
lang_for_each_statement walks the parse tree and calls the provided
function for each node
*/
/* lang_for_each_statement walks the parse tree and calls the provided
function for each node. */
static void
lang_for_each_statement_worker (func, s)
@ -404,11 +400,11 @@ void
lang_for_each_statement (func)
void (*func) PARAMS ((lang_statement_union_type *));
{
lang_for_each_statement_worker (func,
statement_list.head);
lang_for_each_statement_worker (func, statement_list.head);
}
/*----------------------------------------------------------------------*/
void
lang_list_init (list)
lang_statement_list_type *list;
@ -417,14 +413,9 @@ lang_list_init (list)
list->tail = &list->head;
}
/*----------------------------------------------------------------------
/* Build a new statement node for the parse tree. */
build a new statement node for the parse tree
*/
static
lang_statement_union_type *
static lang_statement_union_type *
new_statement (type, size, list)
enum statement_enum type;
size_t size;
@ -439,17 +430,15 @@ new_statement (type, size, list)
return new;
}
/*
Build a new input file node for the language. There are several ways
in which we treat an input file, eg, we only look at symbols, or
prefix it with a -l etc.
/* Build a new input file node for the language. There are several
ways in which we treat an input file, eg, we only look at symbols,
or prefix it with a -l etc.
We can be supplied with requests for input files more than once;
they may, for example be split over serveral lines like foo.o(.text)
foo.o(.data) etc, so when asked for a file we check that we havn't
got it already so we don't duplicate the bfd.
got it already so we don't duplicate the bfd. */
*/
static lang_input_statement_type *
new_afile (name, file_type, target, add_to_list)
const char *name;
@ -547,7 +536,8 @@ lang_add_input_file (name, file_type, target)
return new_afile (name, file_type, target, true);
}
/* Build enough state so that the parser can build its tree */
/* Build enough state so that the parser can build its tree. */
void
lang_init ()
{
@ -563,7 +553,8 @@ lang_init ()
first_file = lang_add_input_file ((char *) NULL,
lang_input_file_is_marker_enum,
(char *) NULL);
abs_output_section = lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME);
abs_output_section =
lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME);
abs_output_section->bfd_section = bfd_abs_section_ptr;
@ -574,11 +565,10 @@ lang_init ()
MEMORY { name:org=exp, len=exp ... }
syntax.
We maintain a list of all the regions here
We maintain a list of all the regions here.
If no regions are specified in the script, then the default is used
which is created when looked up to be the entire data space
*/
which is created when looked up to be the entire data space. */
static lang_memory_region_type *lang_memory_region_list;
static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list;
@ -820,8 +810,8 @@ init_os (s)
}
s->bfd_section->output_section = s->bfd_section;
/* We initialize an output sections output offset to minus its own */
/* vma to allow us to output a section through itself */
/* We initialize an output sections output offset to minus its own
vma to allow us to output a section through itself. */
s->bfd_section->output_offset = 0;
get_userdata (s->bfd_section) = (PTR) new;
@ -1140,7 +1130,7 @@ wild_doit (ptr, section, output, file)
else
first = false;
/* Add a section reference to the list */
/* Add a section reference to the list. */
new = new_stat (lang_input_section, ptr);
new->section = section;
@ -1546,6 +1536,7 @@ wild (s, section, file, target, output)
}
/* Return true iff target is the sought target. */
static int
get_target (target, data)
const bfd_target *target;
@ -1557,6 +1548,7 @@ get_target (target, data)
}
/* Like strcpy() but convert to lower case as well. */
static void
stricpy (dest, src)
char *dest;
@ -1577,6 +1569,7 @@ stricpy (dest, src)
/* Remove the first occurance of needle (if any) in haystack
from haystack. */
static void
strcut (haystack, needle)
char *haystack;
@ -1597,6 +1590,7 @@ strcut (haystack, needle)
/* Compare two target format name strings.
Return a value indicating how "similar" they are. */
static int
name_compare (first, second)
char *first;
@ -1641,6 +1635,7 @@ static const bfd_target * winner;
/* Scan all the valid bfd targets looking for one that has the endianness
requirement that was specified on the command line, and is the nearest
match to the original output target. */
static int
closest_target_match (target, data)
const bfd_target *target;
@ -1648,10 +1643,12 @@ closest_target_match (target, data)
{
const bfd_target *original = (const bfd_target *) data;
if (command_line.endian == ENDIAN_BIG && target->byteorder != BFD_ENDIAN_BIG)
if (command_line.endian == ENDIAN_BIG
&& target->byteorder != BFD_ENDIAN_BIG)
return 0;
if (command_line.endian == ENDIAN_LITTLE && target->byteorder != BFD_ENDIAN_LITTLE)
if (command_line.endian == ENDIAN_LITTLE
&& target->byteorder != BFD_ENDIAN_LITTLE)
return 0;
/* Must be the same flavour. */
@ -1675,6 +1672,7 @@ closest_target_match (target, data)
}
/* Return the BFD target format of the first input file. */
static char *
get_first_input_target ()
{
@ -1712,7 +1710,8 @@ open_output (name)
/* Has the user told us which output format to use? */
if (output_target == (char *) NULL)
{
/* No - has the current target been set to something other than the default ? */
/* No - has the current target been set to something other than
the default? */
if (current_target != default_target)
output_target = current_target;
@ -1727,7 +1726,8 @@ open_output (name)
}
}
/* Has the user requested a particular endianness on the command line ? */
/* Has the user requested a particular endianness on the command
line? */
if (command_line.endian != ENDIAN_UNSET)
{
const bfd_target *target;
@ -1785,7 +1785,9 @@ open_output (name)
delete_output_file_on_failure = true;
/* output->flags |= D_PAGED;*/
#if 0
output->flags |= D_PAGED;
#endif
if (! bfd_set_format (output, bfd_object))
einfo (_("%P%F:%s: can not make object file: %E\n"), name);
@ -1852,7 +1854,7 @@ open_input_bfds (s, force)
open_input_bfds (s->output_section_statement.children.head, force);
break;
case lang_wild_statement_enum:
/* Maybe we should load the file's symbols */
/* Maybe we should load the file's symbols. */
if (s->wild_statement.filename
&& ! wildcardp (s->wild_statement.filename))
(void) lookup_name (s->wild_statement.filename);
@ -1912,7 +1914,8 @@ open_input_bfds (s, force)
}
}
/* If there are [COMMONS] statements, put a wild one into the bss section */
/* If there are [COMMONS] statements, put a wild one into the bss
section. */
static void
lang_reasonable_defaults ()
@ -1921,8 +1924,7 @@ lang_reasonable_defaults ()
lang_output_section_statement_lookup (".text");
lang_output_section_statement_lookup (".data");
default_common_section =
lang_output_section_statement_lookup (".bss");
default_common_section = lang_output_section_statement_lookup (".bss");
if (placed_commons == false)
{
@ -1935,13 +1937,10 @@ lang_reasonable_defaults ()
lang_list_init (&new->children);
}
#endif
}
/*
Add the supplied name to the symbol table as an undefined reference.
Remove items from the chain as we open input bfds
*/
/* Add the supplied name to the symbol table as an undefined reference.
Remove items from the chain as we open input bfds. */
typedef struct ldlang_undef_chain_list
{
struct ldlang_undef_chain_list *next;
@ -1966,8 +1965,8 @@ ldlang_add_undef (name)
/* Run through the list of undefineds created above and place them
into the linker hash table as undefined symbols belonging to the
script file.
*/
script file. */
static void
lang_place_undefineds ()
{
@ -1991,7 +1990,8 @@ lang_place_undefineds ()
}
}
/* Open input files and attatch to output sections */
/* Open input files and attatch to output sections. */
static void
map_input_to_output_sections (s, target, output_section_statement)
lang_statement_union_type *s;
@ -2053,7 +2053,7 @@ map_input_to_output_sections (s, target, output_section_statement)
FAIL ();
break;
case lang_address_statement_enum:
/* Mark the specified section with the supplied address */
/* Mark the specified section with the supplied address. */
{
lang_output_section_statement_type *os =
lang_output_section_statement_lookup
@ -2575,8 +2575,7 @@ insert_pad (this_ptr, fill, power, output_section_statement, dot)
to the output section's requirement.
If this alignment is > than any seen before,
then record it too. Perform the alignment by
inserting a magic 'padding' statement.
*/
inserting a magic 'padding' statement. */
unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture,
ldfile_output_machine);
@ -2588,7 +2587,7 @@ insert_pad (this_ptr, fill, power, output_section_statement, dot)
((lang_statement_union_type *)
stat_alloc (sizeof (lang_padding_statement_type)));
/* Link into existing chain */
/* Link into existing chain. */
new->header.next = *this_ptr;
*this_ptr = new;
new->header.type = lang_padding_statement_enum;
@ -2599,7 +2598,7 @@ insert_pad (this_ptr, fill, power, output_section_statement, dot)
new->padding_statement.size = alignment_needed * opb;
}
/* Remember the most restrictive alignment */
/* Remember the most restrictive alignment. */
if (power > output_section_statement->alignment_power)
{
output_section_statement->alignment_power = power;
@ -2609,7 +2608,8 @@ insert_pad (this_ptr, fill, power, output_section_statement, dot)
return dot + alignment_needed;
}
/* Work out how much this section will move the dot point */
/* Work out how much this section will move the dot point. */
static bfd_vma
size_input_section (this_ptr, output_section_statement, fill, dot, relax)
lang_statement_union_type **this_ptr;
@ -2632,12 +2632,11 @@ size_input_section (this_ptr, output_section_statement, fill, dot, relax)
dot = insert_pad (this_ptr, fill, i->alignment_power,
output_section_statement->bfd_section, dot);
/* Remember where in the output section this input section goes */
/* Remember where in the output section this input section goes. */
i->output_offset = dot - output_section_statement->bfd_section->vma;
/* Mark how big the output section must be to contain this now
*/
/* Mark how big the output section must be to contain this now. */
if (i->_cooked_size != 0)
dot += i->_cooked_size / opb;
else
@ -2660,6 +2659,7 @@ size_input_section (this_ptr, output_section_statement, fill, dot, relax)
/* Check to see if any allocated sections overlap with other allocated
sections. This can happen when the linker script specifically specifies
the output section addresses of the two sections. */
static void
lang_check_section_addresses ()
{
@ -2878,11 +2878,12 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
os->bfd_section->output_offset = 0;
}
(void) lang_size_sections (os->children.head, os, &os->children.head,
(void) lang_size_sections (os->children.head, os,
&os->children.head,
os->fill, dot, relax);
/* put the section within the requested block size, or align at
the block boundary */
/* Put the section within the requested block size, or
align at the block boundary. */
after = ALIGN_N (os->bfd_section->vma
+ os->bfd_section->_raw_size / opb,
/* The coercion here is important, see ld.h. */
@ -2916,8 +2917,8 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
os_region_check (os, os->region, os->addr_tree,
os->bfd_section->vma);
/* if there's no load address specified, use the run region as
the load region */
/* If there's no load address specified, use the run
region as the load region. */
if (os->lma_region == NULL && os->load_base == NULL)
os->lma_region = os->region;
@ -2929,11 +2930,12 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
}
else
{
/* don't allocate twice */
/* Don't allocate twice. */
if (os->lma_region != os->region)
{
/* set load_base, which will be handled later */
os->load_base = exp_intop (os->lma_region->current);
/* Set load_base, which will be handled later. */
os->load_base =
exp_intop (os->lma_region->current);
os->lma_region->current +=
os->bfd_section->_raw_size / opb;
os_region_check (os, os->lma_region, NULL,
@ -2957,7 +2959,8 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
{
unsigned int size = 0;
s->data_statement.output_vma = dot - output_section_statement->bfd_section->vma;
s->data_statement.output_vma =
dot - output_section_statement->bfd_section->vma;
s->data_statement.output_section =
output_section_statement->bfd_section;
@ -2986,8 +2989,10 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
/* The output section gets contents, and then we inspect for
any flags set in the input script which override any ALLOC. */
output_section_statement->bfd_section->flags |= SEC_HAS_CONTENTS;
if (!(output_section_statement->flags & SEC_NEVER_LOAD)) {
output_section_statement->bfd_section->flags |= SEC_ALLOC | SEC_LOAD;
if (!(output_section_statement->flags & SEC_NEVER_LOAD))
{
output_section_statement->bfd_section->flags |=
SEC_ALLOC | SEC_LOAD;
}
}
break;
@ -3011,7 +3016,6 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
dot = lang_size_sections (s->wild_statement.children.head,
output_section_statement,
&s->wild_statement.children.head,
fill, dot, relax);
break;
@ -3051,7 +3055,8 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
case lang_input_statement_enum:
break;
case lang_fill_statement_enum:
s->fill_statement.output_section = output_section_statement->bfd_section;
s->fill_statement.output_section =
output_section_statement->bfd_section;
fill = s->fill_statement.fill;
break;
@ -3600,12 +3605,9 @@ lang_one_common (h, info)
return true;
}
/*
run through the input files and ensure that every input
section has somewhere to go. If one is found without
a destination then create an input request and place it
into the statement tree.
*/
/* Run through the input files and ensure that every input section has
somewhere to go. If one is found without a destination then create
an input request and place it into the statement tree. */
static void
lang_place_orphans ()
@ -3621,7 +3623,7 @@ lang_place_orphans ()
if (s->output_section == (asection *) NULL)
{
/* This section of the file is not attatched, root
around for a sensible place for it to go */
around for a sensible place for it to go. */
if (file->just_syms_flag)
{
@ -3851,16 +3853,16 @@ lang_enter_output_section_statement (output_section_statement_name,
os =
lang_output_section_statement_lookup (output_section_statement_name);
/* Add this statement to tree */
/* add_statement(lang_output_section_statement_enum,
output_section_statement);*/
/* Make next things chain into subchain of this */
/* Add this statement to tree. */
#if 0
add_statement (lang_output_section_statement_enum,
output_section_statement);
#endif
/* Make next things chain into subchain of this. */
if (os->addr_tree ==
(etree_type *) NULL)
if (os->addr_tree == (etree_type *) NULL)
{
os->addr_tree =
address_exp;
os->addr_tree = address_exp;
}
os->sectype = sectype;
if (sectype != noload_section)
@ -3870,13 +3872,10 @@ lang_enter_output_section_statement (output_section_statement_name,
os->block_value = block_value ? block_value : 1;
stat_ptr = &os->children;
os->subsection_alignment = topower(
exp_get_value_int(subalign, -1,
"subsection alignment",
0));
os->section_alignment = topower(
exp_get_value_int(align, -1,
"section alignment", 0));
os->subsection_alignment =
topower (exp_get_value_int (subalign, -1, "subsection alignment", 0));
os->section_alignment =
topower (exp_get_value_int (align, -1, "section alignment", 0));
os->load_base = ebase;
return os;
@ -3891,7 +3890,8 @@ lang_final ()
new->name = output_filename;
}
/* Reset the current counters in the regions */
/* Reset the current counters in the regions. */
static void
reset_memory_regions ()
{
@ -4009,16 +4009,17 @@ lang_process ()
lang_reasonable_defaults ();
current_target = default_target;
lang_for_each_statement (ldlang_open_output); /* Open the output file */
/* Open the output file. */
lang_for_each_statement (ldlang_open_output);
ldemul_create_output_section_statements ();
/* Add to the hash table all undefineds on the command line */
/* Add to the hash table all undefineds on the command line. */
lang_place_undefineds ();
already_linked_table_init ();
/* Create a bfd for each input file */
/* Create a bfd for each input file. */
current_target = default_target;
open_input_bfds (statement_list.head, false);
@ -4045,16 +4046,15 @@ lang_process ()
if (command_line.gc_sections)
lang_gc_sections ();
/* Size up the common data */
/* Size up the common data. */
lang_common ();
/* Run through the contours of the script and attach input sections
to the correct output sections
*/
to the correct output sections. */
map_input_to_output_sections (statement_list.head, (char *) NULL,
(lang_output_section_statement_type *) NULL);
/* Find any sections not attached explicitly and handle them */
/* Find any sections not attached explicitly and handle them. */
lang_place_orphans ();
ldemul_before_allocation ();
@ -4063,7 +4063,7 @@ lang_process ()
section positions, since they will affect SIZEOF_HEADERS. */
lang_record_phdrs ();
/* Now run around and relax if we can */
/* Now run around and relax if we can. */
if (command_line.relax)
{
/* First time round is a trial run to get the 'worst case'
@ -4113,7 +4113,7 @@ lang_process ()
lang_set_startof ();
/* Do all the assignments, now that we know the final resting places
of all the symbols */
of all the symbols. */
lang_do_assignments (statement_list.head,
abs_output_section,
@ -4124,7 +4124,7 @@ lang_process ()
&& command_line.check_section_addresses)
lang_check_section_addresses ();
/* Final stuffs */
/* Final stuffs. */
ldemul_finish ();
lang_finish ();
@ -4323,8 +4323,8 @@ lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec)
if (strcmp (lma_memspec, "*default*") != 0)
{
current_section->lma_region = lang_memory_region_lookup (lma_memspec);
/* if no runtime region has been given, but the load region has been,
use the load region */
/* If no runtime region has been given, but the load region has
been, use the load region. */
if (strcmp (memspec, "*default*") == 0)
current_section->region = lang_memory_region_lookup (lma_memspec);
}
@ -4332,12 +4332,11 @@ lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec)
stat_ptr = &statement_list;
}
/*
Create an absolute symbol with the given name with the value of the
/* Create an absolute symbol with the given name with the value of the
address of first byte of the section named.
If the symbol already exists, then do nothing.
*/
If the symbol already exists, then do nothing. */
void
lang_abs_symbol_at_beginning_of (secname, name)
const char *secname;
@ -4366,12 +4365,11 @@ lang_abs_symbol_at_beginning_of (secname, name)
}
}
/*
Create an absolute symbol with the given name with the value of the
/* Create an absolute symbol with the given name with the value of the
address of the first byte after the end of the section named.
If the symbol already exists, then do nothing.
*/
If the symbol already exists, then do nothing. */
void
lang_abs_symbol_at_end_of (secname, name)
const char *secname;