aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>1996-06-20 23:59:08 +0000
committerDavid Edelsohn <dje.gcc@gmail.com>1996-06-20 23:59:08 +0000
commitb9110a3c4f394a498400b729b866a2f31b0ab851 (patch)
tree14c8fb9758734a18fc3a7eb27a7bcdfe0c518f91 /bfd/coffcode.h
parentedec3111a27452b101fa566d2f4a0447dedf8132 (diff)
downloadgdb-b9110a3c4f394a498400b729b866a2f31b0ab851.zip
gdb-b9110a3c4f394a498400b729b866a2f31b0ab851.tar.gz
gdb-b9110a3c4f394a498400b729b866a2f31b0ab851.tar.bz2
* coffcode.h (coff_set_alignment_hook): Change COFF_IMAGE_WITH_PE
ifdef to COFF_WITH_PE. (coff_compute_section_file_positions): Likewise. (coff_write_object_contents): Likewise. Delete COFF_OBJ_WITH_PE. * pe-{arm,i386,ppc}.c (COFF_OBJ_WITH_PE): Delete. * peicode.h (pe_bfd_copy_private_bfd_data): Delete ifdef COFF_IMAGE_WITH_PE, always include.
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h92
1 files changed, 86 insertions, 6 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 82447d3..af8a49f 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1110,6 +1110,36 @@ coff_set_alignment_hook (abfd, section, scnhdr)
section->alignment_power = 2;
}
#endif
+
+#ifdef COFF_WITH_PE
+ /* In a PE image file, the s_paddr field holds the virtual size of a
+ section, while the s_size field holds the raw size. */
+ if (hdr->s_paddr != 0)
+ {
+ if (coff_section_data (abfd, section) == NULL)
+ {
+ section->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (section->used_by_bfd == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, section) == NULL)
+ {
+ coff_section_data (abfd, section)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, section)->tdata == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
+ }
+#endif
+
}
#undef ALIGN_SET
#undef ELIFALIGN_SET
@@ -1469,6 +1499,17 @@ coff_set_arch_mach_hook (abfd, filehdr)
break;
#endif
+/* start-sanitize-h8s */
+#ifdef H8300SMAGIC
+ case H8300SMAGIC:
+ arch = bfd_arch_h8300;
+ machine = bfd_mach_h8300s;
+ /* !! FIXME this probably isn't the right place for this */
+ abfd->flags |= BFD_IS_RELAXABLE;
+ break;
+#endif
+
+/* end-sanitize-h8s */
#ifdef SH_ARCH_MAGIC_BIG
case SH_ARCH_MAGIC_BIG:
case SH_ARCH_MAGIC_LITTLE:
@@ -1919,6 +1960,11 @@ coff_set_flags (abfd, magicp, flagsp)
case bfd_mach_h8300h:
*magicp = H8300HMAGIC;
return true;
+/* start-sanitize-h8s */
+ case bfd_mach_h8300s:
+ *magicp = H8300SMAGIC;
+ return true;
+/* end-sanitize-h8s */
}
break;
#endif
@@ -2140,10 +2186,33 @@ coff_compute_section_file_positions (abfd)
#endif
current->filepos = sofar;
-#ifdef COFF_IMAGE_WITH_PE
- /* With PE we have to pad each section to be a multiple of its page size
- too, and remember both sizes. Cooked_size becomes very useful. */
- current->_cooked_size = current->_raw_size;
+#ifdef COFF_WITH_PE
+ /* With PE we have to pad each section to be a multiple of its
+ page size too, and remember both sizes. */
+
+ if (coff_section_data (abfd, current) == NULL)
+ {
+ current->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (current->used_by_bfd == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, current) == NULL)
+ {
+ coff_section_data (abfd, current)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, current)->tdata == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, current)->virt_size == 0)
+ pei_section_data (abfd, current)->virt_size = current->_raw_size;
+
current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
#endif
@@ -2269,6 +2338,7 @@ coff_write_object_contents (abfd)
file_ptr sym_base;
unsigned long reloc_size = 0;
unsigned long lnno_size = 0;
+ boolean long_section_names;
asection *text_sec = NULL;
asection *data_sec = NULL;
asection *bss_sec = NULL;
@@ -2343,6 +2413,7 @@ coff_write_object_contents (abfd)
if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
return false;
+ long_section_names = false;
for (current = abfd->sections;
current != NULL;
current = current->next)
@@ -2376,6 +2447,7 @@ coff_write_object_contents (abfd)
memset (section.s_name, 0, SCNNMLEN);
sprintf (section.s_name, "/%lu", (unsigned long) string_size);
string_size += len + 1;
+ long_section_names = true;
}
}
#endif
@@ -2392,7 +2464,12 @@ coff_write_object_contents (abfd)
section.s_size = current->_raw_size;
#ifdef COFF_WITH_PE
- section.s_paddr = current->_cooked_size;
+ /* Reminder: s_paddr holds the virtual size of the section. */
+ if (coff_section_data (abfd, current) != NULL
+ && pei_section_data (abfd, current) != NULL)
+ section.s_paddr = pei_section_data (abfd, current)->virt_size;
+ else
+ section.s_paddr = 0;
#endif
/*
@@ -2763,7 +2840,10 @@ coff_write_object_contents (abfd)
}
else
{
- internal_f.f_symptr = 0;
+ if (long_section_names)
+ internal_f.f_symptr = sym_base;
+ else
+ internal_f.f_symptr = 0;
internal_f.f_flags |= F_LSYMS;
}