* regcache.c (regcache_raw_read): If the target didn't supply a
[deliverable/binutils-gdb.git] / bfd / peXXigen.c
index 8f351bacb32780d266c691be834fffc100b0af61..322c5ea8e45946a0538efb08fa6f4c781b98d11d 100644 (file)
@@ -2373,9 +2373,54 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
          result = FALSE;
        }
     }
+  else
+    {
+      h1 = coff_link_hash_lookup (coff_hash_table (info),
+                                 "__IAT_start__", FALSE, FALSE, TRUE);
+      if (h1 != NULL
+         && (h1->root.type == bfd_link_hash_defined
+          || h1->root.type == bfd_link_hash_defweak)
+         && h1->root.u.def.section != NULL
+         && h1->root.u.def.section->output_section != NULL)
+       {
+         bfd_vma iat_va;
+
+         iat_va =
+           (h1->root.u.def.value
+            + h1->root.u.def.section->output_section->vma
+            + h1->root.u.def.section->output_offset);
+
+         h1 = coff_link_hash_lookup (coff_hash_table (info),
+                                     "__IAT_end__", FALSE, FALSE, TRUE);
+         if (h1 != NULL
+             && (h1->root.type == bfd_link_hash_defined
+              || h1->root.type == bfd_link_hash_defweak)
+             && h1->root.u.def.section != NULL
+             && h1->root.u.def.section->output_section != NULL)
+           {
+             pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size =
+               ((h1->root.u.def.value
+                 + h1->root.u.def.section->output_section->vma
+                 + h1->root.u.def.section->output_offset)
+                - iat_va);
+             if (pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size != 0)
+               pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress =
+                 iat_va - pe_data (abfd)->pe_opthdr.ImageBase;
+           }
+         else
+           {
+             _bfd_error_handler
+               (_("%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]"
+                  " because .idata$6 is missing"), abfd);
+             result = FALSE;
+           }
+        }
+    }
 
   h1 = coff_link_hash_lookup (coff_hash_table (info),
-                             "__tls_used", FALSE, FALSE, TRUE);
+                             (bfd_get_symbol_leading_char(abfd) != 0
+                              ? "__tls_used" : "_tls_used"),
+                             FALSE, FALSE, TRUE);
   if (h1 != NULL)
     {
       if ((h1->root.type == bfd_link_hash_defined
@@ -2394,8 +2439,15 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
             abfd);
          result = FALSE;
        }
-
+     /* According to PECOFF sepcifications by Microsoft version 8.2
+       the TLS data directory consists of 4 pointers, followed
+       by two 4-byte integer. This implies that the total size
+       is different for 32-bit and 64-bit executables.  */ 
+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64)
       pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x18;
+#else
+      pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x28;
+#endif
     }
 
 /* If there is a .pdata section and we have linked pdata finally, we
This page took 0.02409 seconds and 4 git commands to generate.