# This shell script emits a C file. -*- C -*- # It does some substitutions. test -z "${ELFSIZE}" && ELFSIZE=32 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH} else OUTPUT_ARCH=${ARCH}:${MACHINE} fi fragment < ELF support by Ian Lance Taylor 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. */ #define TARGET_IS_${EMULATION_NAME} #include "sysdep.h" #include "bfd.h" #include "libiberty.h" #include "getopt.h" #include "bfdlink.h" #include "ctf-api.h" #include "ld.h" #include "ldmain.h" #include "ldmisc.h" #include "ldexp.h" #include "ldlang.h" #include "ldfile.h" #include "ldemul.h" #include #include "elf-bfd.h" #include "ldelf.h" #include "ldelfgen.h" /* Declare functions used by various EXTRA_EM_FILEs. */ static void gld${EMULATION_NAME}_before_parse (void); static void gld${EMULATION_NAME}_before_plugin_all_symbols_read (void); static void gld${EMULATION_NAME}_after_open (void); static void gld${EMULATION_NAME}_before_allocation (void); static void gld${EMULATION_NAME}_after_allocation (void); EOF # Import any needed special functions and/or overrides. # source_em ${srcdir}/emultempl/elf-generic.em if test -n "$EXTRA_EM_FILE" ; then source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em fi # Functions in this file can be overridden by setting the LDEMUL_* shell # variables. If the name of the overriding function is the same as is # defined in this file, then don't output this file's version. # If a different overriding name is given then output the standard function # as presumably it is called from the overriding function. # if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then fragment <> e${EMULATION_NAME}.c echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c fi if test -n "$GENERATE_PIE_SCRIPT" ; then if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c fi fi echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c fi if test -n "$GENERATE_SHLIB_SCRIPT" ; then if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c fi fi echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c fi echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c fi if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro' >> e${EMULATION_NAME}.c echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c fi echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c fi echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c fi if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c fi echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c if test -n "$GENERATE_RELRO_SCRIPT" ; then echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c fi echo ' ; else return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c echo '; }' >> e${EMULATION_NAME}.c else # Scripts read from the filesystem. fragment < 0) ldelf_emit_note_fdo_package_metadata = xstrdup (optarg); break; case OPTION_COMPRESS_DEBUG: link_info.compress_debug = bfd_get_compression_algorithm (optarg); if (strcasecmp (optarg, "zstd") == 0) { #ifndef HAVE_ZSTD if (link_info.compress_debug == COMPRESS_DEBUG_ZSTD) einfo (_ ("%F%P: --compress-debug-sections=zstd: ld is not built " "with zstd support\n")); #endif } if (link_info.compress_debug == COMPRESS_UNKNOWN) einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"), optarg); break; EOF if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then fragment <