* emulparams/elf32_dlx.sh (TARGET_PAGE_SIZE): Set to 1.
[deliverable/binutils-gdb.git] / ld / emultempl / pe.em
index a863526b4fbe2bcf35dd941b5abfa4e9aa628151..37146ab59f843f9e248f9232f3812e269233a16c 100644 (file)
@@ -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
@@ -52,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"
@@ -153,7 +153,6 @@ static char *pe_out_def_filename = NULL;
 static char *pe_implib_filename = NULL;
 static int pe_enable_auto_image_base = 0;
 static char *pe_dll_search_prefix = NULL;
-static char *pe_data_import_dll = NULL;
 #endif
 
 extern const char *output_filename;
@@ -174,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
@@ -222,6 +221,7 @@ 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 */
@@ -248,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},
@@ -334,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
 }
 
@@ -449,7 +451,7 @@ set_pe_subsystem ()
              entry = alc_entry;
            }
 
-         lang_add_entry (entry, 1);
+         lang_add_entry (entry, 0);
 
          return;
        }
@@ -587,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;
@@ -623,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;
@@ -709,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))
@@ -752,27 +758,16 @@ 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);
 }
 
-/* Previously, pe-dll.c directly accessed pe_data_import_dll,
-   which was only defined if DLL_SUPPORT.  This cause a build
-   failure on certain targets. At least this function will
-   exist regardless of whether DLL_SUPPORT is defined or not.
-  
-   However, it's still a kludge.  pe-dll.c shouldn't directly
-   call any functions other than the gld_${EMULATION_NAME}_*.  */
-
-char *
-pe_get_data_import_dll_name ()
-{
-#ifdef DLL_SUPPORT
-  return pe_data_import_dll;
-#else
-  return "unknown";
-#endif
-}
+/* 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;
@@ -917,8 +912,9 @@ 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;
@@ -1422,10 +1418,10 @@ gld_${EMULATION_NAME}_finish ()
 
          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);
@@ -1653,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')
         {
@@ -1672,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;
 
@@ -1697,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
@@ -1949,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.030498 seconds and 4 git commands to generate.