Add support for disabling automatic generation of .eh_frame_hdr sections in ELF based...
[deliverable/binutils-gdb.git] / ld / emultempl / beos.em
index 679fd81052c543555700c1eb03f1301e1c74a26f..64301023394e33aa45bc7745d56be348ecab5076 100644 (file)
@@ -5,24 +5,27 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is part of GLD, the Gnu Linker.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-2016 Free Software Foundation, Inc.
 
-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 2 of the License, or
-(at your option) any later version.
+   This file is part of the GNU Binutils.
 
-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.
+   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.  */
 
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* For WINDOWS_NT */
 /* The original file generated returned different default scripts depending
@@ -31,11 +34,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    only determine if the subsystem is console or windows in order to select
    the correct entry point by default. */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "getopt.h"
 #include "libiberty.h"
+#include "filenames.h"
 #include "ld.h"
 #include "ldmain.h"
 #include "ldexp.h"
@@ -216,23 +220,8 @@ set_pe_subsystem (void)
          set_pe_name ("__subsystem__", v[i].value);
 
          /* If the subsystem is windows, we use a different entry
-            point.  We also register the entry point as an undefined
-            symbol. from lang_add_entry() The reason we do
-            this is so that the user
-            doesn't have to because they would have to use the -u
-            switch if they were specifying an entry point other than
-            _mainCRTStartup.  Specifically, if creating a windows
-            application, entry point _WinMainCRTStartup must be
-            specified.  What I have found for non console
-            applications (entry not _mainCRTStartup) is that the .obj
-            that contains mainCRTStartup is brought in since it is
-            the first encountered in libc.lib and it has other
-            symbols in it which will be pulled in by the link
-            process.  To avoid this, adding -u with the entry point
-            name specified forces the correct .obj to be used.  We
-            can avoid making the user do this by always adding the
-            entry point name as an undefined symbol.  */
-         lang_add_entry (v[i].entry, 1);
+            point.  */
+         lang_default_entry (v[i].entry);
 
          return;
        }
@@ -281,11 +270,7 @@ gld${EMULATION_NAME}_handle_option (int optc)
     case OPTION_BASE_FILE:
       link_info.base_file = fopen (optarg, FOPEN_WB);
       if (link_info.base_file == NULL)
-       {
-         fprintf (stderr, "%s: Can't open base file %s\n",
-                  program_name, optarg);
-         xexit (1);
-       }
+       einfo (_("%F%P: cannot open base file %s\n"), optarg);
       break;
 
       /* PE options */
@@ -341,11 +326,10 @@ gld_${EMULATION_NAME}_set_symbols (void)
   /* Run through and invent symbols for all the
      names and insert the defaults. */
   int j;
-  lang_statement_list_type *save;
 
   if (!init[IMAGEBASEOFF].inited)
     {
-      if (link_info.relocatable)
+      if (bfd_link_relocatable (&link_info))
        init[IMAGEBASEOFF].value = 0;
       else if (init[DLLOFF].value)
        init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
@@ -354,18 +338,17 @@ gld_${EMULATION_NAME}_set_symbols (void)
     }
 
   /* Don't do any symbol assignments if this is a relocatable link.  */
-  if (link_info.relocatable)
+  if (bfd_link_relocatable (&link_info))
     return;
 
   /* Glue the assignments into the abs section */
-  save = stat_ptr;
-
-  stat_ptr = &(abs_output_section->children);
+  push_stat_ptr (&abs_output_section->children);
 
   for (j = 0; init[j].ptr; j++)
     {
       long val = init[j].value;
-      lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
+      lang_add_assignment (exp_assign (init[j].symbol, exp_intop (val),
+                                      FALSE));
       if (init[j].size == sizeof(short))
        *(short *)init[j].ptr = val;
       else if (init[j].size == sizeof(int))
@@ -378,7 +361,7 @@ gld_${EMULATION_NAME}_set_symbols (void)
       else     abort();
     }
   /* Restore the pointer. */
-  stat_ptr = save;
+  pop_stat_ptr ();
 
   if (pe.FileAlignment >
       pe.SectionAlignment)
