Add new devices x1122 x1132 emulation.
[deliverable/binutils-gdb.git] / ld / pe-dll.c
index 45f54e4df010bb18eb76ca1e7390c6c6eee871a5..95cdd7e36c16f9a1b03183f0b7587a4b7b9845df 100644 (file)
@@ -1,5 +1,5 @@
 /* Routines to help build PEI-format DLLs (Win32 etc)
-   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    Written by DJ Delorie <dj@cygnus.com>
 
    This file is part of GLD, the Gnu Linker.
@@ -59,7 +59,7 @@
     code modifications).
 
     2. This is done completely in bounds of the PE specification (to be fair,
-    there's a place where it pokes nose out of, but in practise it works).
+    there's a place where it pokes nose out of, but in practice it works).
     So, resulting module can be used with any other PE compiler/linker.
 
     3. Auto-import is fully compatible with standard import method and they
@@ -74,7 +74,7 @@
 
     The obvious and only way to get rid of dllimport insanity is to make client
     access variable directly in the DLL, bypassing extra dereference. I.e.,
-    whenever client contains someting like
+    whenever client contains something like
 
     mov dll_var,%eax,
 
@@ -82,7 +82,7 @@
     DLL. The aim is to make OS loader do so, and than make ld help with that.
     Import section of PE made following way: there's a vector of structures
     each describing imports from particular DLL. Each such structure points
-    to two other parellel vectors: one holding imported names, and one which
+    to two other parallel vectors: one holding imported names, and one which
     will hold address of corresponding imported name. So, the solution is
     de-vectorize these structures, making import locations be sparse and
     pointing directly into code. Before continuing, it is worth a note that,
     above: PE specification rambles that name vector (OriginalFirstThunk)
     should run in parallel with addresses vector (FirstThunk), i.e. that they
     should have same number of elements and terminated with zero. We violate
-    this, since FirstThunk points directly into machine code. But in practise,
+    this, since FirstThunk points directly into machine code. But in practice,
     OS loader implemented the sane way: it goes thru OriginalFirstThunk and
     puts addresses to FirstThunk, not something else. It once again should be
     noted that dll and symbol name structures are reused across fixup entries
     in windows9x kernel32.dll, so if you use it, you have two
     IMAGE_IMPORT_DESCRIPTORS for kernel32.dll). Yet other question is whether
     referencing the same PE structures several times is valid. The answer is why
-    not, prohibitting that (detecting violation) would require more work on
+    not, prohibiting that (detecting violation) would require more work on
     behalf of loader than not doing it.
 
     See also: ld/emultempl/pe.em.  */
@@ -223,6 +223,9 @@ static autofilter_entry_type autofilter_symbollist[] =
   { "_cygwin_crt0_common@8", 21 },
   { "_cygwin_noncygwin_dll_entry@12", 30 },
   { "impure_ptr", 10 },
+  { "_pei386_runtime_relocator", 25 },
+  { "do_pseudo_reloc", 15 },
+  { "cygwin_crt0", 11 },
   { NULL, 0 }
 };
 
@@ -2015,8 +2018,8 @@ make_import_fixup_mark (rel)
      overflowing this buffer...  */
     {
       free (fixup_name);
-      /* New buffer size is length of symbol, plus 25, but then
-        rounded up to the nearest multiple of 128.  */
+      /* New buffer size is length of symbol, plus 25, but
+        then rounded up to the nearest multiple of 128.  */
       buffer_len = ((strlen (sym->name) + 25) + 127) & ~127;
       fixup_name = (char *) xmalloc (buffer_len);
     }
@@ -2150,7 +2153,7 @@ make_runtime_pseudo_reloc (name, fixup_name, addend, parent)
 }
 
 /*     .section        .rdata
-       .rva            __pei386_runtime_relocator */
+       .rva            __pei386_runtime_relocator  */
 
 static bfd *
 pe_create_runtime_relocator_reference (parent)
@@ -2606,6 +2609,16 @@ pe_implied_import_dll (filename)
      to enable symbolic dll linking.  */
   dll_name = pe_as32 (expdata + 12) + erva;
 
+  /* Check to see if the dll has already been added to
+     the definition list and if so return without error.
+     This avoids multiple symbol definitions.  */
+  if (def_get_module (pe_def_file, dll_name))
+    {
+      if (pe_dll_extra_pe_debug)
+       printf ("%s is already loaded\n", dll_name);
+      return TRUE;
+    }
+
   /* Iterate through the list of symbols.  */
   for (i = 0; i < nexp; i++)
     {
@@ -2627,7 +2640,7 @@ pe_implied_import_dll (filename)
 
          imp = def_file_add_import (pe_def_file, erva + name_rva,
                                     dll_name, i, 0);
-         /* Mark symbole type.  */
+         /* Mark symbol type.  */
          imp->data = is_data;
  
          if (pe_dll_extra_pe_debug)
@@ -2681,7 +2694,7 @@ pe_dll_fill_sections (abfd, info)
 
       /* Resize the sections.  */
       lang_size_sections (stat_ptr->head, abs_output_section,
-                         &stat_ptr->head, 0, (bfd_vma) 0, NULL);
+                         &stat_ptr->head, 0, (bfd_vma) 0, NULL, TRUE);
 
       /* Redo special stuff.  */
       ldemul_after_allocation ();
@@ -2715,7 +2728,7 @@ pe_exe_fill_sections (abfd, info)
 
       /* Resize the sections.  */
       lang_size_sections (stat_ptr->head, abs_output_section,
-                         &stat_ptr->head, 0, (bfd_vma) 0, NULL);
+                         &stat_ptr->head, 0, (bfd_vma) 0, NULL, TRUE);
 
       /* Redo special stuff.  */
       ldemul_after_allocation ();
This page took 0.026384 seconds and 4 git commands to generate.