2005-10-25 19:40:19 +02:00
|
|
|
# This shell script emits C code -*- C -*-
|
|
|
|
# to keep track of the machine type of Z80 object files
|
|
|
|
# It does some substitutions.
|
2016-01-01 12:25:12 +01:00
|
|
|
# Copyright (C) 2005-2016 Free Software Foundation, Inc.
|
2007-07-06 16:09:45 +02:00
|
|
|
# This file is part of the GNU Binutils.
|
|
|
|
#
|
|
|
|
# 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
2005-10-25 19:40:19 +02:00
|
|
|
|
|
|
|
LDEMUL_BEFORE_PARSE=gldz80_before_parse
|
|
|
|
LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
|
|
|
|
LDEMUL_AFTER_OPEN=gldz80_after_open
|
|
|
|
|
2007-07-19 21:56:10 +02:00
|
|
|
fragment <<EOF
|
2005-10-25 19:40:19 +02:00
|
|
|
/* --- \begin{z80.em} */
|
|
|
|
/* Codes for machine types, bitwise or gives the code to use for the
|
|
|
|
output. */
|
|
|
|
#define M_Z80STRICT 1
|
|
|
|
#define M_Z80 3
|
|
|
|
#define M_Z80FULL 7
|
|
|
|
#define M_R800 11
|
|
|
|
#define M_Z80ANY 15
|
|
|
|
|
|
|
|
/* Bitwise or of the machine types seen so far. */
|
|
|
|
static int result_mach_type;
|
|
|
|
|
2007-07-19 21:56:10 +02:00
|
|
|
static void
|
2005-10-25 19:40:19 +02:00
|
|
|
${LDEMUL_BEFORE_PARSE} (void)
|
|
|
|
{
|
|
|
|
#ifndef TARGET_ /* I.e., if not generic. */
|
|
|
|
ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
|
|
|
|
#endif /* not TARGET_ */
|
|
|
|
result_mach_type = M_Z80STRICT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Update result_mach_type. */
|
|
|
|
static bfd_boolean
|
|
|
|
${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
|
|
|
|
{
|
|
|
|
unsigned long mach_type;
|
|
|
|
|
|
|
|
mach_type = bfd_get_mach (entry->the_bfd);
|
2007-07-19 21:56:10 +02:00
|
|
|
switch (mach_type)
|
2005-10-25 19:40:19 +02:00
|
|
|
{
|
2007-07-19 21:56:10 +02:00
|
|
|
case bfd_mach_z80strict:
|
|
|
|
result_mach_type |= M_Z80STRICT;
|
2005-10-25 19:40:19 +02:00
|
|
|
break;
|
|
|
|
case bfd_mach_z80:
|
2007-07-19 21:56:10 +02:00
|
|
|
result_mach_type |= M_Z80;
|
2005-10-25 19:40:19 +02:00
|
|
|
break;
|
|
|
|
case bfd_mach_z80full:
|
2007-07-19 21:56:10 +02:00
|
|
|
result_mach_type |= M_Z80FULL;
|
2005-10-25 19:40:19 +02:00
|
|
|
break;
|
|
|
|
case bfd_mach_r800:
|
2007-07-19 21:56:10 +02:00
|
|
|
result_mach_type |= M_R800;
|
2005-10-25 19:40:19 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result_mach_type |= M_Z80ANY;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the machine type of the output file based on result_mach_type. */
|
|
|
|
static void
|
|
|
|
gldz80_after_open (void)
|
|
|
|
{
|
|
|
|
unsigned long mach_type;
|
|
|
|
|
* ld.texinfo (Expression Section): Describe treatment of numbers
and absolute symbols.
* ldemul.c (after_open_default): Look up __ld_compatibility.
* ldexp.c (fold_name): Convert absolute symbols to numbers when
inside output section definitions, or when __ld_compatibility >= 221.
(exp_fold_tree_1): Convert numbers to absolute when not in output
section definition and __ld_compatibility < 221. Don't always
convert values outside an output section definition to absolute.
* ldexp.h (uses_defined): Comment.
* ldlang.c (ld_compatibility): New variable.
* ldlang.h (ld_compatibility): Declare.
* emultempl/aix.em, * emultempl/armcoff.em, * emultempl/beos.em,
* emultempl/elf32.em, * emultempl/genelf.em, * emultempl/lnk960.em,
* emultempl/m68kcoff.em, * emultempl/mmo.em, * emultempl/pe.em,
* emultempl/pep.em, * emultempl/sunos.em, * emultempl/z80.em: Call
after_open_default from after_open function.
2010-12-20 14:00:14 +01:00
|
|
|
after_open_default ();
|
|
|
|
|
2005-10-25 19:40:19 +02:00
|
|
|
switch (result_mach_type)
|
|
|
|
{
|
|
|
|
case M_Z80STRICT:
|
|
|
|
mach_type = bfd_mach_z80strict;
|
|
|
|
break;
|
|
|
|
case M_Z80:
|
|
|
|
mach_type = bfd_mach_z80;
|
|
|
|
break;
|
|
|
|
case M_Z80FULL:
|
|
|
|
mach_type = bfd_mach_z80full;
|
|
|
|
break;
|
|
|
|
case M_R800:
|
|
|
|
mach_type = bfd_mach_r800;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mach_type = 0;
|
|
|
|
}
|
2008-02-15 04:35:53 +01:00
|
|
|
bfd_set_arch_mach (link_info.output_bfd, bfd_arch_z80, mach_type);
|
2005-10-25 19:40:19 +02:00
|
|
|
}
|
|
|
|
/* --- \end{z80.em} */
|
|
|
|
EOF
|