* emultempl/aix.em: Convert to C90, remove unnecessary prototypes
[deliverable/binutils-gdb.git] / ld / emultempl / mipsecoff.em
index d1200c46d7041b1f6ecce42099a003bf85838fc5..c0e8093ef7ec1c940c5ce7cee0fa67a0d053f6e2 100644 (file)
@@ -1,10 +1,16 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
+if [ -z "$MACHINE" ]; then
+  OUTPUT_ARCH=${ARCH}
+else
+  OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
 cat >e${EMULATION_NAME}.c <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* Handle embedded relocs for MIPS.
-   Copyright 1994 Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1997, 2000, 2002, 2003
+   Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com> based on generic.em.
 
 This file is part of GLD, the Gnu Linker.
@@ -31,21 +37,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "ld.h"
 #include "ldmain.h"
-#include "ldemul.h"
-#include "ldfile.h"
 #include "ldmisc.h"
 
-static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
-static void gld${EMULATION_NAME}_after_open PARAMS ((void));
-static void check_sections PARAMS ((bfd *, asection *, PTR));
-static void gld${EMULATION_NAME}_after_allocation PARAMS ((void));
-static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
+#include "ldexp.h"
+#include "ldlang.h"
+#include "ldfile.h"
+#include "ldemul.h"
+
+static void check_sections (bfd *, asection *, void *);
 
 static void
-gld${EMULATION_NAME}_before_parse()
+gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_                        /* I.e., if not generic.  */
-  ldfile_output_architecture = bfd_arch_${ARCH};
+  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+  if (arch)
+    {
+      ldfile_output_architecture = arch->arch;
+      ldfile_output_machine = arch->mach;
+      ldfile_output_machine_name = arch->printable_name;
+    }
+  else
+    ldfile_output_architecture = bfd_arch_${ARCH};
 #endif /* not TARGET_ */
 }
 
@@ -57,18 +70,23 @@ gld${EMULATION_NAME}_before_parse()
    have been compiled using -membedded-pic.  */
 
 static void
-gld${EMULATION_NAME}_after_open ()
+gld${EMULATION_NAME}_after_open (void)
 {
   bfd *abfd;
 
   if (! command_line.embedded_relocs
-      || link_info.relocateable)
+      || link_info.relocatable)
     return;
 
   for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
     {
       asection *datasec;
 
+      /* As first-order business, make sure that each input BFD is ECOFF. It
+         better be, as we are directly calling an ECOFF backend function.  */
+      if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour)
+       einfo ("%F%B: all input objects must be ECOFF for --embedded-relocs\n");
+
       datasec = bfd_get_section_by_name (abfd, ".sdata");
 
       /* Note that we assume that the reloc_count field has already
@@ -97,7 +115,7 @@ gld${EMULATION_NAME}_after_open ()
 
       /* Double check that all other data sections are empty, as is
          required for embedded PIC code.  */
-      bfd_map_over_sections (abfd, check_sections, (PTR) datasec);
+      bfd_map_over_sections (abfd, check_sections, datasec);
     }
 }
 
@@ -105,15 +123,12 @@ gld${EMULATION_NAME}_after_open ()
    relocs.  This is called via bfd_map_over_sections.  */
 
 static void
-check_sections (abfd, sec, sdatasec)
-     bfd *abfd;
-     asection *sec;
-     PTR sdatasec;
+check_sections (bfd *abfd, asection *sec, void *sdatasec)
 {
   if ((bfd_get_section_flags (abfd, sec) & SEC_CODE) == 0
-      && sec != (asection *) sdatasec
+      && sec != sdatasec
       && sec->reloc_count != 0)
-    einfo ("%P%X: section %s has relocs; can not use --embedded-relocs\n",
+    einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n",
           abfd, bfd_get_section_name (abfd, sec));
 }
 
@@ -122,12 +137,12 @@ check_sections (abfd, sec, sdatasec)
    BFD backend routine to do the work.  */
 
 static void
-gld${EMULATION_NAME}_after_allocation ()
+gld${EMULATION_NAME}_after_allocation (void)
 {
   bfd *abfd;
 
   if (! command_line.embedded_relocs
-      || link_info.relocateable)
+      || link_info.relocatable)
     return;
 
   for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
@@ -158,8 +173,7 @@ gld${EMULATION_NAME}_after_allocation ()
 }
 
 static char *
-gld${EMULATION_NAME}_get_script(isfile)
-     int *isfile;
+gld${EMULATION_NAME}_get_script (int *isfile)
 EOF
 
 if test -n "$COMPILE_IN"
@@ -167,36 +181,36 @@ then
 # Scripts compiled in.
 
 # sed commands to quote an ld script as a C string.
-sc="-f ${srcdir}/emultempl/stringify.sed"
+sc="-f stringify.sed"
 
 cat >>e${EMULATION_NAME}.c <<EOF
-{                           
+{
   *isfile = 0;
 
-  if (link_info.relocateable == true && config.build_constructors == true)
+  if (link_info.relocatable && config.build_constructors)
     return
 EOF
-sed $sc ldscripts/${EMULATION_NAME}.xu                     >> e${EMULATION_NAME}.c
-echo '  ; else if (link_info.relocateable == true) 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
-echo '  ; else if (!config.magic_demand_paged) return'     >> e${EMULATION_NAME}.c
-sed $sc ldscripts/${EMULATION_NAME}.xn                     >> e${EMULATION_NAME}.c
-echo '  ; else return'                                     >> e${EMULATION_NAME}.c
-sed $sc ldscripts/${EMULATION_NAME}.x                      >> e${EMULATION_NAME}.c
-echo '; }'                                                 >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
+echo '  ; else if (link_info.relocatable) 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
+echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
+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.
 
 cat >>e${EMULATION_NAME}.c <<EOF
-{                           
+{
   *isfile = 1;
 
-  if (link_info.relocateable == true && config.build_constructors == true)
+  if (link_info.relocatable && config.build_constructors)
     return "ldscripts/${EMULATION_NAME}.xu";
-  else if (link_info.relocateable == true)
+  else if (link_info.relocatable)
     return "ldscripts/${EMULATION_NAME}.xr";
   else if (!config.text_read_only)
     return "ldscripts/${EMULATION_NAME}.xbn";
@@ -211,7 +225,7 @@ fi
 
 cat >>e${EMULATION_NAME}.c <<EOF
 
-struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
   gld${EMULATION_NAME}_before_parse,
   syslib_default,
@@ -224,6 +238,19 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   before_allocation_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
-  "${OUTPUT_FORMAT}"
+  "${OUTPUT_FORMAT}",
+  NULL,        /* finish */
+  NULL,        /* create output section statements */
+  NULL,        /* open dynamic archive */
+  NULL,        /* place orphan */
+  NULL,        /* set symbols */
+  NULL,        /* parse args */
+  NULL,        /* add_options */
+  NULL,        /* handle_option */
+  NULL,        /* unrecognized file */
+  NULL,        /* list options */
+  NULL,        /* recognized file */
+  NULL,        /* find_potential_libraries */
+  NULL /* new_vers_pattern */
 };
 EOF
This page took 0.0269 seconds and 4 git commands to generate.