OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [ld/] [emultempl/] [beos.em] - Diff between revs 38 and 156

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 156
# This shell script emits a C file. -*- C -*-
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
# It does some substitutions.
if [ -z "$MACHINE" ]; then
if [ -z "$MACHINE" ]; then
  OUTPUT_ARCH=${ARCH}
  OUTPUT_ARCH=${ARCH}
else
else
  OUTPUT_ARCH=${ARCH}:${MACHINE}
  OUTPUT_ARCH=${ARCH}:${MACHINE}
fi
fi
fragment <
fragment <
/* This file is part of GLD, the Gnu Linker.
/* This file is part of GLD, the Gnu Linker.
   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
   This file is part of the GNU Binutils.
   This file is part of the GNU Binutils.
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */
   MA 02110-1301, USA.  */
/* For WINDOWS_NT */
/* For WINDOWS_NT */
/* The original file generated returned different default scripts depending
/* The original file generated returned different default scripts depending
   on whether certain switches were set, but these switches pertain to the
   on whether certain switches were set, but these switches pertain to the
   Linux system and that particular version of coff.  In the NT case, we
   Linux system and that particular version of coff.  In the NT case, we
   only determine if the subsystem is console or windows in order to select
   only determine if the subsystem is console or windows in order to select
   the correct entry point by default. */
   the correct entry point by default. */
#include "sysdep.h"
#include "sysdep.h"
#include "bfd.h"
#include "bfd.h"
#include "bfdlink.h"
#include "bfdlink.h"
#include "getopt.h"
#include "getopt.h"
#include "libiberty.h"
#include "libiberty.h"
#include "ld.h"
#include "ld.h"
#include "ldmain.h"
#include "ldmain.h"
#include "ldexp.h"
#include "ldexp.h"
#include "ldlang.h"
#include "ldlang.h"
#include "ldfile.h"
#include "ldfile.h"
#include "ldemul.h"
#include "ldemul.h"
#include 
#include 
#include "ldlex.h"
#include "ldlex.h"
#include "ldmisc.h"
#include "ldmisc.h"
#include "ldctor.h"
#include "ldctor.h"
#include "coff/internal.h"
#include "coff/internal.h"
#include "../bfd/libcoff.h"
#include "../bfd/libcoff.h"
#define TARGET_IS_${EMULATION_NAME}
#define TARGET_IS_${EMULATION_NAME}
static struct internal_extra_pe_aouthdr pe;
static struct internal_extra_pe_aouthdr pe;
static int dll;
static int dll;
extern const char *output_filename;
extern const char *output_filename;
static void
static void
gld_${EMULATION_NAME}_before_parse (void)
gld_${EMULATION_NAME}_before_parse (void)
{
{
  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
  output_filename = "a.exe";
  output_filename = "a.exe";
}
}


