1 1.1 christos # This shell script emits a C file. -*- C -*- 2 1.10 christos # Copyright (C) 2006-2025 Free Software Foundation, Inc. 3 1.1 christos # 4 1.1 christos # This file is part of the GNU Binutils. 5 1.1 christos # 6 1.1 christos # This program is free software; you can redistribute it and/or modify 7 1.1 christos # it under the terms of the GNU General Public License as published by 8 1.1 christos # the Free Software Foundation; either version 3 of the License, or 9 1.1 christos # (at your option) any later version. 10 1.1 christos # 11 1.1 christos # This program is distributed in the hope that it will be useful, 12 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 christos # GNU General Public License for more details. 15 1.1 christos # 16 1.1 christos # You should have received a copy of the GNU General Public License 17 1.1 christos # along with this program; if not, write to the Free Software 18 1.1 christos # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19 1.1 christos # MA 02110-1301, USA. 20 1.1 christos # 21 1.1 christos 22 1.1 christos if test -n "$VXWORKS_BASE_EM_FILE" ; then 23 1.1 christos source_em "${srcdir}/emultempl/${VXWORKS_BASE_EM_FILE}.em" 24 1.1 christos fi 25 1.1 christos 26 1.1 christos fragment <<EOF 27 1.1 christos 28 1.1 christos static int force_dynamic; 29 1.1 christos 30 1.1 christos static void 31 1.1 christos vxworks_before_parse (void) 32 1.1 christos { 33 1.1 christos ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse} (); 34 1.1 christos config.rpath_separator = ';'; 35 1.1 christos } 36 1.1 christos 37 1.1 christos static void 38 1.1 christos vxworks_after_open (void) 39 1.1 christos { 40 1.1 christos ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open} (); 41 1.1 christos 42 1.1 christos if (force_dynamic 43 1.1 christos && link_info.input_bfds 44 1.1 christos && bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour 45 1.1 christos && !_bfd_elf_link_create_dynamic_sections (link_info.input_bfds, 46 1.1 christos &link_info)) 47 1.6 christos einfo (_("%X%P: cannot create dynamic sections %E\n")); 48 1.1 christos 49 1.1 christos if (!force_dynamic 50 1.3 christos && !bfd_link_pic (&link_info) 51 1.1 christos && bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour 52 1.1 christos && elf_hash_table (&link_info)->dynamic_sections_created) 53 1.6 christos einfo (_("%X%P: dynamic sections created in non-dynamic link\n")); 54 1.1 christos } 55 1.1 christos 56 1.1 christos EOF 57 1.1 christos 58 1.1 christos PARSE_AND_LIST_LONGOPTS=$PARSE_AND_LIST_LONGOPTS' 59 1.1 christos {"force-dynamic", no_argument, NULL, OPTION_FORCE_DYNAMIC}, 60 1.1 christos ' 61 1.1 christos 62 1.1 christos PARSE_AND_LIST_OPTIONS=$PARSE_AND_LIST_OPTIONS' 63 1.1 christos fprintf (file, _("\ 64 1.1 christos --force-dynamic Always create dynamic sections\n")); 65 1.1 christos ' 66 1.1 christos 67 1.1 christos PARSE_AND_LIST_ARGS_CASES=$PARSE_AND_LIST_ARGS_CASES' 68 1.1 christos case OPTION_FORCE_DYNAMIC: 69 1.1 christos force_dynamic = 1; 70 1.1 christos break; 71 1.1 christos ' 72 1.1 christos 73 1.1 christos # Hook in our routines above. There are three possibilities: 74 1.1 christos # 75 1.1 christos # (1) VXWORKS_BASE_EM_FILE did not set the hook's LDEMUL_FOO variable. 76 1.1 christos # We want to define LDEMUL_FOO to vxworks_foo in that case, 77 1.1 christos # 78 1.1 christos # (2) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to 79 1.1 christos # gld${EMULATION_NAME}_foo. This means that the file has 80 1.7 christos # replaced elf.em's default definition, so we simply #define 81 1.1 christos # the current value of LDEMUL_FOO to vxworks_foo. 82 1.1 christos # 83 1.1 christos # (3) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to 84 1.1 christos # something other than gld${EMULATION_NAME}_foo. We handle 85 1.1 christos # this case in the same way as (1). 86 1.1 christos for override in before_parse after_open; do 87 1.1 christos var="LDEMUL_`echo ${override} | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`" 88 1.1 christos eval value=\$${var} 89 1.1 christos if test "${value}" = "gld${EMULATION_NAME}_${override}"; then 90 1.1 christos fragment <<EOF 91 1.1 christos #define ${value} vxworks_${override} 92 1.1 christos EOF 93 1.1 christos else 94 1.1 christos eval $var=vxworks_${override} 95 1.1 christos fi 96 1.1 christos done 97