diff options
author | David MacKenzie <djm@cygnus> | 1993-06-17 20:55:43 +0000 |
---|---|---|
committer | David MacKenzie <djm@cygnus> | 1993-06-17 20:55:43 +0000 |
commit | 8ddef5528d34f05ff9a492e23b15ef5c6c8eb5fb (patch) | |
tree | f921e9cedac5cd479f9954d6b30598061db2e93d /ld/mri.c | |
parent | 21cc14d8505ad50143ea248c0de12bfa9eecf1e7 (diff) | |
download | gdb-8ddef5528d34f05ff9a492e23b15ef5c6c8eb5fb.zip gdb-8ddef5528d34f05ff9a492e23b15ef5c6c8eb5fb.tar.gz gdb-8ddef5528d34f05ff9a492e23b15ef5c6c8eb5fb.tar.bz2 |
* ldfile.c (ldfile_open_command): Don't try .ld extension.
It wasn't documented (or likely used) and wastes time.
(try_open): If EXTEN is empty, don't try it.
* ldctor.c, lderror.c, ldexp.c, ldfile.c, ldindr.c, ldlang.c,
ldlex.l, ldmain.c, ldmisc.c, ldsym.c, ldver.c, ldwarn.c,
ldwrite.c, lexsup.c, mri.c, relax.c: Replace DEFUN macro calls
with normal function declarations.
* Move *.em to emultempl/*.em. Move *.sh to emulparams/*.sh.
Move *.sc-sh to scripttempl/*.sc.
* {emultempl,emulparams,scripttempl}/README: New files.
* sh.em, st2000.em, z8ksim.em, h8300hms.em, h8500hms.em: Files
removed, replaced with generic.em.
* h8300.sh, h8500.sh, h8300.sc, h8500.sc: Renamed from
h8[35]00hms.s[ch]. Change their contents to omit the "hms".
* *.em (*_get_script): Return script name instead of script contents.
* ldlang.c (lang_process): Change caller.
* ldlex.l, ldgram.y: Recognize -m option.
Check for input files after *all* options in grammar.
* ldmain.c (main): Check for -m options. Add default directory
for -m.
* mkscript.c: File removed.
* genscripts.sh: Take two more parameters, tooldirlib and libdir,
to add to the default LIB_PATH.
Look for input files in the new subdirectories.
Create the scripts in emulations subdirectory and don't filter
them through mkscript.
* configure.in: Make the emulations subdirectory.
* Makefile.in: Account for all of the above changes.
Remove unused .SUFFIXES. Get libgcc.a path with gcc
-print-libgcc-file-name instead of $(libdir)/libgcc.a.
Put CFLAGS last in the compilation rules.
Add -I../bfd to INCLUDES so sysdep.h is found.
* ldfile.c (try_open): If opening without the extension fails,
try with the extension even if -v or -V was given.
had_script is imported (from ldgram.y), not exported.
Diffstat (limited to 'ld/mri.c')
-rw-r--r-- | ld/mri.c | 310 |
1 files changed, 284 insertions, 26 deletions
@@ -27,63 +27,284 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "sysdep.h" +#include "ld.h" #include "ldlang.h" #include "mri.h" +#include "ldgram.h" #include "ldexp.h" -void -DEFUN(mri_output_section, (name, vma), - CONST char *name AND - etree_type *vma) -{ - lang_output_section_statement_type *os; +struct section_name_struct { + struct section_name_struct *next; + CONST char *name; + CONST char *alias; + etree_type *vma; + etree_type *align; + etree_type *subalign; + int ok_to_load; +} ; + +int symbol_truncate = 10000; +struct section_name_struct *order; +struct section_name_struct *only_load; +struct section_name_struct *address; +struct section_name_struct *alias; - os = lang_output_section_statement_lookup(name); +struct section_name_struct *alignment; +struct section_name_struct *subalignment; - if (os->addr_tree == (etree_type *)NULL) { - os->addr_tree = vma; +extern char *strdup(); + +static struct section_name_struct ** +lookup (name, list) + CONST char *name; + struct section_name_struct **list; +{ + + struct section_name_struct **ptr = list; + while (*ptr) + { + if (strcmp(name, (*ptr)->name) == 0) { + /* If this is a match, delete it, we only keep the last instance + of any name */ + *ptr = (*ptr)->next; + } + else { + ptr = &((*ptr)->next); + } } - os->flags = 0; - os->block_value = 0; + *ptr = (struct section_name_struct *)ldmalloc(sizeof(struct section_name_struct)); + return ptr; +} + +static void +mri_add_to_list (list, name, vma, alias, align, subalign) + struct section_name_struct **list; + CONST char *name; + etree_type *vma; + CONST char *alias; + etree_type *align; + etree_type *subalign; +{ + struct section_name_struct **ptr = lookup(name,list); + (*ptr)->name = name; + (*ptr)->vma = vma; + (*ptr)->next = (struct section_name_struct *)NULL; + (*ptr)->ok_to_load = 0; + (*ptr)->alias = alias; +(*ptr)->align = align; +(*ptr)->subalign = subalign; +} + + +void +mri_output_section (name, vma) + CONST char *name; + etree_type *vma; +{ + mri_add_to_list(&address, name, vma, 0,0,0); } /* if any ABSOLUTE <name> are in the script, only load those files marked thus */ -void DEFUN(mri_only_load,(name), CONST char *name) +void +mri_only_load (name) + CONST char *name; { - lang_output_section_statement_type *os; + mri_add_to_list(&only_load, name, 0, 0,0,0); +} - os = lang_output_section_statement_lookup(name); - os->flags = 0; - os->block_value = 0; +etree_type *base; +void +mri_base (exp) + etree_type *exp; +{ + base = exp; } +static int done_tree = 0; +static void +mri_draw_tree () +{ + if (done_tree) return; + + /* Create the regions */ + { + lang_memory_region_type *r; + r = lang_memory_region_lookup("long"); + r->current = r->origin = exp_get_vma(base, (bfd_vma)0, "origin", + lang_first_phase_enum); + r->length = (bfd_size_type) exp_get_vma(0, (bfd_vma) ~((bfd_size_type)0), + "length", lang_first_phase_enum); + } + + + /* Now build the statements for the ldlang machine */ + + + /* Attatch the addresses of any which have addresses, and add the + ones not mentioned */ + if (address != (struct section_name_struct *)NULL) { + struct section_name_struct *alist; + struct section_name_struct *olist; + if (order == (struct section_name_struct *)NULL) { + order = address; + } + + for (alist = address; + alist != (struct section_name_struct*)NULL; + alist = alist->next) + { + int done = 0; + for (olist = order; + done == 0 && + olist != (struct section_name_struct *)NULL; + olist = olist->next) + { + if (strcmp(alist->name, olist->name) == 0) + { + olist->vma = alist->vma; + done = 1; + } + } + if (!done) { + /* add this onto end of order list */ + mri_add_to_list(&order, alist->name, alist->vma, 0,0,0); + } + + } + + } + + /* If we're only supposed to load a subset of them in, then prune + the list. */ + + if (only_load != (struct section_name_struct *)NULL) + { + struct section_name_struct *ptr1; + struct section_name_struct *ptr2; + if (order == (struct section_name_struct*)NULL) + order = only_load; + + /* See if this name is in the list, if it is then we can load it + */ + for (ptr1 = only_load; ptr1; ptr1 = ptr1->next) + { + for (ptr2= order; ptr2; ptr2=ptr2->next) + { + if (strcmp(ptr2->name, ptr1->name)==0) { + ptr2->ok_to_load = 1; + } + } + } + } + else + { + /* No only load list, so everything is ok to load */ + struct section_name_struct *ptr; + for (ptr = order; ptr; ptr=ptr->next) { + ptr->ok_to_load = 1; + } + } + + + /* Create the order of sections to load */ + if (order != (struct section_name_struct *)NULL) + { + /* Been told to output the sections in a certain order */ + struct section_name_struct *p = order; + while (p) + { + struct section_name_struct *aptr; + etree_type *align = 0; + etree_type *subalign = 0; + /* See if an alignment has been specified */ + + for (aptr = alignment; aptr; aptr= aptr->next) + { + if (strcmp(aptr->name, p->name)==0) { + align = aptr->align; + } + } + + for (aptr = subalignment; aptr; aptr= aptr->next) + { + if (strcmp(aptr->name, p->name)==0) { + subalign = aptr->subalign; + } + } + + if (base == 0) { + base = p->vma ? p->vma :exp_nameop(NAME, "."); + } + lang_enter_output_section_statement(p->name, base, + p->ok_to_load ? 0 : + SEC_NEVER_LOAD, 1, + align, subalign); + base = 0; + lang_add_wild(p->name, (char *)NULL); + /* If there is an alias for this section, add it too */ + for (aptr = alias; aptr; aptr = aptr->next) { + + if (strcmp(aptr->alias, p->name)== 0) { + lang_add_wild(aptr->name, (char *)NULL); + } + } + + lang_leave_output_section_statement(0, "long"); + p = p->next; + } + } + + + done_tree = 1; + +} void -DEFUN(mri_load,(name), - CONST char *name) +mri_load (name) + CONST char *name; { + mri_draw_tree(); - lang_add_input_file(name, lang_input_file_is_file_enum, (char *)NULL); + base = 0; + lang_add_input_file(name, + lang_input_file_is_file_enum, (char *)NULL); + /* lang_leave_output_section_statement(0,"*default*");*/ } void -DEFUN(mri_order,(name), - CONST char *name) +mri_order (name) + CONST char *name; { -einfo("Ignoring ORDER %s for the moment\n", name); + mri_add_to_list(&order, name, 0, 0,0,0); +} + +void +mri_alias (want, is, isn) + CONST char *want; + CONST char *is; + int isn; +{ + if (!is) { + /* Some sections are digits - */ + char buf[20]; + sprintf(buf, "%d", isn); + is =strdup(buf); + } + mri_add_to_list(&alias, is, 0, want,0,0); } + void -DEFUN(mri_name,(name), - CONST char *name) +mri_name (name) + CONST char *name; { lang_add_output(name); @@ -91,8 +312,8 @@ DEFUN(mri_name,(name), void -DEFUN(mri_format,(name), - CONST char *name) +mri_format (name) + CONST char *name; { if (strcmp(name, "S") == 0) { @@ -102,7 +323,44 @@ DEFUN(mri_format,(name), { lang_add_output_format("ieee"); } + else if (strcmp(name, "COFF") == 0) + { + lang_add_output_format("coff-m68k"); + } else { einfo("%P%F: unknown format type %s\n", name); } } + + +void +mri_public (name, exp) + CONST char *name; + etree_type *exp; +{ + lang_add_assignment(exp_assop('=', name, exp)); +} + +void +mri_align (name, exp) + CONST char *name; + etree_type *exp; +{ + mri_add_to_list(&alignment, name,0,0,exp,0); +} + +void +mri_alignmod (name, exp) + CONST char *name; + etree_type *exp; +{ + mri_add_to_list(&subalignment, name,0,0,0,exp); +} + + +void +mri_truncate (exp) + int exp; +{ + symbol_truncate = exp; +} |