1*1424dfb3Schristos# This shell script emits a C file. -*- C -*- 2*1424dfb3Schristos# It does some substitutions. 3*1424dfb3Schristosfragment <<EOF 4*1424dfb3Schristos/* This file is is generated by a shell script. DO NOT EDIT! */ 5*1424dfb3Schristos 6*1424dfb3Schristos/* emulate the original gld for the given ${EMULATION_NAME} 7*1424dfb3Schristos Copyright (C) 1991-2020 Free Software Foundation, Inc. 8*1424dfb3Schristos Written by Steve Chamberlain steve@cygnus.com 9*1424dfb3Schristos 10*1424dfb3Schristos This file is part of the GNU Binutils. 11*1424dfb3Schristos 12*1424dfb3Schristos This program is free software; you can redistribute it and/or modify 13*1424dfb3Schristos it under the terms of the GNU General Public License as published by 14*1424dfb3Schristos the Free Software Foundation; either version 3 of the License, or 15*1424dfb3Schristos (at your option) any later version. 16*1424dfb3Schristos 17*1424dfb3Schristos This program is distributed in the hope that it will be useful, 18*1424dfb3Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 19*1424dfb3Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20*1424dfb3Schristos GNU General Public License for more details. 21*1424dfb3Schristos 22*1424dfb3Schristos You should have received a copy of the GNU General Public License 23*1424dfb3Schristos along with this program; if not, write to the Free Software 24*1424dfb3Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 25*1424dfb3Schristos MA 02110-1301, USA. */ 26*1424dfb3Schristos 27*1424dfb3Schristos#define TARGET_IS_${EMULATION_NAME} 28*1424dfb3Schristos 29*1424dfb3Schristos#include "sysdep.h" 30*1424dfb3Schristos#include "bfd.h" 31*1424dfb3Schristos#include "bfdlink.h" 32*1424dfb3Schristos#include "ctf-api.h" 33*1424dfb3Schristos 34*1424dfb3Schristos#include "ld.h" 35*1424dfb3Schristos#include "ldmain.h" 36*1424dfb3Schristos#include "ldmisc.h" 37*1424dfb3Schristos 38*1424dfb3Schristos#include "ldexp.h" 39*1424dfb3Schristos#include "ldlang.h" 40*1424dfb3Schristos#include "ldfile.h" 41*1424dfb3Schristos#include "ldemul.h" 42*1424dfb3Schristos 43*1424dfb3SchristosEOF 44*1424dfb3Schristos 45*1424dfb3Schristos# Import any needed special functions and/or overrides. 46*1424dfb3Schristos# 47*1424dfb3Schristosif test -n "$EXTRA_EM_FILE" ; then 48*1424dfb3Schristos source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em 49*1424dfb3Schristosfi 50*1424dfb3Schristos 51*1424dfb3Schristosif test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then 52*1424dfb3Schristosfragment <<EOF 53*1424dfb3Schristos 54*1424dfb3Schristosstatic void 55*1424dfb3Schristosgld${EMULATION_NAME}_before_parse (void) 56*1424dfb3Schristos{ 57*1424dfb3Schristos#ifndef TARGET_ /* I.e., if not generic. */ 58*1424dfb3Schristos ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); 59*1424dfb3Schristos#endif /* not TARGET_ */ 60*1424dfb3SchristosEOF 61*1424dfb3Schristos # The MSP430 port *needs* linker relaxtion in order to cope with large 62*1424dfb3Schristos # functions where conditional branches do not fit into a +/- 1024 byte range. 63*1424dfb3Schristos case ${target} in 64*1424dfb3Schristos msp430-*-* ) 65*1424dfb3Schristosfragment <<EOF 66*1424dfb3Schristos if (!bfd_link_relocatable (&link_info)) 67*1424dfb3Schristos TARGET_ENABLE_RELAXATION; 68*1424dfb3SchristosEOF 69*1424dfb3Schristos ;; 70*1424dfb3Schristos esac 71*1424dfb3Schristosfragment <<EOF 72*1424dfb3Schristos} 73*1424dfb3Schristos 74*1424dfb3SchristosEOF 75*1424dfb3Schristosfi 76*1424dfb3Schristos 77*1424dfb3Schristosif test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then 78*1424dfb3Schristosfragment <<EOF 79*1424dfb3Schristos 80*1424dfb3Schristosstatic char * 81*1424dfb3Schristosgld${EMULATION_NAME}_get_script (int *isfile) 82*1424dfb3SchristosEOF 83*1424dfb3Schristos 84*1424dfb3Schristosif test x"$COMPILE_IN" = xyes 85*1424dfb3Schristosthen 86*1424dfb3Schristos# Scripts compiled in. 87*1424dfb3Schristos 88*1424dfb3Schristos# sed commands to quote an ld script as a C string. 89*1424dfb3Schristossc="-f stringify.sed" 90*1424dfb3Schristos 91*1424dfb3Schristosfragment <<EOF 92*1424dfb3Schristos{ 93*1424dfb3Schristos *isfile = 0; 94*1424dfb3Schristos 95*1424dfb3Schristos if (bfd_link_relocatable (&link_info) && config.build_constructors) 96*1424dfb3Schristos return 97*1424dfb3SchristosEOF 98*1424dfb3Schristossed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c 99*1424dfb3Schristosecho ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c 100*1424dfb3Schristossed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c 101*1424dfb3Schristosecho ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c 102*1424dfb3Schristossed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c 103*1424dfb3Schristosecho ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c 104*1424dfb3Schristossed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c 105*1424dfb3Schristosecho ' ; else return' >> e${EMULATION_NAME}.c 106*1424dfb3Schristossed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c 107*1424dfb3Schristosecho '; }' >> e${EMULATION_NAME}.c 108*1424dfb3Schristos 109*1424dfb3Schristoselse 110*1424dfb3Schristos# Scripts read from the filesystem. 111*1424dfb3Schristos 112*1424dfb3Schristosfragment <<EOF 113*1424dfb3Schristos{ 114*1424dfb3Schristos *isfile = 1; 115*1424dfb3Schristos 116*1424dfb3Schristos if (bfd_link_relocatable (&link_info) && config.build_constructors) 117*1424dfb3Schristos return "ldscripts/${EMULATION_NAME}.xu"; 118*1424dfb3Schristos else if (bfd_link_relocatable (&link_info)) 119*1424dfb3Schristos return "ldscripts/${EMULATION_NAME}.xr"; 120*1424dfb3Schristos else if (!config.text_read_only) 121*1424dfb3Schristos return "ldscripts/${EMULATION_NAME}.xbn"; 122*1424dfb3Schristos else if (!config.magic_demand_paged) 123*1424dfb3Schristos return "ldscripts/${EMULATION_NAME}.xn"; 124*1424dfb3Schristos else 125*1424dfb3Schristos return "ldscripts/${EMULATION_NAME}.x"; 126*1424dfb3Schristos} 127*1424dfb3SchristosEOF 128*1424dfb3Schristosfi 129*1424dfb3Schristosfi 130*1424dfb3Schristos 131*1424dfb3Schristosfragment <<EOF 132*1424dfb3Schristos 133*1424dfb3Schristosstruct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 134*1424dfb3Schristos{ 135*1424dfb3Schristos ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse}, 136*1424dfb3Schristos ${LDEMUL_SYSLIB-syslib_default}, 137*1424dfb3Schristos ${LDEMUL_HLL-hll_default}, 138*1424dfb3Schristos ${LDEMUL_AFTER_PARSE-after_parse_default}, 139*1424dfb3Schristos ${LDEMUL_AFTER_OPEN-after_open_default}, 140*1424dfb3Schristos ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default}, 141*1424dfb3Schristos ${LDEMUL_BEFORE_PLACE_ORPHANS-before_place_orphans_default}, 142*1424dfb3Schristos ${LDEMUL_AFTER_ALLOCATION-after_allocation_default}, 143*1424dfb3Schristos ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default}, 144*1424dfb3Schristos ${LDEMUL_CHOOSE_TARGET-ldemul_default_target}, 145*1424dfb3Schristos ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default}, 146*1424dfb3Schristos ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script}, 147*1424dfb3Schristos "${EMULATION_NAME}", 148*1424dfb3Schristos "${OUTPUT_FORMAT}", 149*1424dfb3Schristos ${LDEMUL_FINISH-finish_default}, 150*1424dfb3Schristos ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL}, 151*1424dfb3Schristos ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL}, 152*1424dfb3Schristos ${LDEMUL_PLACE_ORPHAN-NULL}, 153*1424dfb3Schristos ${LDEMUL_SET_SYMBOLS-NULL}, 154*1424dfb3Schristos ${LDEMUL_PARSE_ARGS-NULL}, 155*1424dfb3Schristos ${LDEMUL_ADD_OPTIONS-NULL}, 156*1424dfb3Schristos ${LDEMUL_HANDLE_OPTION-NULL}, 157*1424dfb3Schristos ${LDEMUL_UNRECOGNIZED_FILE-NULL}, 158*1424dfb3Schristos ${LDEMUL_LIST_OPTIONS-NULL}, 159*1424dfb3Schristos ${LDEMUL_RECOGNIZED_FILE-NULL}, 160*1424dfb3Schristos ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, 161*1424dfb3Schristos ${LDEMUL_NEW_VERS_PATTERN-NULL}, 162*1424dfb3Schristos ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}, 163*1424dfb3Schristos ${LDEMUL_EMIT_CTF_EARLY-NULL}, 164*1424dfb3Schristos ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}, 165*1424dfb3Schristos ${LDEMUL_PRINT_SYMBOL-NULL} 166*1424dfb3Schristos}; 167*1424dfb3SchristosEOF 168