bfd
[deliverable/binutils-gdb.git] / ld / pe-dll.c
index 2edfdecb710527a14f82dccb4c3c847d95b9fa3a..8af1b0639049894bdcdd1e8dae96282eed28e8fd 100644 (file)
@@ -144,28 +144,70 @@ static size_t edata_sz, reloc_sz;
 static int runtime_pseudo_relocs_created = 0;
 
 typedef struct
-  {
-    char *target_name;
-    char *object_target;
-    unsigned int imagebase_reloc;
-    int pe_arch;
-    int bfd_arch;
-    int underscored;
-  }
-pe_details_type;
+{
+  char *name;
+  int len;
+}
+autofilter_entry_type;
 
 typedef struct
-  {
-    char *name;
-    int len;
-  }
-autofilter_entry_type;
+{
+  char *target_name;
+  char *object_target;
+  unsigned int imagebase_reloc;
+  int pe_arch;
+  int bfd_arch;
+  bfd_boolean underscored;
+  autofilter_entry_type* autofilter_symbollist; 
+}
+pe_details_type;
 
-#define PE_ARCH_i386   1
-#define PE_ARCH_sh     2
-#define PE_ARCH_mips   3
-#define PE_ARCH_arm    4
+static autofilter_entry_type autofilter_symbollist_generic[] =
+{
+  { ".text", 5 },
+  /* Entry point symbols.  */
+  { "DllMain", 7 },
+  { "DllMainCRTStartup", 17 },
+  { "_DllMainCRTStartup", 18 },
+  /* Runtime pseudo-reloc.  */
+  { "_pei386_runtime_relocator", 25 },
+  { "do_pseudo_reloc", 15 },
+  { NULL, 0 }
+};
+
+static autofilter_entry_type autofilter_symbollist_i386[] =
+{
+  { ".text", 5 },
+  /* Entry point symbols, and entry hooks.  */
+  { "cygwin_crt0", 11 },
+  { "DllMain@12", 10 },
+  { "DllEntryPoint@0", 15 },
+  { "DllMainCRTStartup@12", 20 },
+  { "_cygwin_dll_entry@12", 20 },
+  { "_cygwin_crt0_common@8", 21 },
+  { "_cygwin_noncygwin_dll_entry@12", 30 },
+  { "cygwin_attach_dll", 17 },
+  { "cygwin_premain0", 15 },
+  { "cygwin_premain1", 15 },
+  { "cygwin_premain2", 15 },
+  { "cygwin_premain3", 15 },
+  /* Runtime pseudo-reloc.  */
+  { "_pei386_runtime_relocator", 25 },
+  { "do_pseudo_reloc", 15 },
+  /* Global vars that should not be exported.  */
+  { "impure_ptr", 10 },
+  { "_impure_ptr", 11 },
+  { "_fmode", 6 },
+  { "environ", 7 },
+  { NULL, 0 }
+};
+
+#define PE_ARCH_i386    1
+#define PE_ARCH_sh      2
+#define PE_ARCH_mips    3
+#define PE_ARCH_arm     4
 #define PE_ARCH_arm_epoc 5
+#define PE_ARCH_arm_wince 6
 
 static pe_details_type pe_detail_list[] =
 {
@@ -175,7 +217,8 @@ static pe_details_type pe_detail_list[] =
     7 /* R_IMAGEBASE */,
     PE_ARCH_i386,
     bfd_arch_i386,
-    1
+    TRUE,
+    autofilter_symbollist_i386
   },
   {
     "pei-shl",
@@ -183,7 +226,8 @@ static pe_details_type pe_detail_list[] =
     16 /* R_SH_IMAGEBASE */,
     PE_ARCH_sh,
     bfd_arch_sh,
-    1
+    TRUE,
+    autofilter_symbollist_generic
   },
   {
     "pei-mips",
@@ -191,7 +235,8 @@ static pe_details_type pe_detail_list[] =
     34 /* MIPS_R_RVA */,
     PE_ARCH_mips,
     bfd_arch_mips,
-    0
+    FALSE,
+    autofilter_symbollist_generic
   },
   {
     "pei-arm-little",
@@ -199,7 +244,8 @@ static pe_details_type pe_detail_list[] =
     11 /* ARM_RVA32 */,
     PE_ARCH_arm,
     bfd_arch_arm,
-    1
+    TRUE,
+    autofilter_symbollist_generic
   },
   {
     "epoc-pei-arm-little",
@@ -207,32 +253,23 @@ static pe_details_type pe_detail_list[] =
     11 /* ARM_RVA32 */,
     PE_ARCH_arm_epoc,
     bfd_arch_arm,
-    0
+    FALSE,
+    autofilter_symbollist_generic
+  },
+  {
+    "pei-arm-wince-little",
+    "pe-arm-wince-little",
+    2,  /* ARM_RVA32 on Windows CE, see bfd/coff-arm.c.  */
+    PE_ARCH_arm_wince,
+    bfd_arch_arm,
+    FALSE,
+    autofilter_symbollist_generic
   },