@@ -390,16 +373,18 @@ gld_${EMULATION_NAME}_set_symbols (void)
 static void
 gld_${EMULATION_NAME}_after_open (void)
 {
+  after_open_default ();
+
   /* Pass the wacky PE command line options into the output bfd.
      FIXME: This should be done via a function, rather than by
      including an internal BFD header.  */
-  if (!coff_data(output_bfd)->pe)
+  if (!coff_data(link_info.output_bfd)->pe)
     {
       einfo ("%F%P: PE operations on non PE file.\n");
     }
 
-  pe_data(output_bfd)->pe_opthdr = pe;
-  pe_data(output_bfd)->dll = init[DLLOFF].value;
+  pe_data(link_info.output_bfd)->pe_opthdr = pe;
+  pe_data(link_info.output_bfd)->dll = init[DLLOFF].value;
 
 }
 \f
@@ -412,13 +397,13 @@ sort_by_file_name (const void *a, const void *b)
   const lang_statement_union_type *const *rb = b;
   int i, a_sec, b_sec;
 
-  i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename,
-             (*rb)->input_section.ifile->the_bfd->my_archive->filename);
+  i = filename_cmp ((*ra)->input_section.section->owner->my_archive->filename,
+                   (*rb)->input_section.section->owner->my_archive->filename);
   if (i != 0)
     return i;
 
-  i = strcmp ((*ra)->input_section.ifile->filename,
-                (*rb)->input_section.ifile->filename);
+  i = filename_cmp ((*ra)->input_section.section->owner->filename,
+                   (*rb)->input_section.section->owner->filename);
   if (i != 0)
     return i;
   /* the tail idata4/5 are the only ones without relocs to an
@@ -442,15 +427,15 @@ sort_by_file_name (const void *a, const void *b)
        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 */
 
-       if (! bfd_get_section_contents ((*ra)->input_section.ifile->the_bfd,
+       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)))
             einfo ("%F%B: Can't read contents of section .idata: %E\n",
-                 (*ra)->input_section.ifile->the_bfd);
+                 (*ra)->input_section.section->owner);
 
-       if (! bfd_get_section_contents ((*rb)->input_section.ifile->the_bfd,
+       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) ))
            einfo ("%F%B: Can't read contents of section .idata: %E\n",
-                (*rb)->input_section.ifile->the_bfd);
+                (*rb)->input_section.section->owner);
 
       i =  ((a_sec < b_sec) ? -1 : 0);
       if ( i != 0)
@@ -467,16 +452,15 @@ sort_by_section_name (const void *a, const void *b)
   const lang_statement_union_type *const *rb = b;
   int i;
   i = strcmp ((*ra)->input_section.section->name,
-                (*rb)->input_section.section->name);
-/* this is a hack to make .stab and .stabstr last, so we don't have
-   to fix strip/objcopy for .reloc sections.
-   FIXME stripping images with a .rsrc section still needs to be fixed */
-  if ( i != 0)
+             (*rb)->input_section.section->name);
+  /* This is a hack to make .stab and .stabstr last, so we don't have
+     to fix strip/objcopy for .reloc sections.
+     FIXME stripping images with a .rsrc section still needs to be fixed.  */
+  if (i != 0)
     {
-      if ((strncmp ((*ra)->input_section.section->name, ".stab", 5) == 0)
-           && (strncmp ((*rb)->input_section.section->name, ".stab", 5) != 0))
+      if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
+           && (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
          return 1;
-      return i;
     }
   return i;
 }
