2004-03-23 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / ld / pe-dll.c
index f9417be172a89a721eb6f7e42a2d2c2820fc5975..10d636e544c50034731f3ef1bfc3bef1b25fd24b 100644 (file)
@@ -1,5 +1,6 @@
 /* Routines to help build PEI-format DLLs (Win32 etc)
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Written by DJ Delorie <dj@cygnus.com>
 
    This file is part of GLD, the Gnu Linker.
@@ -25,6 +26,7 @@
 #include "libiberty.h"
 #include "safe-ctype.h"
 
+#include <stdint.h>
 #include <time.h>
 
 #include "ld.h"
@@ -916,8 +918,8 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   int s, hint;
   unsigned char *edirectory;
-  unsigned long *eaddresses;
-  unsigned long *enameptrs;
+  uint32_t *eaddresses;
+  uint32_t *enameptrs;
   unsigned short *eordinals;
   unsigned char *enamestr;
   time_t now;
@@ -928,7 +930,7 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
 
   /* Note use of array pointer math here.  */
   edirectory = edata_d;
-  eaddresses = (unsigned long *) (edata_d + 40);
+  eaddresses = (uint32_t *) (edata_d + 40);
   enameptrs = eaddresses + export_table_size;
   eordinals = (unsigned short *) (enameptrs + count_exported_byname);
   enamestr = (char *) (eordinals + count_exported_byname);
@@ -965,9 +967,9 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
   hint = 0;
   for (s = 0; s < NE; s++)
     {
-      if (pe_def_file->exports[s].ordinal != -1)
+      struct bfd_section *ssec = exported_symbol_sections[s];
+      if (ssec && pe_def_file->exports[s].ordinal != -1)
        {
-         struct bfd_section *ssec = exported_symbol_sections[s];
          unsigned long srva = (exported_symbol_offsets[s]
                                + ssec->output_section->vma
                                + ssec->output_offset);
@@ -1031,7 +1033,7 @@ pe_walk_relocs_of_symbol (struct bfd_link_info *info,
 
          for (i = 0; i < nrelocs; i++)
            {
-             struct symbol_cache_entry *sym = *relocs[i]->sym_ptr_ptr;
+             struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
 
              if (!strcmp (name, sym->name))
                cb (relocs[i], s);
@@ -1112,14 +1114,14 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
            {
              if (pe_dll_extra_pe_debug)
                {
-                 struct symbol_cache_entry *sym = *relocs[i]->sym_ptr_ptr;
+                 struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
                  printf ("rel: %s\n", sym->name);
                }
              if (!relocs[i]->howto->pc_relative
                  && relocs[i]->howto->type != pe_details->imagebase_reloc)
                {
                  bfd_vma sym_vma;
-                 struct symbol_cache_entry *sym = *relocs[i]->sym_ptr_ptr;
+                 struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
 
                  sym_vma = (relocs[i]->addend
                             + sym->value
@@ -1155,7 +1157,12 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
                      total_relocs++;
                      break;
                    case BITS_AND_SHIFT (24, 2):
-                     if (relocs[i]->howto->type == 5)
+                     /* FIXME: 0 is ARM_26D, it is defined in bfd/coff-arm.c
+                        Those ARM_xxx definitions should go in proper
+                        header someday.  */
+                     if (relocs[i]->howto->type == 0
+                         /* Older GNU linkers used 5 instead of 0 for this reloc.  */
+                         || relocs[i]->howto->type == 5)
                        /* This is an ARM_26D reloc, which is an ARM_26 reloc
                           that has already been fully processed during a
                           previous link stage, so ignore it here.  */
@@ -1956,7 +1963,7 @@ make_import_fixup_mark (arelent *rel)
   static char *fixup_name = NULL;
   static size_t buffer_len = 0;
 
-  struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
+  struct bfd_symbol *sym = *rel->sym_ptr_ptr;
 
   bfd *abfd = bfd_asymbol_bfd (sym);
   struct bfd_link_hash_entry *bh;
@@ -2154,7 +2161,7 @@ void
 pe_create_import_fixup (arelent *rel, asection *s, int addend)
 {
   char buf[300];
-  struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
+  struct bfd_symbol *sym = *rel->sym_ptr_ptr;
   struct bfd_link_hash_entry *name_thunk_sym;
   const char *name = sym->name;
   char *fixup_name = make_import_fixup_mark (rel);
@@ -2171,6 +2178,7 @@ pe_create_import_fixup (arelent *rel, asection *s, int addend)
 
       /* If we ever use autoimport, we have to cast text section writable.  */
       config.text_read_only = FALSE;
+      output_bfd->flags &= ~WP_TEXT;   
     }
 
   if (addend == 0 || link_info.pei386_runtime_pseudo_reloc)
@@ -2250,6 +2258,9 @@ pe_dll_generate_implib (def_file *def, const char *impfilename)
       char *internal = def->exports[i].internal_name;
       bfd *n;
 
+      /* Don't add PRIVATE entries to import lib.  */  
+      if (pe_def_file->exports[i].flag_private)
+       continue;
       def->exports[i].internal_name = def->exports[i].name;
       n = make_one (def->exports + i, outarch);
       n->next = head;
This page took 0.049897 seconds and 4 git commands to generate.