1993-01-12 00:47:20 +00:00
|
|
|
/* Copyright (C) 1992, 1993 Free Software Foundation, Inc.
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-01-12 00:47:20 +00:00
|
|
|
This file is part of GLD, the Gnu Linker.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
/*
|
|
|
|
|
1992-01-24 22:34:34 +00:00
|
|
|
new age linking
|
|
|
|
|
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
Tie together all the interseting blocks
|
1992-01-24 22:34:34 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "../bfd/seclet.h"
|
|
|
|
#include "coff/internal.h"
|
|
|
|
#include "sysdep.h"
|
|
|
|
|
|
|
|
#include "ldlang.h"
|
|
|
|
#include "ld.h"
|
|
|
|
#include "ldwrite.h"
|
|
|
|
#include "ldmisc.h"
|
|
|
|
#include "ldsym.h"
|
|
|
|
#include "ldgram.h"
|
1992-03-07 18:31:24 +00:00
|
|
|
#include "relax.h"
|
1992-01-24 22:34:34 +00:00
|
|
|
static void
|
* 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.
1993-06-17 20:55:43 +00:00
|
|
|
build_it (statement)
|
|
|
|
lang_statement_union_type * statement;
|
1992-01-24 22:34:34 +00:00
|
|
|
{
|
1993-03-30 17:49:00 +00:00
|
|
|
switch (statement->header.type)
|
|
|
|
{
|
1992-01-24 22:34:34 +00:00
|
|
|
#if 0
|
1993-03-30 17:49:00 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
bfd_byte play_area[SHORT_SIZE];
|
|
|
|
unsigned int i;
|
|
|
|
bfd_putshort (output_bfd, statement->fill_statement.fill, play_area);
|
|
|
|
/* Write out all entire shorts */
|
|
|
|
for (i = 0;
|
|
|
|
i < statement->fill_statement.size - SHORT_SIZE + 1;
|
|
|
|
i += SHORT_SIZE)
|
|
|
|
{
|
|
|
|
bfd_set_section_contents (output_bfd,
|
|
|
|
statement->fill_statement.output_section,
|
|
|
|
play_area,
|
|
|
|
statement->data_statement.output_offset + i,
|
|
|
|
SHORT_SIZE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now write any remaining byte */
|
|
|
|
if (i < statement->fill_statement.size)
|
|
|
|
{
|
|
|
|
bfd_set_section_contents (output_bfd,
|
|
|
|
statement->fill_statement.output_section,
|
|
|
|
play_area,
|
|
|
|
statement->data_statement.output_offset + i,
|
|
|
|
1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
break;
|
1992-08-27 00:32:05 +00:00
|
|
|
#endif
|
1993-03-30 17:49:00 +00:00
|
|
|
case lang_data_statement_enum:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bfd_vma value = statement->data_statement.value;
|
|
|
|
bfd_byte play_area[LONG_SIZE];
|
|
|
|
unsigned int size = 0;
|
|
|
|
asection *output_section = statement->data_statement.output_section;
|
|
|
|
switch (statement->data_statement.type)
|
|
|
|
{
|
|
|
|
case LONG:
|
|
|
|
bfd_put_32 (output_section->owner, value, play_area);
|
|
|
|
size = LONG_SIZE;
|
|
|
|
break;
|
|
|
|
case SHORT:
|
|
|
|
bfd_put_16 (output_section->owner, value, play_area);
|
|
|
|
size = SHORT_SIZE;
|
|
|
|
break;
|
|
|
|
case BYTE:
|
|
|
|
bfd_put_8 (output_section->owner, value, play_area);
|
|
|
|
size = BYTE_SIZE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bfd_set_section_contents (output_section->owner,
|
|
|
|
statement->data_statement.output_section,
|
|
|
|
play_area,
|
|
|
|
statement->data_statement.output_vma,
|
|
|
|
size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case lang_input_section_enum:
|
|
|
|
{
|
|
|
|
/* Create a new seclet in the output section with this
|
1992-11-05 19:35:38 +00:00
|
|
|
attached */
|
1993-03-30 17:49:00 +00:00
|
|
|
if (statement->input_section.ifile->just_syms_flag == false)
|
|
|
|
{
|
|
|
|
asection *i = statement->input_section.section;
|
|
|
|
|
|
|
|
asection *output_section = i->output_section;
|
|
|
|
|
|
|
|
bfd_seclet_type *seclet = bfd_new_seclet (output_section->owner, output_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 */
|
|
|
|
seclet->type = bfd_fill_seclet;
|
|
|
|
seclet->u.fill.value = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seclet->type = bfd_indirect_seclet;
|
|
|
|
seclet->u.indirect.section = i;
|
|
|
|
seclet->u.indirect.symbols
|
|
|
|
= statement->input_section.ifile->asymbols;
|
|
|
|
}
|
|
|
|
seclet->size = i->_cooked_size;
|
|
|
|
seclet->offset = i->output_offset;
|
|
|
|
seclet->next = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case lang_padding_statement_enum:
|
|
|
|
/* Make a new seclet with the right filler */
|
|
|
|
{
|
|
|
|
/* Create a new seclet in the output section with this
|
1992-11-05 19:35:38 +00:00
|
|
|
attached */
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
bfd_seclet_type *seclet =
|
|
|
|
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;
|
|
|
|
seclet->offset = statement->padding_statement.output_offset;
|
|
|
|
seclet->u.fill.value = statement->padding_statement.fill;
|
|
|
|
seclet->next = 0;
|
|
|
|
}
|
|
|
|
break;
|
1992-04-17 15:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* All the other ones fall through */
|
|
|
|
;
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
}
|
1992-01-24 22:34:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
void
|
* 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.
1993-06-17 20:55:43 +00:00
|
|
|
write_relax (output_bfd, data, relocateable)
|
|
|
|
bfd * output_bfd;
|
|
|
|
PTR data;
|
|
|
|
boolean relocateable;
|
1992-01-24 22:34:34 +00:00
|
|
|
{
|
1993-03-30 17:49:00 +00:00
|
|
|
/* Tie up all the statements to generate an output bfd structure which
|
1993-10-25 20:10:35 +00:00
|
|
|
bfd can mull over */
|
1993-03-30 17:49:00 +00:00
|
|
|
lang_for_each_statement (build_it);
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-10-25 20:10:35 +00:00
|
|
|
if (bfd_seclet_link (output_bfd, data, relocateable) == false)
|
|
|
|
einfo ("%F%P: %B: %E\n", output_bfd);
|
1992-01-24 22:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* See if we can change the size of this section by shrinking the
|
|
|
|
relocations in it. If this happens, then we'll have to renumber the
|
|
|
|
symbols in it, and shift around the data too.
|
|
|
|
*/
|
|
|
|
boolean
|
* 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.
1993-06-17 20:55:43 +00:00
|
|
|
relax_section (this_ptr)
|
|
|
|
lang_statement_union_type ** this_ptr;
|
1992-01-24 22:34:34 +00:00
|
|
|
{
|
1993-02-12 16:12:28 +00:00
|
|
|
extern lang_input_statement_type *script_file;
|
1992-01-24 22:34:34 +00:00
|
|
|
lang_input_section_type *is = &((*this_ptr)->input_section);
|
|
|
|
asection *i = is->section;
|
1993-03-30 17:49:00 +00:00
|
|
|
if (!(i->owner->flags & BFD_IS_RELAXABLE))
|
|
|
|
{
|
|
|
|
if (i->owner != script_file->the_bfd)
|
|
|
|
einfo ("%B: not assembled with -linkrelax\n", i->owner);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bfd_relax_section (i->owner, i, is->ifile->asymbols);
|
1992-01-24 22:34:34 +00:00
|
|
|
|
1993-03-30 17:49:00 +00:00
|
|
|
}
|