@@ -549,7 +533,7 @@ sort_sections (lang_statement_union_type *s)
            {
              /* Is this the .idata section?  */
              if (sec->spec.name != NULL
-                 && strncmp (sec->spec.name, ".idata", 6) == 0)
+                 && CONST_STRNEQ (sec->spec.name, ".idata"))
                {
                  /* Sort the children.  We want to sort any objects in
                     the same archive.  In order to handle the case of
@@ -562,7 +546,7 @@ sort_sections (lang_statement_union_type *s)
                    {
                      lang_statement_union_type *start = *p;
                      if (start->header.type != lang_input_section_enum
-                         || !start->input_section.ifile->the_bfd->my_archive)
+                         || !start->input_section.section->owner->my_archive)
                        p = &(start->header.next);
                      else
                        {
@@ -621,8 +605,6 @@ sort_sections (lang_statement_union_type *s)
 static void
 gld_${EMULATION_NAME}_before_allocation (void)
 {
-  extern lang_statement_list_type *stat_ptr;
-
 #ifdef TARGET_IS_ppcpe
   /* Here we rummage through the found bfds to collect toc information */
   {
@@ -661,6 +643,8 @@ gld_${EMULATION_NAME}_before_allocation (void)
 #endif /* TARGET_IS_ppcpe */
 
   sort_sections (stat_ptr->head);
+
+  before_allocation_default ();
 }
 \f
 /* Place an orphan section.  We use this to put sections with a '\$' in them
@@ -674,32 +658,31 @@ gld_${EMULATION_NAME}_before_allocation (void)
    but I'm leaving this here in case we want to enable it for sections
    which are not mentioned in the linker script.  */
 
-static bfd_boolean
-gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
+static lang_output_section_statement_type *
+gld${EMULATION_NAME}_place_orphan (asection *s,
+                                  const char *secname,
+                                  int constraint)
 {
-  const char *secname;
   char *output_secname, *ps;
   lang_output_section_statement_type *os;
   lang_statement_union_type *l;
 
   if ((s->flags & SEC_ALLOC) == 0)
-    return FALSE;
+    return NULL;
 
   /* Don't process grouped sections unless doing a final link.
      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
      link-once-discard.  */
-  if (link_info.relocatable)
-    return FALSE;
-
-  secname = bfd_get_section_name (s->owner, s);
+  if (bfd_link_relocatable (&link_info))
+    return NULL;
 
   /* Everything from the '\$' on gets deleted so don't allow '\$' as the
      first character.  */
   if (*secname == '\$')
     einfo ("%P%F: section %s has '\$' as first character\n", secname);
   if (strchr (secname + 1, '\$') == NULL)
-    return FALSE;
+    return NULL;
 
   /* Look up the output section.  The Microsoft specs say sections names in
      image files never contain a '\$'.  Fortunately, lang_..._lookup creates
@@ -707,7 +690,7 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
   output_secname = xstrdup (secname);
   ps = strchr (output_secname + 1, '\$');
   *ps = 0;
-  os = lang_output_section_statement_lookup (output_secname);
+  os = lang_output_section_statement_lookup (output_secname, constraint, TRUE);
 
   /* Find the '\$' wild statement for this section.  We currently require the
      linker script to explicitly mention "*(.foo\$)".
@@ -735,9 +718,9 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
      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
      sort_sections.  */
-  lang_add_section (&l->wild_statement.children, s, os, file);
+  lang_add_section (&l->wild_statement.children, s, NULL, os);
 
-  return TRUE;
+  return os;
 }
 \f
 static char *
@@ -747,15 +730,15 @@ EOF
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
-  if (link_info.relocatable && config.build_constructors)
+  if (bfd_link_relocatable (&link_info) && config.build_constructors)
     return
 EOF
 sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
-echo '  ; else if (link_info.relocatable) return'     >> 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
@@ -765,7 +748,7 @@ echo '  ; else return'                                 >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
 echo '; }'                                             >> e${EMULATION_NAME}.c
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
@@ -782,7 +765,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL, /* finish */
+  finish_default,
   NULL, /* create output section statements */
   NULL, /* open dynamic archive */
   gld${EMULATION_NAME}_place_orphan,
@@ -794,6 +777,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* list options */
   NULL,        /* recognized file */
   NULL,        /* find_potential_libraries */
-  NULL /* new_vers_pattern */
+  NULL,        /* new_vers_pattern */
+  NULL /* extra_map_file_text */
 };
 EOF
This page took 0.032608 seconds and 4 git commands to generate.