1f7cc78ecSespie# This shell script emits a C file. -*- C -*- 2f7cc78ecSespie# It does some substitutions. 3f7cc78ecSespiecat >e${EMULATION_NAME}.c <<EOF 4f7cc78ecSespie/* This file is is generated by a shell script. DO NOT EDIT! */ 5f7cc78ecSespie 6f7cc78ecSespie/* emulate the original gld for the given ${EMULATION_NAME} 7*cf2f2c56Smiod Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 8*cf2f2c56Smiod 2004 Free Software Foundation, Inc. 9f7cc78ecSespie Written by Steve Chamberlain steve@cygnus.com 10f7cc78ecSespie 11f7cc78ecSespieThis file is part of GLD, the Gnu Linker. 12f7cc78ecSespie 13f7cc78ecSespieThis program is free software; you can redistribute it and/or modify 14f7cc78ecSespieit under the terms of the GNU General Public License as published by 15f7cc78ecSespiethe Free Software Foundation; either version 2 of the License, or 16f7cc78ecSespie(at your option) any later version. 17f7cc78ecSespie 18f7cc78ecSespieThis program is distributed in the hope that it will be useful, 19f7cc78ecSespiebut WITHOUT ANY WARRANTY; without even the implied warranty of 20f7cc78ecSespieMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21f7cc78ecSespieGNU General Public License for more details. 22f7cc78ecSespie 23f7cc78ecSespieYou should have received a copy of the GNU General Public License 24f7cc78ecSespiealong with this program; if not, write to the Free Software 25f7cc78ecSespieFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 26f7cc78ecSespie 27f7cc78ecSespie#define TARGET_IS_${EMULATION_NAME} 28f7cc78ecSespie 29f7cc78ecSespie#define bfd_elf32_arm_allocate_interworking_sections \ 30f7cc78ecSespie bfd_elf32_arm_oabi_allocate_interworking_sections 31f7cc78ecSespie#define bfd_elf32_arm_get_bfd_for_interworking \ 32f7cc78ecSespie bfd_elf32_arm_oabi_get_bfd_for_interworking 33f7cc78ecSespie#define bfd_elf32_arm_process_before_allocation \ 34f7cc78ecSespie bfd_elf32_arm_oabi_process_before_allocation 35f7cc78ecSespie 36f7cc78ecSespie#include "bfd.h" 37f7cc78ecSespie#include "sysdep.h" 38f7cc78ecSespie#include "bfdlink.h" 39f7cc78ecSespie#include "getopt.h" 40f7cc78ecSespie 41f7cc78ecSespie#include "ld.h" 42f7cc78ecSespie#include "ldmain.h" 43f7cc78ecSespie#include "ldmisc.h" 44f7cc78ecSespie 45f7cc78ecSespie#include "ldexp.h" 46f7cc78ecSespie#include "ldlang.h" 475f210c2aSfgsch#include "ldfile.h" 485f210c2aSfgsch#include "ldemul.h" 49f7cc78ecSespie 50f7cc78ecSespiestatic void 51*cf2f2c56Smiodgld${EMULATION_NAME}_before_parse (void) 52f7cc78ecSespie{ 53f7cc78ecSespie#ifndef TARGET_ /* I.e., if not generic. */ 54*cf2f2c56Smiod ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); 55f7cc78ecSespie#endif /* not TARGET_ */ 56f7cc78ecSespie} 57f7cc78ecSespie 58f7cc78ecSespie/* This is called after the sections have been attached to output 59f7cc78ecSespie sections, but before any sizes or addresses have been set. */ 60f7cc78ecSespie 61f7cc78ecSespiestatic void 62*cf2f2c56Smiodgld${EMULATION_NAME}_before_allocation (void) 63f7cc78ecSespie{ 64f7cc78ecSespie /* we should be able to set the size of the interworking stub section */ 65f7cc78ecSespie 66f7cc78ecSespie /* Here we rummage through the found bfds to collect glue information */ 67f7cc78ecSespie /* FIXME: should this be based on a command line option? krk@cygnus.com */ 68f7cc78ecSespie { 69f7cc78ecSespie LANG_FOR_EACH_INPUT_STATEMENT (is) 70f7cc78ecSespie { 71f7cc78ecSespie if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, &link_info, 0)) 72f7cc78ecSespie { 73f7cc78ecSespie /* xgettext:c-format */ 74f7cc78ecSespie einfo (_("Errors encountered processing file %s"), is->filename); 75f7cc78ecSespie } 76f7cc78ecSespie } 77f7cc78ecSespie } 78f7cc78ecSespie 79f7cc78ecSespie /* We have seen it all. Allocate it, and carry on */ 80f7cc78ecSespie bfd_elf32_arm_allocate_interworking_sections (& link_info); 81f7cc78ecSespie} 82f7cc78ecSespie 83f7cc78ecSespiestatic void 84*cf2f2c56Smiodgld${EMULATION_NAME}_after_open (void) 85f7cc78ecSespie{ 86f7cc78ecSespie 87f7cc78ecSespie LANG_FOR_EACH_INPUT_STATEMENT (is) 88f7cc78ecSespie { 89f7cc78ecSespie /* The interworking bfd must be the last one to be processed */ 90f7cc78ecSespie if (!is->next) 91f7cc78ecSespie bfd_elf32_arm_get_bfd_for_interworking (is->the_bfd, & link_info); 92f7cc78ecSespie } 93f7cc78ecSespie} 94f7cc78ecSespie 95f7cc78ecSespiestatic char * 96*cf2f2c56Smiodgld${EMULATION_NAME}_get_script (int *isfile) 97f7cc78ecSespieEOF 98f7cc78ecSespie 99f7cc78ecSespieif test -n "$COMPILE_IN" 100f7cc78ecSespiethen 101f7cc78ecSespie# Scripts compiled in. 102f7cc78ecSespie 103f7cc78ecSespie# sed commands to quote an ld script as a C string. 104f7cc78ecSespiesc="-f stringify.sed" 105f7cc78ecSespie 106f7cc78ecSespiecat >>e${EMULATION_NAME}.c <<EOF 107f7cc78ecSespie{ 108f7cc78ecSespie *isfile = 0; 109f7cc78ecSespie 110*cf2f2c56Smiod if (link_info.relocatable && config.build_constructors) 111f7cc78ecSespie return 112f7cc78ecSespieEOF 113f7cc78ecSespiesed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c 114*cf2f2c56Smiodecho ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c 115f7cc78ecSespiesed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c 116f7cc78ecSespieecho ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c 117f7cc78ecSespiesed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c 118f7cc78ecSespieecho ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c 119f7cc78ecSespiesed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c 120f7cc78ecSespieecho ' ; else return' >> e${EMULATION_NAME}.c 121f7cc78ecSespiesed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c 122f7cc78ecSespieecho '; }' >> e${EMULATION_NAME}.c 123f7cc78ecSespie 124f7cc78ecSespieelse 125f7cc78ecSespie# Scripts read from the filesystem. 126f7cc78ecSespie 127f7cc78ecSespiecat >>e${EMULATION_NAME}.c <<EOF 128f7cc78ecSespie{ 129f7cc78ecSespie *isfile = 1; 130f7cc78ecSespie 131*cf2f2c56Smiod if (link_info.relocatable && config.build_constructors) 132f7cc78ecSespie return "ldscripts/${EMULATION_NAME}.xu"; 133*cf2f2c56Smiod else if (link_info.relocatable) 134f7cc78ecSespie return "ldscripts/${EMULATION_NAME}.xr"; 135f7cc78ecSespie else if (!config.text_read_only) 136f7cc78ecSespie return "ldscripts/${EMULATION_NAME}.xbn"; 137f7cc78ecSespie else if (!config.magic_demand_paged) 138f7cc78ecSespie return "ldscripts/${EMULATION_NAME}.xn"; 139f7cc78ecSespie else 140f7cc78ecSespie return "ldscripts/${EMULATION_NAME}.x"; 141f7cc78ecSespie} 142f7cc78ecSespieEOF 143f7cc78ecSespie 144f7cc78ecSespiefi 145f7cc78ecSespie 146f7cc78ecSespiecat >>e${EMULATION_NAME}.c <<EOF 147f7cc78ecSespie 148f7cc78ecSespiestruct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 149f7cc78ecSespie{ 150f7cc78ecSespie gld${EMULATION_NAME}_before_parse, 151f7cc78ecSespie syslib_default, 152f7cc78ecSespie hll_default, 153f7cc78ecSespie after_parse_default, 154f7cc78ecSespie gld${EMULATION_NAME}_after_open, 155f7cc78ecSespie after_allocation_default, 156f7cc78ecSespie set_output_arch_default, 157f7cc78ecSespie ldemul_default_target, 158f7cc78ecSespie gld${EMULATION_NAME}_before_allocation, 159f7cc78ecSespie gld${EMULATION_NAME}_get_script, 160f7cc78ecSespie "${EMULATION_NAME}", 161f7cc78ecSespie "${OUTPUT_FORMAT}", 162f7cc78ecSespie NULL, /* finish */ 163f7cc78ecSespie NULL, /* create output section statements */ 164f7cc78ecSespie NULL, /* open dynamic archive */ 165f7cc78ecSespie NULL, /* place orphan */ 166f7cc78ecSespie NULL, /* set symbols */ 167f7cc78ecSespie NULL, /* parse args */ 168d2201f2fSdrahn NULL, /* add_options */ 169d2201f2fSdrahn NULL, /* handle_option */ 170f7cc78ecSespie NULL, /* unrecognized file */ 171f7cc78ecSespie NULL, /* list options */ 172f7cc78ecSespie NULL, /* recognized file */ 173d2201f2fSdrahn NULL, /* find_potential_libraries */ 174d2201f2fSdrahn NULL /* new_vers_pattern */ 175f7cc78ecSespie}; 176f7cc78ecSespieEOF 177