2000-09-12 Kazu Hirata <kazu@hxi.com>
[deliverable/binutils-gdb.git] / ld / pe-dll.c
index 5b2ffe42d9ff5156692419cd579b3b868d844c60..cbd0c495a44ee2eb93c816fdc881c06c97a64ef4 100644 (file)
@@ -34,6 +34,7 @@
 #include "ldmisc.h"
 #include "ldgram.h"
 #include "ldmain.h"
+#include "ldfile.h"
 #include "ldemul.h"
 #include "coff/internal.h"
 #include "../bfd/libcoff.h"
@@ -136,7 +137,8 @@ pe_dll_id_target (target)
 {
   int i;
   for (i=0; pe_detail_list[i].target_name; i++)
-    if (strcmp (pe_detail_list[i].target_name, target) == 0)
+    if (strcmp (pe_detail_list[i].target_name, target) == 0
+       || strcmp (pe_detail_list[i].object_target, target) == 0)
       {
        pe_details = pe_detail_list+i;
        return;
@@ -300,8 +302,7 @@ process_def_file (abfd, info)
 
          for (j = 0; j < nsyms; j++)
            {
-             if ((symbols[j]->flags & (BSF_FUNCTION | BSF_GLOBAL))
-                 == (BSF_FUNCTION | BSF_GLOBAL))
+             if (symbols[j]->flags & BSF_GLOBAL)
                {
                  const char *sn = symbols[j]->name;
                  if (*sn == '_')
@@ -617,15 +618,12 @@ generate_edata (abfd, info)
 
 static void
 fill_exported_offsets (abfd, info)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      struct bfd_link_info *info;
 {
-  int i, j;
+  int i;
   struct bfd_link_hash_entry *blhe;
-  bfd *b;
-  struct sec *s;
-  def_file_export *e=0;
-
+  
   for (i = 0; i < pe_def_file->num_exports; i++)
     {
       char *name = (char *) xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
@@ -1402,12 +1400,12 @@ make_one (exp, parent)
      bfd *parent;
 {
   asection *tx, *id7, *id5, *id4, *id6;
-  unsigned char *td, *d7, *d5, *d4, *d6;
+  unsigned char *td, *d7, *d5, *d4, *d6 = NULL;
   int len;
   char *oname;
   bfd *abfd;
-  unsigned char *jmp_bytes;
-  int jmp_byte_count;
+  unsigned char *jmp_bytes = NULL;
+  int jmp_byte_count = 0;
 
   switch (pe_details->pe_arch)
     {
@@ -1446,7 +1444,7 @@ make_one (exp, parent)
   if (! exp->flag_data)
     quick_symbol (abfd, U(""), exp->internal_name, "", tx, BSF_GLOBAL, 0);
   quick_symbol (abfd, U("_head_"), dll_symname, "", UNDSEC, BSF_GLOBAL, 0);
-  quick_symbol (abfd, U("__imp_"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
+  quick_symbol (abfd, U("_imp__"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
   if (pe_dll_compat_implib)
     quick_symbol (abfd, U("__imp_"), exp->internal_name, "", 
                   id5, BSF_GLOBAL, 0);
@@ -1663,10 +1661,17 @@ pe_process_import_defs (output_bfd, link_info)
            struct bfd_link_hash_entry *blhe;
 
            /* see if we need this import */
-           char *name = (char *) xmalloc (strlen (pe_def_file->imports[i].internal_name) + 2);
+           char *name = (char *) xmalloc (strlen (pe_def_file->imports[i].internal_name) + 2 + 6);
            sprintf (name, "%s%s", U(""), pe_def_file->imports[i].internal_name);
            blhe = bfd_link_hash_lookup (link_info->hash, name,
                                         false, false, false);
+           if (!blhe || (blhe && blhe->type != bfd_link_hash_undefined))
+             {
+               sprintf (name, "%s%s", U("_imp__"),
+                        pe_def_file->imports[i].internal_name);
+               blhe = bfd_link_hash_lookup (link_info->hash, name,
+                                            false, false, false);
+             }
            free (name);
            if (blhe && blhe->type == bfd_link_hash_undefined)
              {
This page took 0.024552 seconds and 4 git commands to generate.