1214571Sdim# This shell script emits a C file. -*- C -*- 2214571Sdim# Copyright 2006 Free Software Foundation, Inc. 3214571Sdim# Contributed by: 4214571Sdim# Mei Ligang (ligang@sunnorth.com.cn) 5214571Sdim# Pei-Lin Tsai (pltsai@sunplus.com) 6214571Sdim 7214571Sdim# This file is part of GLD, the Gnu Linker. 8214571Sdim# 9214571Sdim# This program is free software; you can redistribute it and/or modify 10214571Sdim# it under the terms of the GNU General Public License as published by 11214571Sdim# the Free Software Foundation; either version 2 of the License, or 12214571Sdim# (at your option) any later version. 13214571Sdim# 14214571Sdim# This program is distributed in the hope that it will be useful, 15214571Sdim# but WITHOUT ANY WARRANTY; without even the implied warranty of 16214571Sdim# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17214571Sdim# GNU General Public License for more details. 18214571Sdim# 19214571Sdim# You should have received a copy of the GNU General Public License 20214571Sdim# along with this program; if not, write to the Free Software 21214571Sdim# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 22214571Sdim# 02110-1301, USA. 23214571Sdim# 24214571Sdim 25214571Sdim# This file is sourced from elf32.em, and defines extra score-elf 26214571Sdim# specific routines. 27214571Sdim# 28214571Sdimcat >>e${EMULATION_NAME}.c <<EOF 29214571Sdim 30214571Sdimstatic void 31214571Sdimgld${EMULATION_NAME}_before_parse () 32214571Sdim{ 33214571Sdim#ifndef TARGET_ /* I.e., if not generic. */ 34214571Sdim ldfile_set_output_arch ("`echo ${ARCH}`"); 35214571Sdim#endif /* not TARGET_ */ 36214571Sdim config.dynamic_link = ${DYNAMIC_LINK-true}; 37214571Sdim config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`; 38214571Sdim} 39214571Sdim 40214571Sdimstatic void 41214571Sdimscore_elf_after_open (void) 42214571Sdim{ 43214571Sdim if (strstr (bfd_get_target (output_bfd), "score") == NULL) 44214571Sdim { 45214571Sdim /* The score backend needs special fields in the output hash structure. 46214571Sdim These will only be created if the output format is an score format, 47214571Sdim hence we do not support linking and changing output formats at the 48214571Sdim same time. Use a link followed by objcopy to change output formats. */ 49214571Sdim einfo ("%F%X%P: error: cannot change output format whilst linking S+core binaries\n"); 50214571Sdim return; 51214571Sdim } 52214571Sdim 53214571Sdim /* Call the standard elf routine. */ 54214571Sdim gld${EMULATION_NAME}_after_open (); 55214571Sdim} 56214571Sdim 57214571SdimEOF 58214571Sdim 59214571Sdim# Define some shell vars to insert bits of code into the standard elf 60214571Sdim# parse_args and list_options functions. 61214571Sdim# 62214571SdimPARSE_AND_LIST_PROLOGUE='' 63214571SdimPARSE_AND_LIST_SHORTOPTS= 64214571SdimPARSE_AND_LIST_LONGOPTS='' 65214571SdimPARSE_AND_LIST_OPTIONS='' 66214571SdimPARSE_AND_LIST_ARGS_CASES='' 67214571Sdim 68214571Sdim# We have our own after_open and before_allocation functions, but they call 69214571Sdim# the standard routines, so give them a different name. 70214571SdimLDEMUL_AFTER_OPEN=score_elf_after_open 71214571Sdim 72214571Sdim# Replace the elf before_parse function with our own. 73214571SdimLDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse 74214571Sdim 75