* emulparams/elf32_dlx.sh (TARGET_PAGE_SIZE): Set to 1.
[deliverable/binutils-gdb.git] / ld / emultempl / pe.em
index 03037329dbd0b5009f7895cc69d0b13103dc3739..37146ab59f843f9e248f9232f3812e269233a16c 100644 (file)
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-if [ -z "$MACHINE" ]; then 
+if [ -z "$MACHINE" ]; then
   OUTPUT_ARCH=${ARCH}
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
@@ -9,7 +9,7 @@ rm -f e${EMULATION_NAME}.c
 (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
 cat >>e${EMULATION_NAME}.c <<EOF
 /* This file is part of GLD, the Gnu Linker.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
@@ -31,8 +31,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    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
    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. */
+
+#define TARGET_IS_${EMULATION_NAME}
+
+/* Do this before including bfd.h, so we prototype the right functions.  */
+#ifdef TARGET_IS_arm_epoc_pe
+#define bfd_arm_pe_allocate_interworking_sections \
+       bfd_arm_epoc_pe_allocate_interworking_sections
+#define bfd_arm_pe_get_bfd_for_interworking \
+       bfd_arm_epoc_pe_get_bfd_for_interworking
+#define bfd_arm_pe_process_before_allocation \
+       bfd_arm_epoc_pe_process_before_allocation
+#endif
+
 #include "bfd.h"
 #include "sysdep.h"
 #include "bfdlink.h"
@@ -40,11 +52,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "libiberty.h"
 #include "ld.h"
 #include "ldmain.h"
-#include "ldgram.h"
 #include "ldexp.h"
 #include "ldlang.h"
 #include "ldfile.h"
 #include "ldemul.h"
+#include "ldgram.h"
 #include "ldlex.h"
 #include "ldmisc.h"
 #include "ldctor.h"
@@ -59,8 +71,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include <ctype.h>
 
-#define TARGET_IS_${EMULATION_NAME}
-
 /* Permit the emulation parameters to override the default section
    alignment by setting OVERRIDE_SECTION_ALIGNMENT.  FIXME: This makes
    it seem that include/coff/internal.h should not define
@@ -94,15 +104,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #define PE_DEF_FILE_ALIGNMENT          0x00000200
 #endif
 
-#ifdef TARGET_IS_arm_epoc_pe
-#define bfd_arm_pe_allocate_interworking_sections \
-       bfd_arm_epoc_pe_allocate_interworking_sections
-#define bfd_arm_pe_get_bfd_for_interworking \
-       bfd_arm_epoc_pe_get_bfd_for_interworking
-#define bfd_arm_pe_process_before_allocation \
-       bfd_arm_epoc_pe_process_before_allocation
-#endif
-
 static void gld_${EMULATION_NAME}_set_symbols PARAMS ((void));
 static void gld_${EMULATION_NAME}_after_open PARAMS ((void));
 static void gld_${EMULATION_NAME}_before_parse PARAMS ((void));
@@ -115,8 +116,30 @@ static boolean gld_${EMULATION_NAME}_place_orphan
 static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
 static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
 static void gld_${EMULATION_NAME}_finish PARAMS ((void));
-static boolean gld_${EMULATION_NAME}_open_dynamic_archive 
+static boolean gld_${EMULATION_NAME}_open_dynamic_archive
   PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *));
+static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE *));
+static void set_pe_name PARAMS ((char *, long));
+static void set_pe_subsystem PARAMS ((void));
+static void set_pe_value PARAMS ((char *));
+static void set_pe_stack_heap PARAMS ((char *, char *));
+
+#ifdef DLL_SUPPORT
+static boolean pe_undef_cdecl_match
+  PARAMS ((struct bfd_link_hash_entry *, PTR));
+static void pe_fixup_stdcalls PARAMS ((void));
+static int make_import_fixup PARAMS ((arelent *, asection *));
+static void pe_find_data_imports PARAMS ((void));
+#endif
+
+static boolean pr_sym PARAMS ((struct bfd_hash_entry *, PTR string));
+static boolean gld_${EMULATION_NAME}_unrecognized_file
+  PARAMS ((lang_input_statement_type *));
+static boolean gld_${EMULATION_NAME}_recognized_file
+  PARAMS ((lang_input_statement_type *));
+static int gld_${EMULATION_NAME}_find_potential_libraries
+  PARAMS ((char *, lang_input_statement_type *));
+
 
 static struct internal_extra_pe_aouthdr pe;
 static int dll;
@@ -150,7 +173,7 @@ gld_${EMULATION_NAME}_before_parse()
 #ifdef DLL_SUPPORT
   config.dynamic_link = true;
   config.has_shared = 1;
-/* link_info.pei386_auto_import = true; */
+  link_info.pei386_auto_import = -1;
 
 #if (PE_DEF_SUBSYSTEM == 9) || (PE_DEF_SUBSYSTEM == 2)
 #if defined TARGET_IS_mipspe || defined TARGET_IS_armpe
@@ -198,13 +221,14 @@ gld_${EMULATION_NAME}_before_parse()
 #define OPTION_DLL_ENABLE_AUTO_IMPORT  (OPTION_NO_DEFAULT_EXCLUDES + 1)
 #define OPTION_DLL_DISABLE_AUTO_IMPORT (OPTION_DLL_ENABLE_AUTO_IMPORT + 1)
 #define OPTION_ENABLE_EXTRA_PE_DEBUG   (OPTION_DLL_DISABLE_AUTO_IMPORT + 1)
+#define OPTION_EXCLUDE_LIBS            (OPTION_ENABLE_EXTRA_PE_DEBUG + 1)
 
 static struct option longopts[] = {
   /* PE options */
   {"base-file", required_argument, NULL, OPTION_BASE_FILE},
   {"dll", no_argument, NULL, OPTION_DLL},
   {"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},
   {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
   {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
@@ -224,6 +248,7 @@ static struct option longopts[] = {
   {"output-def", required_argument, NULL, OPTION_OUT_DEF},
   {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL},
   {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS},
+  {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},      
   {"kill-at", no_argument, NULL, OPTION_KILL_ATS},
   {"add-stdcall-alias", no_argument, NULL, OPTION_STDCALL_ALIASES},
   {"enable-stdcall-fixup", no_argument, NULL, OPTION_ENABLE_STDCALL_FIXUP},
@@ -310,24 +335,25 @@ gld_${EMULATION_NAME}_list_options (file)
   fprintf (file, _("  --disable-stdcall-fixup            Don't link _sym to _sym@nn\n"));
   fprintf (file, _("  --enable-stdcall-fixup             Link _sym to _sym@nn without warnings\n"));
   fprintf (file, _("  --exclude-symbols sym,sym,...      Exclude symbols from automatic export\n"));
+  fprintf (file, _("  --exclude-libs lib,lib,...         Exclude libraries from automatic export\n")); 
   fprintf (file, _("  --export-all-symbols               Automatically export all globals to DLL\n"));
   fprintf (file, _("  --kill-at                          Remove @nn from exported symbols\n"));
   fprintf (file, _("  --out-implib <file>                Generate import library\n"));
   fprintf (file, _("  --output-def <file>                Generate a .DEF file for the built DLL\n"));
   fprintf (file, _("  --warn-duplicate-exports           Warn about duplicate exports.\n"));
-  fprintf (file, _("  --compat-implib                    Create backward compatible import libs;\n"));
-  fprintf (file, _("                                       create __imp_<SYMBOL> as well.\n"));
-  fprintf (file, _("  --enable-auto-image-base           Automatically choose image base for DLLs\n"));
-  fprintf (file, _("                                       unless user specifies one\n"));
+  fprintf (file, _("  --compat-implib                    Create backward compatible import libs;\n\
+                                       create __imp_<SYMBOL> as well.\n"));
+  fprintf (file, _("  --enable-auto-image-base           Automatically choose image base for DLLs\n\
+                                       unless user specifies one\n"));
   fprintf (file, _("  --disable-auto-image-base          Do not auto-choose image base. (default)\n"));
-  fprintf (file, _("  --dll-search-prefix=<string>       When linking dynamically to a dll witout an\n"));
-  fprintf (file, _("                                       importlib, use <string><basename>.dll \n"));
-  fprintf (file, _("                                       in preference to lib<basename>.dll \n"));
-  fprintf (file, _("  --enable-auto-import               Do sophistcated linking of _sym to \n"));
-  fprintf (file, _("                                       __imp_sym for DATA references\n"));
+  fprintf (file, _("  --dll-search-prefix=<string>       When linking dynamically to a dll without an\n\
+                                       importlib, use <string><basename>.dll \n\
+                                       in preference to lib<basename>.dll \n"));
+  fprintf (file, _("  --enable-auto-import               Do sophistcated linking of _sym to \n\
+                                       __imp_sym for DATA references\n"));
   fprintf (file, _("  --disable-auto-import              Do not auto-import DATA items from DLLs\n"));
-  fprintf (file, _("  --enable-extra-pe-debug            Enable verbose debug output when building\n"));
-  fprintf (file, _("                                       or linking to DLLs (esp. auto-import)\n"));
+  fprintf (file, _("  --enable-extra-pe-debug            Enable verbose debug output when building\n\
+                                       or linking to DLLs (esp. auto-import)\n"));
 #endif
 }
 
@@ -357,7 +383,7 @@ set_pe_subsystem ()
   const char *sver;
   int len;
   int i;
-  static const struct 
+  static const struct
     {
       const char *name;
       const int value;
@@ -425,12 +451,12 @@ set_pe_subsystem ()
              entry = alc_entry;
            }
 
-         lang_add_entry (entry, 1);
+         lang_add_entry (entry, 0);
 
          return;
        }
     }
-  
+
   einfo (_("%P%F: invalid subsystem type %s\n"), optarg);
 }
 
@@ -439,12 +465,12 @@ set_pe_subsystem ()
 static void
 set_pe_value (name)
      char *name;
-     
+
 {
   char *end;
-  
+
   set_pe_name (name,  strtoul (optarg, &end, 0));
-  
+
   if (end == optarg)
     einfo (_("%P%F: invalid hex number for PE parameter '%s'\n"), optarg);
 
@@ -457,7 +483,7 @@ set_pe_stack_heap (resname, comname)
      char *comname;
 {
   set_pe_value (resname);
-  
+
   if (*optarg == ',')
     {
       optarg++;
@@ -510,10 +536,10 @@ gld_${EMULATION_NAME}_parse_args(argc, argv)
       break;
 
       /* PE options */
-    case OPTION_HEAP: 
+    case OPTION_HEAP:
       set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
       break;
-    case OPTION_STACK: 
+    case OPTION_STACK:
       set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
       break;
     case OPTION_SUBSYSTEM:
@@ -563,7 +589,10 @@ gld_${EMULATION_NAME}_parse_args(argc, argv)
       pe_dll_export_everything = 1;
       break;
     case OPTION_EXCLUDE_SYMBOLS:
-      pe_dll_add_excludes (optarg);
+      pe_dll_add_excludes (optarg, 0);
+      break;
+    case OPTION_EXCLUDE_LIBS:
+      pe_dll_add_excludes (optarg, 1);
       break;
     case OPTION_KILL_ATS:
       pe_dll_kill_ats = 1;
@@ -599,10 +628,10 @@ gld_${EMULATION_NAME}_parse_args(argc, argv)
       pe_dll_do_default_excludes = 0;
       break;
     case OPTION_DLL_ENABLE_AUTO_IMPORT:
-      link_info.pei386_auto_import = true;
+      link_info.pei386_auto_import = 1;
       break;
     case OPTION_DLL_DISABLE_AUTO_IMPORT:
-      link_info.pei386_auto_import = false;
+      link_info.pei386_auto_import = 0;
       break;
     case OPTION_ENABLE_EXTRA_PE_DEBUG:
       pe_dll_extra_pe_debug = 1;
@@ -614,7 +643,7 @@ gld_${EMULATION_NAME}_parse_args(argc, argv)
 \f
 
 #ifdef DLL_SUPPORT
-static unsigned long 
+static unsigned long
 strhash (const char *str)
 {
   const unsigned char *s;
@@ -685,7 +714,8 @@ gld_${EMULATION_NAME}_set_symbols ()
     {
       long val = init[j].value;
       lang_assignment_statement_type *rv;
-      rv = lang_add_assignment (exp_assop ('=' ,init[j].symbol, exp_intop (val)));
+      rv = lang_add_assignment (exp_assop ('=', init[j].symbol,
+                                          exp_intop (val)));
       if (init[j].size == sizeof(short))
        *(short *)init[j].ptr = val;
       else if (init[j].size == sizeof(int))
@@ -701,7 +731,7 @@ gld_${EMULATION_NAME}_set_symbols ()
     }
   /* Restore the pointer. */
   stat_ptr = save;
-  
+
   if (pe.FileAlignment >
       pe.SectionAlignment)
     {
@@ -728,10 +758,17 @@ gld_${EMULATION_NAME}_after_parse ()
      opened, so registering the symbol as undefined will make a
      difference.  */
 
-  if (! link_info.relocateable && entry_symbol != NULL)
-    ldlang_add_undef (entry_symbol);
+  if (! link_info.relocateable && entry_symbol.name != NULL)
+    ldlang_add_undef (entry_symbol.name);
 }
 
+/* pe-dll.c directly accesses pe_data_import_dll,
+   so it must be defined outside of #ifdef DLL_SUPPORT.
+   Note - this variable is deliberately not initialised.
+   This allows it to be treated as a common varaible, and only
+   exist in one incarnation in a multiple target enabled linker.  */
+char * pe_data_import_dll;
+
 #ifdef DLL_SUPPORT
 static struct bfd_link_hash_entry *pe_undef_found_sym;
 
@@ -758,11 +795,11 @@ pe_fixup_stdcalls ()
   static int gave_warning_message = 0;
   struct bfd_link_hash_entry *undef, *sym;
   char *at;
-  if (pe_dll_extra_pe_debug) 
+  if (pe_dll_extra_pe_debug)
     {
       printf ("%s\n", __FUNCTION__);
     }
-  
+
   for (undef = link_info.hash->undefs; undef; undef=undef->next)
     if (undef->type == bfd_link_hash_undefined)
     {
@@ -823,25 +860,39 @@ pe_fixup_stdcalls ()
 }
 
 static int
-make_import_fixup (rel)
+make_import_fixup (rel, s)
   arelent *rel;
+  asection *s;
 {
   struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
-/*
-  bfd *b; 
-*/
 
-  if (pe_dll_extra_pe_debug) 
+  if (pe_dll_extra_pe_debug)
     {
-      printf ("arelent: %s@%#x: add=%li\n", sym->name, 
-              (int) rel->address, rel->addend);
+      printf ("arelent: %s@%#lx: add=%li\n", sym->name,
+              (long) rel->address, (long) rel->addend);
     }
-  pe_create_import_fixup (rel);
+
+  {
+    int addend = 0;
+    if (!bfd_get_section_contents(s->owner, s, &addend, rel->address, sizeof(addend)))
+      {
+        einfo (_("%C: Cannot get section contents - auto-import exception\n"),
+               s->owner, s, rel->address);
+      }
+
+    if (addend == 0)
+      pe_create_import_fixup (rel);
+    else
+      {
+        einfo (_("%C: variable '%T' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.\n"),
+               s->owner, s, rel->address, sym->name);
+        einfo ("%X");
+      }
+  }
+
   return 1;
 }
 
-char *pe_data_import_dll;
-
 static void
 pe_find_data_imports ()
 {
@@ -852,7 +903,7 @@ pe_find_data_imports ()
         {
           /* C++ symbols are *long* */
           char buf[4096];
-          if (pe_dll_extra_pe_debug) 
+          if (pe_dll_extra_pe_debug)
             {
               printf ("%s:%s\n", __FUNCTION__, undef->root.string);
             }
@@ -861,33 +912,34 @@ pe_find_data_imports ()
           sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);
           if (sym && sym->type == bfd_link_hash_defined)
             {
-              einfo (_("Warning: resolving %s by linking to %s (auto-import)\n"),
-                     undef->root.string, buf);
-              {  
+             if (link_info.pei386_auto_import == -1)
+               info_msg (_("Info: resolving %s by linking to %s (auto-import)\n"),
+                      undef->root.string, buf);
+              {
                 bfd *b = sym->u.def.section->owner;
                 asymbol **symbols;
                 int nsyms, symsize, i;
-     
+
                 symsize = bfd_get_symtab_upper_bound (b);
                 symbols = (asymbol **) xmalloc (symsize);
                 nsyms = bfd_canonicalize_symtab (b, symbols);
 
                 for (i = 0; i < nsyms; i++)
                   {
-                    if (memcmp(symbols[i]->name, "__head_", 
+                    if (memcmp(symbols[i]->name, "__head_",
                              sizeof ("__head_") - 1))
                       continue;
                     if (pe_dll_extra_pe_debug)
                       {
                         printf ("->%s\n", symbols[i]->name);
                       }
-                    pe_data_import_dll = (char*) (symbols[i]->name + 
+                    pe_data_import_dll = (char*) (symbols[i]->name +
                                                   sizeof ("__head_") - 1);
                     break;
                   }
               }
 
-              pe_walk_relocs_of_symbol (&link_info, undef->root.string, 
+              pe_walk_relocs_of_symbol (&link_info, undef->root.string,
                                         make_import_fixup);
 
               /* let's differentiate it somehow from defined */
@@ -907,9 +959,9 @@ pe_find_data_imports ()
 static boolean
 pr_sym (h, string)
   struct bfd_hash_entry *h;
-  PTR string;
+  PTR string ATTRIBUTE_UNUSED;
 {
-  if (pe_dll_extra_pe_debug) 
+  if (pe_dll_extra_pe_debug)
     {
       printf("+%s\n",h->string);
     }
@@ -921,7 +973,7 @@ static void
 gld_${EMULATION_NAME}_after_open ()
 {
 
-  if (pe_dll_extra_pe_debug) 
+  if (pe_dll_extra_pe_debug)
     {
       bfd *a;
       struct bfd_link_hash_entry *sym;
@@ -936,12 +988,12 @@ gld_${EMULATION_NAME}_after_open ()
           printf("*%s\n",a->filename);
         }
     }
-  
+
   /* 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) == NULL || coff_data (output_bfd)->pe == NULL)
+
+  if (coff_data (output_bfd) == NULL || coff_data (output_bfd)->pe == 0)
     einfo (_("%F%P: PE operations on non PE file.\n"));
 
   pe_data (output_bfd)->pe_opthdr = pe;
@@ -951,7 +1003,7 @@ gld_${EMULATION_NAME}_after_open ()
   if (pe_enable_stdcall_fixup) /* -1=warn or 1=disable */
     pe_fixup_stdcalls ();
 
-  pe_find_data_imports (output_bfd, &link_info);
+  pe_find_data_imports ();
 
   pe_process_import_defs(output_bfd, &link_info);
   if (link_info.shared)
@@ -1002,7 +1054,7 @@ gld_${EMULATION_NAME}_after_open ()
          {
            int idata2 = 0, reloc_count=0, is_imp = 0;
            asection *sec;
-           
+
            /* See if this is an import library thunk.  */
            for (sec = is->the_bfd->sections; sec; sec = sec->next)
              {
@@ -1012,7 +1064,7 @@ gld_${EMULATION_NAME}_after_open ()
                  is_imp = 1;
                reloc_count += sec->reloc_count;
              }
-           
+
            if (is_imp && !idata2 && reloc_count)
              {
                /* It is, look for the reference to head and see if it's
@@ -1025,22 +1077,22 @@ gld_${EMULATION_NAME}_after_open ()
                    asymbol **symbols;
                    arelent **relocs;
                    int nrelocs;
-                   
+
                    symsize = bfd_get_symtab_upper_bound (is->the_bfd);
                    if (symsize < 1)
                      break;
                    relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec);
                    if (relsize < 1)
                      break;
-                   
+
                    symbols = (asymbol **) xmalloc (symsize);
-                   symsize = bfd_canonicalize_symtab (is->the_bfd, symbols);
+                   symsize = bfd_canonicalize_symtab (is->the_bfd, symbols);
                    if (symsize < 0)
                      {
                        einfo ("%X%P: unable to process symbols: %E");
                        return;
                      }
-                   
+
                    relocs = (arelent **) xmalloc ((size_t) relsize);
                    nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec,
                                                          relocs, symbols);
@@ -1050,39 +1102,39 @@ gld_${EMULATION_NAME}_after_open ()
                        einfo ("%X%P: unable to process relocs: %E");
                        return;
                      }
-                   
+
                    for (i = 0; i < nrelocs; i++)
                      {
                        struct symbol_cache_entry *s;
                        struct bfd_link_hash_entry * blhe;
                        bfd *other_bfd;
                        char *n;
-                       
+
                        s = (relocs[i]->sym_ptr_ptr)[0];
-                       
+
                        if (s->flags & BSF_LOCAL)
                          continue;
-                       
+
                        /* Thunk section with reloc to another bfd.  */
                        blhe = bfd_link_hash_lookup (link_info.hash,
                                                     s->name,
                                                     false, false, true);
-                           
+
                        if (blhe == NULL
                            || blhe->type != bfd_link_hash_defined)
                          continue;
-                       
+
                        other_bfd = blhe->u.def.section->owner;
-                           
+
                        if (strcmp (is->the_bfd->my_archive->filename,
                                    other_bfd->my_archive->filename) == 0)
                          continue;
-                       
+
                        /* Rename this implib to match the other.  */
                        n = (char *) xmalloc (strlen (other_bfd->my_archive->filename) + 1);
-                           
+
                        strcpy (n, other_bfd->my_archive->filename);
-                           
+
                        is->the_bfd->my_archive->filename = n;
                      }
 
@@ -1160,7 +1212,7 @@ gld_${EMULATION_NAME}_after_open ()
   }
 }
 \f
-static void  
+static void
 gld_${EMULATION_NAME}_before_allocation()
 {
 #ifdef TARGET_IS_ppcpe
@@ -1302,7 +1354,7 @@ gld_${EMULATION_NAME}_unrecognized_file(entry)
   }
 #endif
   return false;
-  
+
 }
 
 static boolean
@@ -1341,7 +1393,7 @@ gld_${EMULATION_NAME}_finish ()
   if (thumb_entry_symbol != NULL)
     {
       h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol, false, false, true);
-      
+
       if (h != (struct bfd_link_hash_entry *) NULL
          && (h->type == bfd_link_hash_defined
              || h->type == bfd_link_hash_defweak)
@@ -1349,27 +1401,27 @@ gld_${EMULATION_NAME}_finish ()
        {
          static char buffer[32];
          bfd_vma val;
-         
+
          /* Special procesing is required for a Thumb entry symbol.  The
             bottom bit of its address must be set.  */
          val = (h->u.def.value
                 + bfd_get_section_vma (output_bfd,
                                        h->u.def.section->output_section)
                 + h->u.def.section->output_offset);
-         
+
          val |= 1;
-         
+
          /* Now convert this value into a string and store it in entry_symbol
             where the lang_finish() function will pick it up.  */
          buffer[0] = '0';
          buffer[1] = 'x';
-         
+
          sprintf_vma (buffer + 2, val);
-         
-         if (entry_symbol != NULL && entry_from_cmdline)
+
+         if (entry_symbol.name != NULL && entry_from_cmdline)
            einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
-                  thumb_entry_symbol, entry_symbol);
-         entry_symbol = buffer;
+                  thumb_entry_symbol, entry_symbol.name);
+         entry_symbol.name = buffer;
        }
       else
        einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
@@ -1390,7 +1442,7 @@ gld_${EMULATION_NAME}_finish ()
       pe_exe_fill_sections (output_bfd, &link_info);
     }
 #endif
-  
+
   if (pe_out_def_filename)
     pe_dll_generate_def_file (pe_out_def_filename);
 #endif /* DLL_SUPPORT */
@@ -1568,7 +1620,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
            {
              char *symname;
              etree_type *e_align;
-             
+
              symname = (char *) xmalloc (ps - outsecname + sizeof "___start_");
              sprintf (symname, "___start_%s", outsecname);
              e_align = exp_unop (ALIGN_K,
@@ -1576,7 +1628,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
              lang_add_assignment (exp_assop ('=', symname, e_align));
            }
        }
-      
+
       if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
        address = exp_intop ((bfd_vma) 0);
       else
@@ -1597,7 +1649,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
 
       lang_leave_output_section_statement
        ((bfd_vma) 0, "*default*",
-        (struct lang_output_section_phdr_list *) NULL, "*default*");
+        (struct lang_output_section_phdr_list *) NULL, NULL);
 
       if (config.build_constructors && *ps == '\0')
         {
@@ -1607,7 +1659,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
             stat_ptr back where we want it.  */
          if (place != NULL)
            stat_ptr = &add;
-         
+
          symname = (char *) xmalloc (ps - outsecname + sizeof "___stop_");
          sprintf (symname, "___stop_%s", outsecname);
          lang_add_assignment (exp_assop ('=', symname,
@@ -1616,7 +1668,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
 
       stat_ptr = old;
 
-      if (place != NULL)
+      if (place != NULL && os->bfd_section != NULL)
        {
          asection *snew, **pps;
 
@@ -1641,16 +1693,15 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
 
          if (place->section != NULL)
            {
-             /*  Unlink the section.  */
+             /* Unlink the section.  */
              for (pps = &output_bfd->sections;
                   *pps != snew;
                   pps = &(*pps)->next)
                ;
-             *pps = snew->next;
+             bfd_section_list_remove (output_bfd, pps);
 
              /* Now tack it on to the "place->os" section list.  */
-             snew->next = *place->section;
-             *place->section = snew;
+             bfd_section_list_insert (output_bfd, place->section, snew);
            }
 
          /* Save the end of this list.  Further ophans of this type will
@@ -1755,7 +1806,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
   filename = entry->filename;
 
   string = (char *) xmalloc (strlen (search->name)
-                             + strlen (filename) 
+                             + strlen (filename)
                              + sizeof "/lib.a.dll"
 #ifdef DLL_SUPPORT
                              + (pe_dll_search_prefix ? strlen (pe_dll_search_prefix) : 0)
@@ -1789,7 +1840,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
             {
 #ifdef DLL_SUPPORT
               if (pe_dll_search_prefix)
-                {  
+                {
                   /* Try "<prefix>foo.dll" (preferred dll name, if specified) */
                   sprintf (string, "%s/%s%s.dll", search->name, pe_dll_search_prefix, filename);
                   if (! ldfile_try_open_bfd (string, entry))
@@ -1809,7 +1860,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
                     }
                 }
               else /* pe_dll_search_prefix not specified */
-#endif         
+#endif
                 {
                   /* Try "libfoo.dll" (preferred dll name) */
                   sprintf (string, "%s/lib%s.dll", search->name, filename);
@@ -1850,7 +1901,7 @@ EOF
 sc="-f stringify.sed"
 
 cat >>e${EMULATION_NAME}.c <<EOF
-{                           
+{
   *isfile = 0;
 
   if (link_info.relocateable == true && config.build_constructors == true)
@@ -1870,7 +1921,7 @@ echo '; }'                                                 >> e${EMULATION_NAME}
 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,
@@ -1893,6 +1944,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld_${EMULATION_NAME}_unrecognized_file,
   gld_${EMULATION_NAME}_list_options,
   gld_${EMULATION_NAME}_recognized_file,
-  gld_${EMULATION_NAME}_find_potential_libraries
+  gld_${EMULATION_NAME}_find_potential_libraries,
+  NULL /* new_vers_pattern */
 };
 EOF
This page took 0.035389 seconds and 4 git commands to generate.