2001-09-11 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / bfd / linker.c
index 54781868e7ab2c837be64f301c5326027abada48..df7ee4b16123bcb81312a15be4f729e7aae7b83e 100644 (file)
@@ -483,6 +483,8 @@ _bfd_link_hash_table_init (table, abfd, newfunc)
   table->creator = abfd->xvec;
   table->undefs = NULL;
   table->undefs_tail = NULL;
+  table->type = bfd_link_generic_hash_table;
+
   return bfd_hash_table_init (&table->table, newfunc);
 }
 
@@ -1003,10 +1005,24 @@ _bfd_generic_link_add_archive_symbols (abfd, info, checkfn)
       arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);
       if (arh == (struct archive_hash_entry *) NULL)
        {
-         pundef = &(*pundef)->next;
-         continue;
-       }
+         /* If we haven't found the exact symbol we're looking for, 
+            let's look for its import thunk */
+         if (info->pei386_auto_import)
+           {
+             char *buf = (char *) bfd_malloc (strlen (h->root.string) + 10);
+             if (buf == NULL)
+               return false;
 
+             sprintf (buf, "__imp_%s", h->root.string);
+             arh = archive_hash_lookup (&arsym_hash, buf, false, false);
+             free(buf);
+           }
+         if (arh == (struct archive_hash_entry *) NULL)
+           {
+             pundef = &(*pundef)->next;
+             continue;
+           }
+       }
       /* Look at all the objects which define this symbol.  */
       for (l = arh->defs; l != (struct archive_list *) NULL; l = l->next)
        {
@@ -1395,7 +1411,7 @@ static const enum link_action link_action[8][8] =
   /* UNDEFW_ROW        */  {WEAK,  NOACT, NOACT, REF,   REF,   NOACT, REFC,  WARNC },
   /* DEF_ROW   */  {DEF,   DEF,   DEF,   MDEF,  DEF,   CDEF,  MDEF,  CYCLE },
   /* DEFW_ROW  */  {DEFW,  DEFW,  DEFW,  NOACT, NOACT, NOACT, NOACT, CYCLE },
-  /* COMMON_ROW        */  {COM,   COM,   COM,   CREF,  CREF,  BIG,   REFC,  WARNC },
+  /* COMMON_ROW        */  {COM,   COM,   COM,   CREF,  COM,   BIG,   REFC,  WARNC },
   /* INDR_ROW  */  {IND,   IND,   IND,   MDEF,  IND,   CIND,  MIND,  CYCLE },
   /* WARN_ROW   */  {MWARN, WARN,  WARN,  CWARN, CWARN, WARN,  CWARN, MWARN },
   /* SET_ROW   */  {SET,   SET,   SET,   SET,   SET,   SET,   CYCLE, CYCLE }
@@ -2645,28 +2661,35 @@ default_fill_link_order (abfd, info, sec, link_order)
      struct bfd_link_order *link_order;
 {
   size_t size;
-  char *space;
+  unsigned char *space;
   size_t i;
-  int fill;
+  unsigned int fill;
+  file_ptr loc;
   boolean result;
 
   BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
 
   size = (size_t) link_order->size;
-  space = (char *) bfd_malloc (size);
-  if (space == NULL && size != 0)
+  if (size == 0)
+    return true;
+
+  space = (unsigned char *) bfd_malloc (size);
+  if (space == NULL)
     return false;
 
   fill = link_order->u.fill.value;
-  for (i = 0; i < size; i += 2)
+  for (i = 0; i < size; i += 4)
+    space[i] = fill >> 24;
+  for (i = 1; i < size; i += 4)
+    space[i] = fill >> 16;
+  for (i = 2; i < size; i += 4)
     space[i] = fill >> 8;
-  for (i = 1; i < size; i += 2)
+  for (i = 3; i < size; i += 4)
     space[i] = fill;
-  result = bfd_set_section_contents (abfd, sec, space,
-                                    (file_ptr)
-                                     (link_order->offset *
-                                      bfd_octets_per_byte (abfd)),
-                                    link_order->size);
+
+  loc = (file_ptr) (link_order->offset * bfd_octets_per_byte (abfd));
+  result = bfd_set_section_contents (abfd, sec, space, loc, link_order->size);
+
   free (space);
   return result;
 }
This page took 0.028009 seconds and 4 git commands to generate.