static int longest_section_name = 8;
static lang_statement_list_type statement_list;
+static void print_size PARAMS ((size_t value));
+static void print_alignment PARAMS ((unsigned int value));
+static void print_fill PARAMS ((fill_type value));
+static void print_section PARAMS ((const char *name));
+static void lang_for_each_statement_worker
+ PARAMS ((void (*func) (lang_statement_union_type *),
+ lang_statement_union_type *s));
+static lang_input_statement_type *new_afile
+ PARAMS ((const char *name, lang_input_file_enum_type file_type,
+ const char *target));
+static void print_flags PARAMS ((int *ignore_flags));
+static void init_os PARAMS ((lang_output_section_statement_type *s));
+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,
+ lang_output_section_statement_type *output));
+static lang_input_statement_type *lookup_name PARAMS ((const char *name));
+static void wild PARAMS ((lang_wild_statement_type *s,
+ const char *section, const char *file,
+ const char *target,
+ lang_output_section_statement_type *output));
+static bfd *open_output PARAMS ((const char *name));
+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 lang_init_script_file PARAMS ((void));
+static void map_input_to_output_sections
+ PARAMS ((lang_statement_union_type *s,
+ const char *target,
+ lang_output_section_statement_type *output_section_statement));
+static void print_output_section_statement
+ PARAMS ((lang_output_section_statement_type *output_section_statement));
+static void print_assignment
+ PARAMS ((lang_assignment_statement_type *assignment,
+ lang_output_section_statement_type *output_section));
+static void print_input_statement PARAMS ((lang_input_statement_type *statm));
+static void print_symbol PARAMS ((asymbol *q));
+static void print_input_section PARAMS ((lang_input_section_type *in));
+static void print_fill_statement PARAMS ((lang_fill_statement_type *fill));
+static void print_data_statement PARAMS ((lang_data_statement_type *data));
+static void print_padding_statement PARAMS ((lang_padding_statement_type *s));
+static void print_wild_statement
+ PARAMS ((lang_wild_statement_type *w,
+ lang_output_section_statement_type *os));
+static void print_statement PARAMS ((lang_statement_union_type *s,
+ lang_output_section_statement_type *os));
+static void print_statements PARAMS ((void));
+static bfd_vma insert_pad PARAMS ((lang_statement_union_type **this_ptr,
+ fill_type fill, unsigned int power,
+ asection *output_section_statement,
+ bfd_vma dot));
+static bfd_vma size_input_section
+ PARAMS ((lang_statement_union_type **this_ptr,
+ lang_output_section_statement_type *output_section_statement,
+ unsigned short fill, bfd_vma dot, boolean relax));
+static bfd_vma lang_size_sections
+ PARAMS ((lang_statement_union_type *s,
+ lang_output_section_statement_type *output_section_statement,
+ lang_statement_union_type **prev, unsigned short fill,
+ bfd_vma dot, boolean relax));
+static bfd_vma lang_do_assignments
+ PARAMS ((lang_statement_union_type * s,
+ lang_output_section_statement_type *output_section_statement,
+ unsigned short fill,
+ bfd_vma dot));
+static void lang_relocate_globals PARAMS ((void));
+static void lang_finish PARAMS ((void));
+static void lang_check PARAMS ((void));
+static void lang_common PARAMS ((void));
+static void lang_place_orphans PARAMS ((void));
+static int topower PARAMS ((int));
+static void reset_memory_regions PARAMS ((void));
+
/* EXPORTS */
boolean relaxing;
lang_output_section_statement_type *abs_output_section;
#define outside_symbol_address(q) ((q)->value + outside_section_address(q->section))
-void lang_add_data PARAMS ((int type, union etree_union * exp));
-
PTR
stat_alloc (size)
size_t size;
{
return obstack_alloc (&stat_obstack, size);
}
+
static void
print_size (value)
size_t value;
{
fprintf (config.map_file, "%5x", (unsigned) value);
}
+
static void
print_alignment (value)
unsigned int value;
{
fprintf (config.map_file, "2**%1u", value);
}
+
static void
-DEFUN (print_fill, (value),
- fill_type value)
+print_fill (value)
+ fill_type value;
{
fprintf (config.map_file, "%04x", (unsigned) value);
}
-
static void
print_section (name)
- CONST char *CONST name;
+ CONST char *name;
{
fprintf (config.map_file, "%*s", -longest_section_name, name);
}
static void
lang_for_each_statement_worker (func, s)
- void (*func) ();
+ void (*func) (lang_statement_union_type *);
lang_statement_union_type *s;
{
for (; s != (lang_statement_union_type *) NULL; s = s->next)
void
lang_for_each_statement (func)
- void (*func) ();
+ void (*func) (lang_statement_union_type *);
{
lang_for_each_statement_worker (func,
statement_list.head);
*/
static lang_input_statement_type *
new_afile (name, file_type, target)
- CONST char *CONST name;
- CONST lang_input_file_enum_type file_type;
- CONST char *CONST target;
+ CONST char *name;
+ lang_input_file_enum_type file_type;
+ CONST char *target;
{
lang_input_statement_type *p = new_stat (lang_input_statement,
if ((section->flags & SEC_SHARED_LIBRARY) != 0)
section->output_section->flags |= section->flags;
else
- section->output_section->flags |= section->flags & ~SEC_NEVER_LOAD;
+ section->output_section->flags |=
+ section->flags & (flagword) (~ SEC_NEVER_LOAD);
if (!output->loadable)
{
static
lang_input_statement_type *
lookup_name (name)
- CONST char *CONST name;
+ CONST char *name;
{
lang_input_statement_type *search;
static void
wild (s, section, file, target, output)
lang_wild_statement_type * s;
- CONST char *CONST section;
- CONST char *CONST file;
- CONST char *CONST target;
+ CONST char *section;
+ CONST char *file;
+ CONST char *target;
lang_output_section_statement_type * output;
{
lang_input_statement_type *f;
static bfd *
open_output (name)
- CONST char *CONST name;
+ CONST char *name;
{
bfd *output;
static void
lang_reasonable_defaults ()
{
-
-
-
#if 0
lang_output_section_statement_lookup (".text");
lang_output_section_statement_lookup (".data");
}
}
-
-
-
-
static void
print_output_section_statement (output_section_statement)
lang_output_section_statement_type * output_section_statement;
}
static bfd_vma
-DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot),
- lang_statement_union_type ** this_ptr AND
- fill_type fill AND
- unsigned int power AND
- asection * output_section_statement AND
- bfd_vma dot)
+insert_pad (this_ptr, fill, power, output_section_statement, dot)
+ lang_statement_union_type ** this_ptr;
+ fill_type fill;
+ unsigned int power;
+ asection * output_section_statement;
+ bfd_vma dot;
{
/* Align this section first to the
input sections requirement, then
/* Work out how much this section will move the dot point */
static bfd_vma
-DEFUN (size_input_section, (this_ptr, output_section_statement, fill, dot, relax),
- lang_statement_union_type ** this_ptr AND
- lang_output_section_statement_type * output_section_statement AND
- unsigned short fill AND
- bfd_vma dot AND
- boolean relax)
+size_input_section (this_ptr, output_section_statement, fill, dot, relax)
+ lang_statement_union_type ** this_ptr;
+ lang_output_section_statement_type * output_section_statement;
+ unsigned short fill;
+ bfd_vma dot;
+ boolean relax;
{
lang_input_section_type *is = &((*this_ptr)->input_section);
asection *i = is->section;
static boolean had_relax;
static bfd_vma
-DEFUN (lang_size_sections, (s, output_section_statement, prev, fill, dot, relax),
- lang_statement_union_type * s AND
- lang_output_section_statement_type * output_section_statement AND
- lang_statement_union_type ** prev AND
- unsigned short fill AND
- bfd_vma dot AND
- boolean relax)
+lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
+ lang_statement_union_type * s;
+ lang_output_section_statement_type * output_section_statement;
+ lang_statement_union_type ** prev;
+ unsigned short fill;
+ bfd_vma dot;
+ boolean relax;
{
/* Size up the sections from their constituent parts */
for (; s != (lang_statement_union_type *) NULL; s = s->next)
}
static bfd_vma
-DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot),
- lang_statement_union_type * s AND
- lang_output_section_statement_type * output_section_statement AND
- unsigned short fill AND
- bfd_vma dot)
+lang_do_assignments (s, output_section_statement, fill, dot)
+ lang_statement_union_type * s;
+ lang_output_section_statement_type * output_section_statement;
+ unsigned short fill;
+ bfd_vma dot;
{
-
for (; s != (lang_statement_union_type *) NULL; s = s->next)
{
switch (s->header.type)
}
}
+#if 0
+
+/* Not used. */
void
lang_for_each_input_section (func)
}
}
-
+#endif
void
ldlang_add_file (entry)
static lang_output_section_statement_type *current_section;
static int topower(x)
- int x;
+ int x;
{
unsigned int i = 1;
int l;
void
lang_enter_output_section_statement (output_section_statement_name,
address_exp, flags, block_value,
- align, subalign, base)
+ align, subalign, ebase)
const char *output_section_statement_name;
etree_type * address_exp;
int flags;
bfd_vma block_value;
etree_type *align;
etree_type *subalign;
- etree_type *base;
+ etree_type *ebase;
{
lang_output_section_statement_type *os;
exp_get_value_int(align, -1,
"section alignment", 0));
- os->load_base = base;
+ os->load_base = ebase;
}
asymbol *
-DEFUN (create_symbol, (name, flags, section),
- CONST char *name AND
- flagword flags AND
- asection * section)
+create_symbol (name, flags, section)
+ CONST char *name;
+ flagword flags;
+ asection * section;
{
asymbol **def_ptr = (asymbol **) stat_alloc ((bfd_size_type) (sizeof (asymbol **)));
args_type command_line;
ld_config_type config;
+
+static boolean check_for_scripts_dir PARAMS ((char *dir));
+static void read_entry_symbols
+ PARAMS ((bfd *desc, struct lang_input_statement_struct *entry));
+static void enter_file_symbols PARAMS ((lang_input_statement_type *entry));
+static void search_library PARAMS ((struct lang_input_statement_struct *));
+static lang_input_statement_type *decode_library_subfile
+ PARAMS ((struct lang_input_statement_struct *library_entry,
+ bfd *subfile_offset));
+static void linear_library PARAMS ((struct lang_input_statement_struct *));
+static void symdef_library PARAMS ((struct lang_input_statement_struct *));
+static void clear_syms PARAMS ((struct lang_input_statement_struct *entry,
+ file_ptr offset));
+static boolean subfile_wanted_p
+ PARAMS ((struct lang_input_statement_struct *));
\f
-void
+extern int main PARAMS ((int, char **));
+
+int
main (argc, argv)
- char **argv;
int argc;
+ char **argv;
{
char *emulation;
}
exit (0);
+ return 0;
}
/* We need to find any explicitly given emulation in order to initialize the
free (dir); /* Well, we tried. */
}
-void
+static void
read_entry_symbols (desc, entry)
bfd *desc;
struct lang_input_statement_struct *entry;
/* Searching libraries */
-struct lang_input_statement_struct *decode_library_subfile ();
-void linear_library (), symdef_library ();
-
/* Search the library ENTRY, already open on descriptor DESC.
This means deciding which library members to load,
making a chain of `struct lang_input_statement_struct' for those members,
and entering their global symbols in the hash table. */
-void
+static void
search_library (entry)
struct lang_input_statement_struct *entry;
{
SUBFILE_OFFSET is the byte index in the library of this member's header.
We store the length of the member into *LENGTH_LOC. */
-lang_input_statement_type *
+static lang_input_statement_type *
decode_library_subfile (library_entry, subfile_offset)
struct lang_input_statement_struct *library_entry;
bfd *subfile_offset;
return subentry;
}
-boolean subfile_wanted_p ();
-void
+static void
clear_syms (entry, offset)
struct lang_input_statement_struct *entry;
file_ptr offset;
{
carsym *car;
- unsigned long indx = bfd_get_next_mapent (entry->the_bfd,
- BFD_NO_MORE_SYMBOLS,
- &car);
+ symindex indx = bfd_get_next_mapent (entry->the_bfd,
+ BFD_NO_MORE_SYMBOLS,
+ &car);
while (indx != BFD_NO_MORE_SYMBOLS)
{
/* Search a library that has a map
*/
-void
+static void
symdef_library (entry)
struct lang_input_statement_struct *entry;
carsym *exported_library_name;
bfd *prev_archive_member_bfd = 0;
- int idx = bfd_get_next_mapent (entry->the_bfd,
- BFD_NO_MORE_SYMBOLS,
- &exported_library_name);
+ symindex idx = bfd_get_next_mapent (entry->the_bfd,
+ BFD_NO_MORE_SYMBOLS,
+ &exported_library_name);
not_finished = false;
while (idx != BFD_NO_MORE_SYMBOLS && undefined_global_sym_count)
{
-
if (exported_library_name->name)
{
-
ldsym_type *sp = ldsym_get_soft (exported_library_name->name);
/* If we find a symbol that appears to be needed, think carefully
- about the archive member that the symbol is in. */
+ about the archive member that the symbol is in. */
/* So - if it exists, and is referenced somewhere and is
- undefined or */
+ undefined or */
if (sp && sp->srefs_chain && !sp->sdefs_chain)
{
- bfd *archive_member_bfd = bfd_get_elt_at_index (entry->the_bfd, idx);
+ bfd *archive_member_bfd =
+ bfd_get_elt_at_index (entry->the_bfd, (int) idx);
struct lang_input_statement_struct *archive_member_lang_input_statement_struct;
#ifdef GNU960
- if (archive_member_bfd && gnu960_check_format (archive_member_bfd, bfd_object))
+ if (archive_member_bfd
+ && gnu960_check_format (archive_member_bfd, bfd_object))
#else
- if (archive_member_bfd && bfd_check_format (archive_member_bfd, bfd_object))
+ if (archive_member_bfd
+ && bfd_check_format (archive_member_bfd, bfd_object))
#endif
{
-
/* Don't think carefully about any archive member
- more than once in a given pass. */
+ more than once in a given pass. */
if (prev_archive_member_bfd != archive_member_bfd)
{
if (archive_member_bfd->usrdata != (PTR) NULL)
{
- archive_member_lang_input_statement_struct = (lang_input_statement_type *) archive_member_bfd->usrdata;
+ archive_member_lang_input_statement_struct =
+ ((lang_input_statement_type *)
+ archive_member_bfd->usrdata);
}
else
{
-
archive_member_lang_input_statement_struct =
- decode_library_subfile (entry, archive_member_bfd);
- archive_member_bfd->usrdata = (PTR) archive_member_lang_input_statement_struct;
-
+ decode_library_subfile (entry,
+ archive_member_bfd);
+ archive_member_bfd->usrdata =
+ (PTR) archive_member_lang_input_statement_struct;
}
if (archive_member_lang_input_statement_struct == 0)
if (archive_member_lang_input_statement_struct->loaded == false)
{
+ read_entry_symbols (archive_member_bfd,
+ archive_member_lang_input_statement_struct);
- read_entry_symbols (archive_member_bfd, archive_member_lang_input_statement_struct);
- /* Now scan the symbol table and decide whether to load. */
-
-
- if (subfile_wanted_p (archive_member_lang_input_statement_struct) == true)
+ /* Now scan the symbol table and decide
+ whether to load. */
+ if (subfile_wanted_p (archive_member_lang_input_statement_struct)
+ == true)
{
/* This member is needed; load it.
- Since we are loading something on this pass,
- we must make another pass through the symdef data. */
-
+ Since we are loading something on
+ this pass, we must make another
+ pass through the symdef data. */
not_finished = true;
enter_file_symbols (archive_member_lang_input_statement_struct);
prev = archive_member_lang_input_statement_struct;
- /* Clear out this member's symbols from the symdef data
- so that following passes won't waste time on them. */
- clear_syms (entry, exported_library_name->file_offset);
+ /* Clear out this member's symbols
+ from the symdef data so that
+ following passes won't waste time
+ on them. */
+ clear_syms (entry,
+ exported_library_name->file_offset);
archive_member_lang_input_statement_struct->loaded = true;
}
}
}
}
}
- idx = bfd_get_next_mapent (entry->the_bfd, idx, &exported_library_name);
+ idx = bfd_get_next_mapent (entry->the_bfd, idx,
+ &exported_library_name);
}
}
}
-void
+static void
linear_library (entry)
struct lang_input_statement_struct *entry;
{
linker ymbol table
Return nonzero if we ought to load this file */
-boolean
+static boolean
subfile_wanted_p (entry)
struct lang_input_statement_struct *entry;
{
#include "ldsym.h"
#include "ldgram.h"
#include "relax.h"
+
+static void build_it PARAMS ((lang_statement_union_type *));
+
static void
build_it (statement)
lang_statement_union_type * statement;
i += SHORT_SIZE)
{
bfd_set_section_contents (output_bfd,
- statement->fill_statement.output_section,
+ statement->fill_statement.output_section,
play_area,
- statement->data_statement.output_offset + i,
+ statement->data_statement.output_offset + i,
SHORT_SIZE);
}
if (i < statement->fill_statement.size)
{
bfd_set_section_contents (output_bfd,
- statement->fill_statement.output_section,
+ statement->fill_statement.output_section,
play_area,
- statement->data_statement.output_offset + i,
+ statement->data_statement.output_offset + i,
1);
}
break;
#endif
case lang_data_statement_enum:
-
{
-
bfd_vma value = statement->data_statement.value;
bfd_byte play_area[LONG_SIZE];
unsigned int size = 0;
bfd_set_section_contents (output_section->owner,
statement->data_statement.output_section,
play_area,
- statement->data_statement.output_vma,
+ ((file_ptr)
+ statement->data_statement.output_vma),
size);
-
-
-
}
break;
case lang_input_section_enum:
{
/* Create a new seclet in the output section with this
- attached */
+ attached */
if (statement->input_section.ifile->just_syms_flag == false)
{
asection *i = statement->input_section.section;
if (i->flags & SEC_NEVER_LOAD)
{
/* We've got a never load section inside one which is going
- to be output, we'll change it into a fill seclet */
+ to be output, we'll change it into a fill seclet */
seclet->type = bfd_fill_seclet;
seclet->u.fill.value = 0;
}
/* Make a new seclet with the right filler */
{
/* Create a new seclet in the output section with this
- attached */
+ attached */
bfd_seclet_type *seclet =
- bfd_new_seclet (statement->padding_statement.output_section->owner,
- statement->padding_statement.output_section);
+ bfd_new_seclet (statement->padding_statement.output_section->owner,
+ statement->padding_statement.output_section);
seclet->type = bfd_fill_seclet;
seclet->size = statement->padding_statement.size;
}
break;
-
-
- break;
default:
/* All the other ones fall through */
;
-
}
-
-
-
}
-
void
write_relax (output_bfd, data, relocateable)
bfd * output_bfd;