{
int idx;
- for (idx = 0; idx < 16; idx++)
+ for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
{
/* If data directory is empty, rva also should be 0. */
int size =
extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
- /* First null out all data directory entries. */
- memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory));
-
add_data_entry (abfd, extra, 0, ".edata", ib);
add_data_entry (abfd, extra, 2, ".rsrc", ib);
add_data_entry (abfd, extra, 3, ".pdata", ib);
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
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
if (sec)
{
- bfd_size_type x = sec->rawsize ? sec->rawsize : sec->size;
+ bfd_size_type x = sec->rawsize;
+ bfd_byte *tmp_data = NULL;
+
+ if (x)
+ tmp_data = bfd_malloc (x);
- if (x && bfd_get_section_contents (abfd, sec, pfinfo->contents, 0, x))
+ if (tmp_data != NULL)
{
- qsort (pfinfo->contents,
- (size_t) ((sec->size <x ? sec->size : x) / 12),
- 12, sort_x64_pdata);
- bfd_set_section_contents (pfinfo->output_bfd, sec,
- pfinfo->contents, 0, x);
+ if (bfd_get_section_contents (abfd, sec, tmp_data, 0, x))
+ {
+ qsort (tmp_data,
+ (size_t) (x / 12),
+ 12, sort_x64_pdata);
+ bfd_set_section_contents (pfinfo->output_bfd, sec,
+ tmp_data, 0, x);
+ }
+ free (tmp_data);
}
}
}