-  { NULL, NULL, 0, 0, 0, 0 }
+  { NULL, NULL, 0, 0, 0, FALSE, NULL }
 };
 
 static pe_details_type *pe_details;
 
-static autofilter_entry_type autofilter_symbollist[] =
-{
-  { "DllMain", 7 },
-  { "DllMainCRTStartup", 17 },
-  { "_DllMainCRTStartup", 18 },
-  { "DllMain@12", 10 },
-  { "DllEntryPoint@0", 15 },
-  { "DllMainCRTStartup@12", 20 },
-  { "_cygwin_dll_entry@12", 20 },
-  { "_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 },
-  { ".text", 5 },
-  { NULL, 0 }
-};
-
 /* Do not specify library suffix explicitly, to allow for dllized versions.  */
 static autofilter_entry_type autofilter_liblist[] =
 {
@@ -269,20 +306,11 @@ static autofilter_entry_type autofilter_symbolprefixlist[] =
   { "__imp_", 6 },
   /* Do __imp_ explicitly to save time.  */
   { "__rtti_", 7 },
-  { ".idata$", 7 },
   /* Don't re-export auto-imported symbols.  */
   { "_nm_", 4 },
   { "__builtin_", 10 },
   /* Don't export symbols specifying internal DLL layout.  */
   { "_head_", 6 },
-  { "_fmode", 6 },
-  { "_impure_ptr", 11 },
-  { "cygwin_attach_dll", 17 },
-  { "cygwin_premain0", 15 },
-  { "cygwin_premain1", 15 },
-  { "cygwin_premain2", 15 },
-  { "cygwin_premain3", 15 },
-  { "environ", 7 },
   { NULL, 0 }
 };
 
@@ -449,10 +477,9 @@ auto_export (bfd *abfd, def_file *d, const char *n)
 
       /* Don't try to blindly exclude all symbols
         that begin with '__'; this was tried and
-        it is too restrictive.  */
-
-      /* Then, exclude specific symbols.  */
-      afptr = autofilter_symbollist;
+        it is too restrictive.  Instead we have
+        a target specific list to use:  */
+      afptr = pe_details->autofilter_symbollist; 
       while (afptr->name)
        {
          if (strcmp (n, afptr->name) == 0)
@@ -1137,13 +1164,8 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
          int nsyms, symsize;
 
          /* If it's not loaded, we don't need to relocate it this way.  */
-#if 0    /* Some toolchains can generate .data sections without a SEC_LOAD flag but with relocs.  */
          if (!(s->output_section->flags & SEC_LOAD))
            continue;
-#endif
-         /* Huh ?  */
-         if (strncmp (bfd_get_section_name (abfd, s), ".idata",6) == 0)
-           continue;
 
          /* I don't know why there would be a reloc for these, but I've
             seen it happen - DJ  */
@@ -1825,6 +1847,8 @@ make_one (def_file_export *exp, bfd *parent)
       jmp_byte_count = sizeof (jmp_mips_bytes);
       break;
     case PE_ARCH_arm:
+    case PE_ARCH_arm_epoc:
+    case PE_ARCH_arm_wince:
       jmp_bytes = jmp_arm_bytes;
       jmp_byte_count = sizeof (jmp_arm_bytes);
       break;
@@ -1902,6 +1926,8 @@ make_one (def_file_export *exp, bfd *parent)
          quick_reloc (abfd, 4, BFD_RELOC_LO16, 2);
          break;
        case PE_ARCH_arm:
+       case PE_ARCH_arm_epoc:
+       case PE_ARCH_arm_wince:
          quick_reloc (abfd, 8, BFD_RELOC_32, 2);
          break;
        default:
This page took 0.025667 seconds and 4 git commands to generate.