/* PE format extra command line options.  */
/* PE format extra command line options.  */
/* Used for setting flags in the PE header. */
/* Used for setting flags in the PE header. */
#define OPTION_BASE_FILE                (300  + 1)
#define OPTION_BASE_FILE                (300  + 1)
#define OPTION_DLL                      (OPTION_BASE_FILE + 1)
#define OPTION_DLL                      (OPTION_BASE_FILE + 1)
#define OPTION_FILE_ALIGNMENT           (OPTION_DLL + 1)
#define OPTION_FILE_ALIGNMENT           (OPTION_DLL + 1)
#define OPTION_IMAGE_BASE               (OPTION_FILE_ALIGNMENT + 1)
#define OPTION_IMAGE_BASE               (OPTION_FILE_ALIGNMENT + 1)
#define OPTION_MAJOR_IMAGE_VERSION      (OPTION_IMAGE_BASE + 1)
#define OPTION_MAJOR_IMAGE_VERSION      (OPTION_IMAGE_BASE + 1)
#define OPTION_MAJOR_OS_VERSION         (OPTION_MAJOR_IMAGE_VERSION + 1)
#define OPTION_MAJOR_OS_VERSION         (OPTION_MAJOR_IMAGE_VERSION + 1)
#define OPTION_MAJOR_SUBSYSTEM_VERSION  (OPTION_MAJOR_OS_VERSION + 1)
#define OPTION_MAJOR_SUBSYSTEM_VERSION  (OPTION_MAJOR_OS_VERSION + 1)
#define OPTION_MINOR_IMAGE_VERSION      (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
#define OPTION_MINOR_IMAGE_VERSION      (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
#define OPTION_MINOR_OS_VERSION         (OPTION_MINOR_IMAGE_VERSION + 1)
#define OPTION_MINOR_OS_VERSION         (OPTION_MINOR_IMAGE_VERSION + 1)
#define OPTION_MINOR_SUBSYSTEM_VERSION  (OPTION_MINOR_OS_VERSION + 1)
#define OPTION_MINOR_SUBSYSTEM_VERSION  (OPTION_MINOR_OS_VERSION + 1)
#define OPTION_SECTION_ALIGNMENT        (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
#define OPTION_SECTION_ALIGNMENT        (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
#define OPTION_STACK                    (OPTION_SECTION_ALIGNMENT + 1)
#define OPTION_STACK                    (OPTION_SECTION_ALIGNMENT + 1)
#define OPTION_SUBSYSTEM                (OPTION_STACK + 1)
#define OPTION_SUBSYSTEM                (OPTION_STACK + 1)
#define OPTION_HEAP                     (OPTION_SUBSYSTEM + 1)
#define OPTION_HEAP                     (OPTION_SUBSYSTEM + 1)
static void
static void
gld${EMULATION_NAME}_add_options
gld${EMULATION_NAME}_add_options
  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
   struct option **longopts, int nrl ATTRIBUTE_UNUSED,
   struct option **longopts, int nrl ATTRIBUTE_UNUSED,
   struct option **really_longopts ATTRIBUTE_UNUSED)
   struct option **really_longopts ATTRIBUTE_UNUSED)
{
{
  static const struct option xtra_long[] = {
  static const struct option xtra_long[] = {
    /* PE options */
    /* PE options */
    {"base-file", required_argument, NULL, OPTION_BASE_FILE},
    {"base-file", required_argument, NULL, OPTION_BASE_FILE},
    {"dll", no_argument, NULL, OPTION_DLL},
    {"dll", no_argument, NULL, OPTION_DLL},
    {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
    {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
    {"heap", required_argument, NULL, OPTION_HEAP},
    {"heap", required_argument, NULL, OPTION_HEAP},
    {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
    {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
    {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
    {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
    {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
    {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
    {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
    {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
    {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
    {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
    {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
    {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
    {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
    {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
    {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
    {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
    {"stack", required_argument, NULL, OPTION_STACK},
    {"stack", required_argument, NULL, OPTION_STACK},
    {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
    {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
    {NULL, no_argument, NULL, 0}
    {NULL, no_argument, NULL, 0}
  };
  };
  *longopts = (struct option *)
  *longopts = (struct option *)
    xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
    xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
}
}
/* PE/WIN32; added routines to get the subsystem type, heap and/or stack
/* PE/WIN32; added routines to get the subsystem type, heap and/or stack
   parameters which may be input from the command line */
   parameters which may be input from the command line */
typedef struct {
typedef struct {
  void *ptr;
  void *ptr;
  int size;
  int size;
  int value;
  int value;
  char *symbol;
  char *symbol;
  int inited;
  int inited;
} definfo;
} definfo;
#define D(field,symbol,def)  {&pe.field,sizeof(pe.field), def, symbol,0}
#define D(field,symbol,def)  {&pe.field,sizeof(pe.field), def, symbol,0}
static definfo init[] =
static definfo init[] =
{
{
  /* imagebase must be first */
  /* imagebase must be first */
#define IMAGEBASEOFF 0
#define IMAGEBASEOFF 0
  D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
  D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
#define DLLOFF 1
#define DLLOFF 1
  {&dll, sizeof(dll), 0, "__dll__", 0},
  {&dll, sizeof(dll), 0, "__dll__", 0},
  D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
  D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
  D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
  D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
  D(MajorOperatingSystemVersion,"__major_os_version__", 4),
  D(MajorOperatingSystemVersion,"__major_os_version__", 4),
  D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
  D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
  D(MajorImageVersion,"__major_image_version__", 1),
  D(MajorImageVersion,"__major_image_version__", 1),
  D(MinorImageVersion,"__minor_image_version__", 0),
  D(MinorImageVersion,"__minor_image_version__", 0),
  D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
  D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
  D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
  D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
  D(Subsystem,"__subsystem__", 3),
  D(Subsystem,"__subsystem__", 3),
  D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
  D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
  D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
  D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
  D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
  D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
  D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
  D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
  D(LoaderFlags,"__loader_flags__", 0x0),
  D(LoaderFlags,"__loader_flags__", 0x0),
  { NULL, 0, 0, NULL, 0 }
  { NULL, 0, 0, NULL, 0 }
};
};
static void
static void
set_pe_name (char *name, long val)
set_pe_name (char *name, long val)
{
{
  int i;
  int i;
  /* Find the name and set it. */
  /* Find the name and set it. */
  for (i = 0; init[i].ptr; i++)
  for (i = 0; init[i].ptr; i++)
    {
    {
      if (strcmp (name, init[i].symbol) == 0)
      if (strcmp (name, init[i].symbol) == 0)
        {
        {
          init[i].value = val;
          init[i].value = val;
          init[i].inited = 1;
          init[i].inited = 1;
          return;
          return;
        }
        }
    }
    }
  abort();
  abort();
}
}
static void
static void
set_pe_subsystem (void)
set_pe_subsystem (void)
{
{
  const char *sver;
  const char *sver;
  int len;
  int len;
  int i;
  int i;
  static const struct
  static const struct
    {
    {
      const char *name;
      const char *name;
      const int value;
      const int value;
      const char *entry;
      const char *entry;
    }
    }
  v[] =
  v[] =
    {
    {
      { "native", 1, "_NtProcessStartup" },
      { "native", 1, "_NtProcessStartup" },
      { "windows", 2, "_WinMainCRTStartup" },
      { "windows", 2, "_WinMainCRTStartup" },
      { "wwindows", 2, "_wWinMainCRTStartup" },
      { "wwindows", 2, "_wWinMainCRTStartup" },
      { "console", 3, "_mainCRTStartup" },
      { "console", 3, "_mainCRTStartup" },
      { "wconsole", 3, "_wmainCRTStartup" },
      { "wconsole", 3, "_wmainCRTStartup" },
      { "posix", 7, "___PosixProcessStartup"},
      { "posix", 7, "___PosixProcessStartup"},
      { 0, 0, 0 }
      { 0, 0, 0 }
    };
    };
  sver = strchr (optarg, ':');
  sver = strchr (optarg, ':');
  if (sver == NULL)
  if (sver == NULL)
    len = strlen (optarg);
    len = strlen (optarg);
  else
  else
    {
    {
      char *end;
      char *end;
      len = sver - optarg;
      len = sver - optarg;
      set_pe_name ("__major_subsystem_version__",
      set_pe_name ("__major_subsystem_version__",
                   strtoul (sver + 1, &end, 0));
                   strtoul (sver + 1, &end, 0));
      if (*end == '.')
      if (*end == '.')
        set_pe_name ("__minor_subsystem_version__",
        set_pe_name ("__minor_subsystem_version__",
                     strtoul (end + 1, &end, 0));
                     strtoul (end + 1, &end, 0));
      if (*end != '\0')
      if (*end != '\0')
        einfo ("%P: warning: bad version number in -subsystem option\n");
        einfo ("%P: warning: bad version number in -subsystem option\n");
    }
    }
  for (i = 0; v[i].name; i++)
  for (i = 0; v[i].name; i++)
    {
    {
      if (strncmp (optarg, v[i].name, len) == 0
      if (strncmp (optarg, v[i].name, len) == 0
          && v[i].name[len] == '\0')
          && v[i].name[len] == '\0')
        {
        {
          set_pe_name ("__subsystem__", v[i].value);
          set_pe_name ("__subsystem__", v[i].value);
          /* If the subsystem is windows, we use a different entry
          /* If the subsystem is windows, we use a different entry
             point.  */
             point.  */
          lang_default_entry (v[i].entry);
          lang_default_entry (v[i].entry);
          return;
          return;
        }
        }
    }
    }
  einfo ("%P%F: invalid subsystem type %s\n", optarg);
  einfo ("%P%F: invalid subsystem type %s\n", optarg);
}
}
static void
static void
set_pe_value (char *name)
set_pe_value (char *name)
{
{
  char *end;
  char *end;
  set_pe_name (name,  strtoul (optarg, &end, 0));
  set_pe_name (name,  strtoul (optarg, &end, 0));
  if (end == optarg)
  if (end == optarg)
    {
    {
      einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
      einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
    }
    }
  optarg = end;
  optarg = end;
}
}
static void
static void
set_pe_stack_heap (char *resname, char *comname)
set_pe_stack_heap (char *resname, char *comname)
{
{
  set_pe_value (resname);
  set_pe_value (resname);
  if (*optarg == ',')
  if (*optarg == ',')
    {
    {
      optarg++;
      optarg++;
      set_pe_value (comname);
      set_pe_value (comname);
    }
    }
  else if (*optarg)
  else if (*optarg)
    {
    {
      einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
      einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
    }
    }
}
}
static bfd_boolean
static bfd_boolean
gld${EMULATION_NAME}_handle_option (int optc)
gld${EMULATION_NAME}_handle_option (int optc)
{
{
  switch (optc)
  switch (optc)
    {
    {
    default:
    default:
      return FALSE;
      return FALSE;
    case OPTION_BASE_FILE:
    case OPTION_BASE_FILE:
      link_info.base_file = fopen (optarg, FOPEN_WB);
      link_info.base_file = fopen (optarg, FOPEN_WB);
      if (link_info.base_file == NULL)
      if (link_info.base_file == NULL)
        {
        {
          fprintf (stderr, "%s: Can't open base file %s\n",
          fprintf (stderr, "%s: Can't open base file %s\n",
                   program_name, optarg);
                   program_name, optarg);
          xexit (1);
          xexit (1);
        }
        }
      break;
      break;
      /* PE options */
      /* PE options */
    case OPTION_HEAP:
    case OPTION_HEAP:
      set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
      set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
      break;
      break;
    case OPTION_STACK:
    case OPTION_STACK:
      set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
      set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
      break;
      break;
    case OPTION_SUBSYSTEM:
    case OPTION_SUBSYSTEM:
      set_pe_subsystem ();
      set_pe_subsystem ();
      break;
      break;
    case OPTION_MAJOR_OS_VERSION:
    case OPTION_MAJOR_OS_VERSION:
      set_pe_value ("__major_os_version__");
      set_pe_value ("__major_os_version__");
      break;
      break;
    case OPTION_MINOR_OS_VERSION:
    case OPTION_MINOR_OS_VERSION:
      set_pe_value ("__minor_os_version__");
      set_pe_value ("__minor_os_version__");
      break;
      break;
    case OPTION_MAJOR_SUBSYSTEM_VERSION:
    case OPTION_MAJOR_SUBSYSTEM_VERSION:
      set_pe_value ("__major_subsystem_version__");
      set_pe_value ("__major_subsystem_version__");
      break;
      break;
    case OPTION_MINOR_SUBSYSTEM_VERSION:
    case OPTION_MINOR_SUBSYSTEM_VERSION:
      set_pe_value ("__minor_subsystem_version__");
      set_pe_value ("__minor_subsystem_version__");
      break;
      break;
    case OPTION_MAJOR_IMAGE_VERSION:
    case OPTION_MAJOR_IMAGE_VERSION:
      set_pe_value ("__major_image_version__");
      set_pe_value ("__major_image_version__");
      break;
      break;
    case OPTION_MINOR_IMAGE_VERSION:
    case OPTION_MINOR_IMAGE_VERSION:
      set_pe_value ("__minor_image_version__");
      set_pe_value ("__minor_image_version__");
      break;
      break;
    case OPTION_FILE_ALIGNMENT:
    case OPTION_FILE_ALIGNMENT:
      set_pe_value ("__file_alignment__");
      set_pe_value ("__file_alignment__");
      break;
      break;
    case OPTION_SECTION_ALIGNMENT:
    case OPTION_SECTION_ALIGNMENT:
      set_pe_value ("__section_alignment__");
      set_pe_value ("__section_alignment__");
      break;
      break;
    case OPTION_DLL:
    case OPTION_DLL:
      set_pe_name ("__dll__", 1);
      set_pe_name ("__dll__", 1);
      break;
      break;
    case OPTION_IMAGE_BASE:
    case OPTION_IMAGE_BASE:
      set_pe_value ("__image_base__");
      set_pe_value ("__image_base__");
      break;
      break;
    }
    }
  return TRUE;
  return TRUE;
}
}


/* Assign values to the special symbols before the linker script is
/* Assign values to the special symbols before the linker script is
   read.  */
   read.  */
static void
static void
gld_${EMULATION_NAME}_set_symbols (void)
gld_${EMULATION_NAME}_set_symbols (void)
{
{
  /* Run through and invent symbols for all the
  /* Run through and invent symbols for all the
     names and insert the defaults. */
     names and insert the defaults. */
  int j;
  int j;
  lang_statement_list_type *save;
  lang_statement_list_type *save;
  if (!init[IMAGEBASEOFF].inited)
  if (!init[IMAGEBASEOFF].inited)
    {
    {
      if (link_info.relocatable)
      if (link_info.relocatable)
        init[IMAGEBASEOFF].value = 0;
        init[IMAGEBASEOFF].value = 0;
      else if (init[DLLOFF].value)
      else if (init[DLLOFF].value)
        init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
        init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
      else
      else
        init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
        init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
    }
    }
  /* Don't do any symbol assignments if this is a relocatable link.  */
  /* Don't do any symbol assignments if this is a relocatable link.  */
  if (link_info.relocatable)
  if (link_info.relocatable)
    return;
    return;
  /* Glue the assignments into the abs section */
  /* Glue the assignments into the abs section */
  save = stat_ptr;
  save = stat_ptr;
  stat_ptr = &(abs_output_section->children);
  stat_ptr = &(abs_output_section->children);
  for (j = 0; init[j].ptr; j++)
  for (j = 0; init[j].ptr; j++)
    {
    {
      long val = init[j].value;
      long val = init[j].value;
      lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
      lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
      if (init[j].size == sizeof(short))
      if (init[j].size == sizeof(short))
        *(short *)init[j].ptr = val;
        *(short *)init[j].ptr = val;
      else if (init[j].size == sizeof(int))
      else if (init[j].size == sizeof(int))
        *(int *)init[j].ptr = val;
        *(int *)init[j].ptr = val;
      else if (init[j].size == sizeof(long))
      else if (init[j].size == sizeof(long))
        *(long *)init[j].ptr = val;
        *(long *)init[j].ptr = val;
      /* This might be a long long or other special type.  */
      /* This might be a long long or other special type.  */
      else if (init[j].size == sizeof(bfd_vma))
      else if (init[j].size == sizeof(bfd_vma))
        *(bfd_vma *)init[j].ptr = val;
        *(bfd_vma *)init[j].ptr = val;
      else      abort();
      else      abort();
    }
    }
  /* Restore the pointer. */
  /* Restore the pointer. */
  stat_ptr = save;
  stat_ptr = save;
  if (pe.FileAlignment >
  if (pe.FileAlignment >
      pe.SectionAlignment)
      pe.SectionAlignment)
    {
    {
      einfo ("%P: warning, file alignment > section alignment.\n");
      einfo ("%P: warning, file alignment > section alignment.\n");
    }
    }
}
}
static void
static void
gld_${EMULATION_NAME}_after_open (void)
gld_${EMULATION_NAME}_after_open (void)
{
{
  /* Pass the wacky PE command line options into the output bfd.
  /* Pass the wacky PE command line options into the output bfd.
     FIXME: This should be done via a function, rather than by
     FIXME: This should be done via a function, rather than by
     including an internal BFD header.  */
     including an internal BFD header.  */
  if (!coff_data(link_info.output_bfd)->pe)
  if (!coff_data(link_info.output_bfd)->pe)
    {
    {
      einfo ("%F%P: PE operations on non PE file.\n");
      einfo ("%F%P: PE operations on non PE file.\n");
    }
    }
  pe_data(link_info.output_bfd)->pe_opthdr = pe;
  pe_data(link_info.output_bfd)->pe_opthdr = pe;
  pe_data(link_info.output_bfd)->dll = init[DLLOFF].value;
  pe_data(link_info.output_bfd)->dll = init[DLLOFF].value;
}
}


/* Callback functions for qsort in sort_sections. */
/* Callback functions for qsort in sort_sections. */
static int
static int
sort_by_file_name (const void *a, const void *b)
sort_by_file_name (const void *a, const void *b)
{
{
  const lang_statement_union_type *const *ra = a;
  const lang_statement_union_type *const *ra = a;
  const lang_statement_union_type *const *rb = b;
  const lang_statement_union_type *const *rb = b;
  int i, a_sec, b_sec;
  int i, a_sec, b_sec;
  i = strcmp ((*ra)->input_section.section->owner->my_archive->filename,
  i = strcmp ((*ra)->input_section.section->owner->my_archive->filename,
              (*rb)->input_section.section->owner->my_archive->filename);
              (*rb)->input_section.section->owner->my_archive->filename);
  if (i != 0)
  if (i != 0)
    return i;
    return i;
  i = strcmp ((*ra)->input_section.section->owner->filename,
  i = strcmp ((*ra)->input_section.section->owner->filename,
                 (*rb)->input_section.section->owner->filename);
                 (*rb)->input_section.section->owner->filename);
  if (i != 0)
  if (i != 0)
    return i;
    return i;
  /* the tail idata4/5 are the only ones without relocs to an
  /* the tail idata4/5 are the only ones without relocs to an
     idata$6 section unless we are importing by ordinal,
     idata$6 section unless we are importing by ordinal,
     so sort them to last to terminate the IAT
     so sort them to last to terminate the IAT
     and HNT properly. if no reloc this one is import by ordinal
     and HNT properly. if no reloc this one is import by ordinal
     so we have to sort by section contents */
     so we have to sort by section contents */
  if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
  if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
    {
    {
       i =  (((*ra)->input_section.section->reloc_count >
       i =  (((*ra)->input_section.section->reloc_count >
                 (*rb)->input_section.section->reloc_count) ? -1 : 0);
                 (*rb)->input_section.section->reloc_count) ? -1 : 0);
       if ( i != 0)
       if ( i != 0)
         return i;
         return i;
        return  (((*ra)->input_section.section->reloc_count >
        return  (((*ra)->input_section.section->reloc_count >
                 (*rb)->input_section.section->reloc_count) ? 0 : 1);
                 (*rb)->input_section.section->reloc_count) ? 0 : 1);
    }
    }
  else
  else
    {
    {
       if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
       if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
          return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
          return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
       if (! bfd_get_section_contents ((*ra)->input_section.section->owner,
       if (! bfd_get_section_contents ((*ra)->input_section.section->owner,
         (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
         (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
            einfo ("%F%B: Can't read contents of section .idata: %E\n",
            einfo ("%F%B: Can't read contents of section .idata: %E\n",
                 (*ra)->input_section.section->owner);
                 (*ra)->input_section.section->owner);
       if (! bfd_get_section_contents ((*rb)->input_section.section->owner,
       if (! bfd_get_section_contents ((*rb)->input_section.section->owner,
        (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
        (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
           einfo ("%F%B: Can't read contents of section .idata: %E\n",
           einfo ("%F%B: Can't read contents of section .idata: %E\n",
                (*rb)->input_section.section->owner);
                (*rb)->input_section.section->owner);
      i =  ((a_sec < b_sec) ? -1 : 0);
      i =  ((a_sec < b_sec) ? -1 : 0);
      if ( i != 0)
      if ( i != 0)
        return i;
        return i;
      return  ((a_sec < b_sec) ? 0 : 1);
      return  ((a_sec < b_sec) ? 0 : 1);
   }
   }
return 0;
return 0;
}
}
static int
static int
sort_by_section_name (const void *a, const void *b)
sort_by_section_name (const void *a, const void *b)
{
{
  const lang_statement_union_type *const *ra = a;
  const lang_statement_union_type *const *ra = a;
  const lang_statement_union_type *const *rb = b;
  const lang_statement_union_type *const *rb = b;
  int i;
  int i;
  i = strcmp ((*ra)->input_section.section->name,
  i = strcmp ((*ra)->input_section.section->name,
              (*rb)->input_section.section->name);
              (*rb)->input_section.section->name);
  /* This is a hack to make .stab and .stabstr last, so we don't have
  /* This is a hack to make .stab and .stabstr last, so we don't have
     to fix strip/objcopy for .reloc sections.
     to fix strip/objcopy for .reloc sections.
     FIXME stripping images with a .rsrc section still needs to be fixed.  */
     FIXME stripping images with a .rsrc section still needs to be fixed.  */
  if (i != 0)
  if (i != 0)
    {
    {
      if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
      if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
           && (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
           && (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
         return 1;
         return 1;
    }
    }
  return i;
  return i;
}
}
/* Subroutine of sort_sections to a contiguous subset of a list of sections.
/* Subroutine of sort_sections to a contiguous subset of a list of sections.
   NEXT_AFTER is the element after the last one to sort.
   NEXT_AFTER is the element after the last one to sort.
   The result is a pointer to the last element's "next" pointer.  */
   The result is a pointer to the last element's "next" pointer.  */
static lang_statement_union_type **
static lang_statement_union_type **
sort_sections_1 (lang_statement_union_type **startptr,
sort_sections_1 (lang_statement_union_type **startptr,
                 lang_statement_union_type *next_after,
                 lang_statement_union_type *next_after,
                 int count,
                 int count,
                 int (*sort_func) (const void *, const void *))
                 int (*sort_func) (const void *, const void *))
{
{
  lang_statement_union_type **vec;
  lang_statement_union_type **vec;
  lang_statement_union_type *p;
  lang_statement_union_type *p;
  int i;
  int i;
  lang_statement_union_type **ret;
  lang_statement_union_type **ret;
  if (count == 0)
  if (count == 0)
    return startptr;
    return startptr;
  vec = ((lang_statement_union_type **)
  vec = ((lang_statement_union_type **)
         xmalloc (count * sizeof (lang_statement_union_type *)));
         xmalloc (count * sizeof (lang_statement_union_type *)));
  for (p = *startptr, i = 0; i < count; i++, p = p->header.next)
  for (p = *startptr, i = 0; i < count; i++, p = p->header.next)
    vec[i] = p;
    vec[i] = p;
  qsort (vec, count, sizeof (vec[0]), sort_func);
  qsort (vec, count, sizeof (vec[0]), sort_func);
  /* Fill in the next pointers again. */
  /* Fill in the next pointers again. */
  *startptr = vec[0];
  *startptr = vec[0];
  for (i = 0; i < count - 1; i++)
  for (i = 0; i < count - 1; i++)
    vec[i]->header.next = vec[i + 1];
    vec[i]->header.next = vec[i + 1];
  vec[i]->header.next = next_after;
  vec[i]->header.next = next_after;
  ret = &vec[i]->header.next;
  ret = &vec[i]->header.next;
  free (vec);
  free (vec);
  return ret;
  return ret;
}
}
/* Sort the .idata\$foo input sections of archives into filename order.
/* Sort the .idata\$foo input sections of archives into filename order.
   The reason is so dlltool can arrange to have the pe dll import information
   The reason is so dlltool can arrange to have the pe dll import information
   generated correctly - the head of the list goes into dh.o, the tail into
   generated correctly - the head of the list goes into dh.o, the tail into
   dt.o, and the guts into ds[nnnn].o.  Note that this is only needed for the
   dt.o, and the guts into ds[nnnn].o.  Note that this is only needed for the
   .idata section.
   .idata section.
   FIXME: This may no longer be necessary with grouped sections.  Instead of
   FIXME: This may no longer be necessary with grouped sections.  Instead of
   sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
   sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
   .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
   .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
   This would have to be elaborated upon to handle multiple dll's
   This would have to be elaborated upon to handle multiple dll's
   [assuming such an eloboration is possible of course].
   [assuming such an eloboration is possible of course].
   We also sort sections in '\$' wild statements.  These are created by the
   We also sort sections in '\$' wild statements.  These are created by the
   place_orphans routine to implement grouped sections.  */
   place_orphans routine to implement grouped sections.  */
static void
static void
sort_sections (lang_statement_union_type *s)
sort_sections (lang_statement_union_type *s)
{
{
  for (; s ; s = s->header.next)
  for (; s ; s = s->header.next)
    switch (s->header.type)
    switch (s->header.type)
      {
      {
      case lang_output_section_statement_enum:
      case lang_output_section_statement_enum:
        sort_sections (s->output_section_statement.children.head);
        sort_sections (s->output_section_statement.children.head);
        break;
        break;
      case lang_wild_statement_enum:
      case lang_wild_statement_enum:
        {
        {
          lang_statement_union_type **p = &s->wild_statement.children.head;
          lang_statement_union_type **p = &s->wild_statement.children.head;
          struct wildcard_list *sec;
          struct wildcard_list *sec;
          for (sec = s->wild_statement.section_list; sec; sec = sec->next)
          for (sec = s->wild_statement.section_list; sec; sec = sec->next)
            {
            {
              /* Is this the .idata section?  */
              /* Is this the .idata section?  */
              if (sec->spec.name != NULL
              if (sec->spec.name != NULL
                  && CONST_STRNEQ (sec->spec.name, ".idata"))
                  && CONST_STRNEQ (sec->spec.name, ".idata"))
                {
                {
                  /* Sort the children.  We want to sort any objects in
                  /* Sort the children.  We want to sort any objects in
                     the same archive.  In order to handle the case of
                     the same archive.  In order to handle the case of
                     including a single archive multiple times, we sort
                     including a single archive multiple times, we sort
                     all the children by archive name and then by object
                     all the children by archive name and then by object
                     name.  After sorting them, we re-thread the pointer
                     name.  After sorting them, we re-thread the pointer
                     chain.  */
                     chain.  */
                  while (*p)
                  while (*p)
                    {
                    {
                      lang_statement_union_type *start = *p;
                      lang_statement_union_type *start = *p;
                      if (start->header.type != lang_input_section_enum
                      if (start->header.type != lang_input_section_enum
                          || !start->input_section.section->owner->my_archive)
                          || !start->input_section.section->owner->my_archive)
                        p = &(start->header.next);
                        p = &(start->header.next);
                      else
                      else
                        {
                        {
                          lang_statement_union_type *end;
                          lang_statement_union_type *end;
                          int count;
                          int count;
                          for (end = start, count = 0;
                          for (end = start, count = 0;
                               end && (end->header.type
                               end && (end->header.type
                                       == lang_input_section_enum);
                                       == lang_input_section_enum);
                               end = end->header.next)
                               end = end->header.next)
                            count++;
                            count++;
                          p = sort_sections_1 (p, end, count,
                          p = sort_sections_1 (p, end, count,
                                               sort_by_file_name);
                                               sort_by_file_name);
                        }
                        }
                    }
                    }
                  break;
                  break;
                }
                }
              /* If this is a collection of grouped sections, sort them.
              /* If this is a collection of grouped sections, sort them.
                 The linker script must explicitly mention "*(.foo\$)" or
                 The linker script must explicitly mention "*(.foo\$)" or
                 "*(.foo\$*)".  Don't sort them if \$ is not the last
                 "*(.foo\$*)".  Don't sort them if \$ is not the last
                 character (not sure if this is really useful, but it
                 character (not sure if this is really useful, but it
                 allows explicitly mentioning some \$ sections and letting
                 allows explicitly mentioning some \$ sections and letting
                 the linker handle the rest).  */
                 the linker handle the rest).  */
              if (sec->spec.name != NULL)
              if (sec->spec.name != NULL)
                {
                {
                  char *q = strchr (sec->spec.name, '\$');
                  char *q = strchr (sec->spec.name, '\$');
                  if (q != NULL
                  if (q != NULL
                      && (q[1] == '\0'
                      && (q[1] == '\0'
                          || (q[1] == '*' && q[2] == '\0')))
                          || (q[1] == '*' && q[2] == '\0')))
                    {
                    {
                      lang_statement_union_type *end;
                      lang_statement_union_type *end;
                      int count;
                      int count;
                      for (end = *p, count = 0; end; end = end->header.next)
                      for (end = *p, count = 0; end; end = end->header.next)
                        {
                        {
                          if (end->header.type != lang_input_section_enum)
                          if (end->header.type != lang_input_section_enum)
                            abort ();
                            abort ();
                          count++;
                          count++;
                        }
                        }
                      (void) sort_sections_1 (p, end, count,
                      (void) sort_sections_1 (p, end, count,
                                              sort_by_section_name);
                                              sort_by_section_name);
                    }
                    }
                  break;
                  break;
                }
                }
            }
            }
        }
        }
        break;
        break;
      default:
      default:
        break;
        break;
      }
      }
}
}
static void
static void
gld_${EMULATION_NAME}_before_allocation (void)
gld_${EMULATION_NAME}_before_allocation (void)
{
{
  extern lang_statement_list_type *stat_ptr;
  extern lang_statement_list_type *stat_ptr;
#ifdef TARGET_IS_ppcpe
#ifdef TARGET_IS_ppcpe
  /* Here we rummage through the found bfds to collect toc information */
  /* Here we rummage through the found bfds to collect toc information */
  {
  {
    LANG_FOR_EACH_INPUT_STATEMENT (is)
    LANG_FOR_EACH_INPUT_STATEMENT (is)
      {
      {
        if (!ppc_process_before_allocation(is->the_bfd, &link_info))
        if (!ppc_process_before_allocation(is->the_bfd, &link_info))
          {
          {
            einfo("Errors encountered processing file %s\n", is->filename);
            einfo("Errors encountered processing file %s\n", is->filename);
          }
          }
      }
      }
  }
  }
  /* We have seen it all. Allocate it, and carry on */
  /* We have seen it all. Allocate it, and carry on */
  ppc_allocate_toc_section (&link_info);
  ppc_allocate_toc_section (&link_info);
#else
#else
#ifdef TARGET_IS_armpe
#ifdef TARGET_IS_armpe
  /* FIXME: we should be able to set the size of the interworking stub
  /* FIXME: we should be able to set the size of the interworking stub
     section.
     section.
     Here we rummage through the found bfds to collect glue
     Here we rummage through the found bfds to collect glue
     information.  FIXME: should this be based on a command line
     information.  FIXME: should this be based on a command line
     option?  krk@cygnus.com */
     option?  krk@cygnus.com */
  {
  {
    LANG_FOR_EACH_INPUT_STATEMENT (is)
    LANG_FOR_EACH_INPUT_STATEMENT (is)
      {
      {
        if (!arm_process_before_allocation (is->the_bfd, & link_info))
        if (!arm_process_before_allocation (is->the_bfd, & link_info))
          {
          {
            einfo ("Errors encountered processing file %s", is->filename);
            einfo ("Errors encountered processing file %s", is->filename);
          }
          }
      }
      }
  }
  }
  /* We have seen it all. Allocate it, and carry on */
  /* We have seen it all. Allocate it, and carry on */
  arm_allocate_interworking_sections (& link_info);
  arm_allocate_interworking_sections (& link_info);
#endif /* TARGET_IS_armpe */
#endif /* TARGET_IS_armpe */
#endif /* TARGET_IS_ppcpe */
#endif /* TARGET_IS_ppcpe */
  sort_sections (stat_ptr->head);
  sort_sections (stat_ptr->head);
  before_allocation_default ();
  before_allocation_default ();
}
}


/* Place an orphan section.  We use this to put sections with a '\$' in them
/* Place an orphan section.  We use this to put sections with a '\$' in them
   into the right place.  Any section with a '\$' in them (e.g. .text\$foo)
   into the right place.  Any section with a '\$' in them (e.g. .text\$foo)
   gets mapped to the output section with everything from the '\$' on stripped
   gets mapped to the output section with everything from the '\$' on stripped
   (e.g. .text).
   (e.g. .text).
   See the Microsoft Portable Executable and Common Object File Format
   See the Microsoft Portable Executable and Common Object File Format
   Specification 4.1, section 4.2, Grouped Sections.
   Specification 4.1, section 4.2, Grouped Sections.
   FIXME: This is now handled by the linker script using wildcards,
   FIXME: This is now handled by the linker script using wildcards,
   but I'm leaving this here in case we want to enable it for sections
   but I'm leaving this here in case we want to enable it for sections
   which are not mentioned in the linker script.  */
   which are not mentioned in the linker script.  */
static bfd_boolean
static bfd_boolean
gld${EMULATION_NAME}_place_orphan (asection *s)
gld${EMULATION_NAME}_place_orphan (asection *s)
{
{
  const char *secname;
  const char *secname;
  char *output_secname, *ps;
  char *output_secname, *ps;
  lang_output_section_statement_type *os;
  lang_output_section_statement_type *os;
  lang_statement_union_type *l;
  lang_statement_union_type *l;
  if ((s->flags & SEC_ALLOC) == 0)
  if ((s->flags & SEC_ALLOC) == 0)
    return FALSE;
    return FALSE;
  /* Don't process grouped sections unless doing a final link.
  /* Don't process grouped sections unless doing a final link.
     If they're marked as COMDAT sections, we don't want .text\$foo to
     If they're marked as COMDAT sections, we don't want .text\$foo to
     end up in .text and then have .text disappear because it's marked
     end up in .text and then have .text disappear because it's marked
     link-once-discard.  */
     link-once-discard.  */
  if (link_info.relocatable)
  if (link_info.relocatable)
    return FALSE;
    return FALSE;
  secname = bfd_get_section_name (s->owner, s);
  secname = bfd_get_section_name (s->owner, s);
  /* Everything from the '\$' on gets deleted so don't allow '\$' as the
  /* Everything from the '\$' on gets deleted so don't allow '\$' as the
     first character.  */
     first character.  */
  if (*secname == '\$')
  if (*secname == '\$')
    einfo ("%P%F: section %s has '\$' as first character\n", secname);
    einfo ("%P%F: section %s has '\$' as first character\n", secname);
  if (strchr (secname + 1, '\$') == NULL)
  if (strchr (secname + 1, '\$') == NULL)
    return FALSE;
    return FALSE;
  /* Look up the output section.  The Microsoft specs say sections names in
  /* Look up the output section.  The Microsoft specs say sections names in
     image files never contain a '\$'.  Fortunately, lang_..._lookup creates
     image files never contain a '\$'.  Fortunately, lang_..._lookup creates
     the section if it doesn't exist.  */
     the section if it doesn't exist.  */
  output_secname = xstrdup (secname);
  output_secname = xstrdup (secname);
  ps = strchr (output_secname + 1, '\$');
  ps = strchr (output_secname + 1, '\$');
  *ps = 0;
  *ps = 0;
  os = lang_output_section_statement_lookup (output_secname);
  os = lang_output_section_statement_lookup (output_secname);
  /* Find the '\$' wild statement for this section.  We currently require the
  /* Find the '\$' wild statement for this section.  We currently require the
     linker script to explicitly mention "*(.foo\$)".
     linker script to explicitly mention "*(.foo\$)".
     FIXME: ppcpe.sc has .CRT\$foo in the .rdata section.  According to the
     FIXME: ppcpe.sc has .CRT\$foo in the .rdata section.  According to the
     Microsoft docs this isn't correct so it's not (currently) handled.  */
     Microsoft docs this isn't correct so it's not (currently) handled.  */
  ps[0] = '\$';
  ps[0] = '\$';
  ps[1] = 0;
  ps[1] = 0;
  for (l = os->children.head; l; l = l->header.next)
  for (l = os->children.head; l; l = l->header.next)
    if (l->header.type == lang_wild_statement_enum)
    if (l->header.type == lang_wild_statement_enum)
      {
      {
        struct wildcard_list *sec;
        struct wildcard_list *sec;
        for (sec = l->wild_statement.section_list; sec; sec = sec->next)
        for (sec = l->wild_statement.section_list; sec; sec = sec->next)
          if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
          if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
            break;
            break;
        if (sec)
        if (sec)
          break;
          break;
      }
      }
  ps[0] = 0;
  ps[0] = 0;
  if (l == NULL)
  if (l == NULL)
    einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
    einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
  /* Link the input section in and we're done for now.
  /* Link the input section in and we're done for now.
     The sections still have to be sorted, but that has to wait until
     The sections still have to be sorted, but that has to wait until
     all such sections have been processed by us.  The sorting is done by
     all such sections have been processed by us.  The sorting is done by
     sort_sections.  */
     sort_sections.  */
  lang_add_section (&l->wild_statement.children, s, os);
  lang_add_section (&l->wild_statement.children, s, os);
  return TRUE;
  return TRUE;
}
}


static char *
static char *
gld_${EMULATION_NAME}_get_script (int *isfile)
gld_${EMULATION_NAME}_get_script (int *isfile)
EOF
EOF
# Scripts compiled in.
# Scripts compiled in.
# sed commands to quote an ld script as a C string.
# sed commands to quote an ld script as a C string.
sc="-f stringify.sed"
sc="-f stringify.sed"
fragment <
fragment <
{
{
  *isfile = 0;
  *isfile = 0;
  if (link_info.relocatable && config.build_constructors)
  if (link_info.relocatable && config.build_constructors)
    return
    return
EOF
EOF
sed $sc ldscripts/${EMULATION_NAME}.xu                 >> 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
echo '  ; else if (link_info.relocatable) return'     >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xr                 >> 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
echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xbn                >> 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
echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
echo '  ; else return'                                 >> e${EMULATION_NAME}.c
echo '  ; else return'                                 >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
echo '; }'                                             >> e${EMULATION_NAME}.c
echo '; }'                                             >> e${EMULATION_NAME}.c
fragment <
fragment <
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
{
{
  gld_${EMULATION_NAME}_before_parse,
  gld_${EMULATION_NAME}_before_parse,
  syslib_default,
  syslib_default,
  hll_default,
  hll_default,
  after_parse_default,
  after_parse_default,
  gld_${EMULATION_NAME}_after_open,
  gld_${EMULATION_NAME}_after_open,
  after_allocation_default,
  after_allocation_default,
  set_output_arch_default,
  set_output_arch_default,
  ldemul_default_target,
  ldemul_default_target,
  gld_${EMULATION_NAME}_before_allocation,
  gld_${EMULATION_NAME}_before_allocation,
  gld_${EMULATION_NAME}_get_script,
  gld_${EMULATION_NAME}_get_script,
  "${EMULATION_NAME}",
  "${EMULATION_NAME}",
  "${OUTPUT_FORMAT}",
  "${OUTPUT_FORMAT}",
  finish_default,
  finish_default,
  NULL, /* create output section statements */
  NULL, /* create output section statements */
  NULL, /* open dynamic archive */
  NULL, /* open dynamic archive */
  gld${EMULATION_NAME}_place_orphan,
  gld${EMULATION_NAME}_place_orphan,
  gld_${EMULATION_NAME}_set_symbols,
  gld_${EMULATION_NAME}_set_symbols,
  NULL, /* parse_args */
  NULL, /* parse_args */
  gld${EMULATION_NAME}_add_options,
  gld${EMULATION_NAME}_add_options,
  gld${EMULATION_NAME}_handle_option,
  gld${EMULATION_NAME}_handle_option,
  NULL, /* unrecognized file */
  NULL, /* unrecognized file */
  NULL, /* list options */
  NULL, /* list options */
  NULL, /* recognized file */
  NULL, /* recognized file */
  NULL, /* find_potential_libraries */
  NULL, /* find_potential_libraries */
  NULL  /* new_vers_pattern */
  NULL  /* new_vers_pattern */
};
};
EOF
EOF
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.