* 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.
This commit is contained in:
parent
edec3111a2
commit
b9110a3c4f
|
@ -5,6 +5,14 @@ Thu Jun 20 18:14:25 1996 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
Thu Jun 20 11:00:57 1996 Doug Evans <dje@canuck.cygnus.com>
|
Thu Jun 20 11:00:57 1996 Doug Evans <dje@canuck.cygnus.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
* peicode.h (coff_swap_scnhdr_out): ".drectve" doesn't have trailing 0.
|
* peicode.h (coff_swap_scnhdr_out): ".drectve" doesn't have trailing 0.
|
||||||
|
|
||||||
Wed Jun 19 11:37:52 1996 Ian Lance Taylor <ian@cygnus.com>
|
Wed Jun 19 11:37:52 1996 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
|
@ -1110,6 +1110,36 @@ coff_set_alignment_hook (abfd, section, scnhdr)
|
||||||
section->alignment_power = 2;
|
section->alignment_power = 2;
|
||||||
}
|
}
|
||||||
#endif
|
#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 ALIGN_SET
|
||||||
#undef ELIFALIGN_SET
|
#undef ELIFALIGN_SET
|
||||||
|
@ -1469,6 +1499,17 @@ coff_set_arch_mach_hook (abfd, filehdr)
|
||||||
break;
|
break;
|
||||||
#endif
|
#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
|
#ifdef SH_ARCH_MAGIC_BIG
|
||||||
case SH_ARCH_MAGIC_BIG:
|
case SH_ARCH_MAGIC_BIG:
|
||||||
case SH_ARCH_MAGIC_LITTLE:
|
case SH_ARCH_MAGIC_LITTLE:
|
||||||
|
@ -1919,6 +1960,11 @@ coff_set_flags (abfd, magicp, flagsp)
|
||||||
case bfd_mach_h8300h:
|
case bfd_mach_h8300h:
|
||||||
*magicp = H8300HMAGIC;
|
*magicp = H8300HMAGIC;
|
||||||
return true;
|
return true;
|
||||||
|
/* start-sanitize-h8s */
|
||||||
|
case bfd_mach_h8300s:
|
||||||
|
*magicp = H8300SMAGIC;
|
||||||
|
return true;
|
||||||
|
/* end-sanitize-h8s */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2140,10 +2186,33 @@ coff_compute_section_file_positions (abfd)
|
||||||
#endif
|
#endif
|
||||||
current->filepos = sofar;
|
current->filepos = sofar;
|
||||||
|
|
||||||
#ifdef COFF_IMAGE_WITH_PE
|
#ifdef COFF_WITH_PE
|
||||||
/* With PE we have to pad each section to be a multiple of its page size
|
/* With PE we have to pad each section to be a multiple of its
|
||||||
too, and remember both sizes. Cooked_size becomes very useful. */
|
page size too, and remember both sizes. */
|
||||||
current->_cooked_size = current->_raw_size;
|
|
||||||
|
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;
|
current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2269,6 +2338,7 @@ coff_write_object_contents (abfd)
|
||||||
file_ptr sym_base;
|
file_ptr sym_base;
|
||||||
unsigned long reloc_size = 0;
|
unsigned long reloc_size = 0;
|
||||||
unsigned long lnno_size = 0;
|
unsigned long lnno_size = 0;
|
||||||
|
boolean long_section_names;
|
||||||
asection *text_sec = NULL;
|
asection *text_sec = NULL;
|
||||||
asection *data_sec = NULL;
|
asection *data_sec = NULL;
|
||||||
asection *bss_sec = NULL;
|
asection *bss_sec = NULL;
|
||||||
|
@ -2343,6 +2413,7 @@ coff_write_object_contents (abfd)
|
||||||
if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
|
if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
long_section_names = false;
|
||||||
for (current = abfd->sections;
|
for (current = abfd->sections;
|
||||||
current != NULL;
|
current != NULL;
|
||||||
current = current->next)
|
current = current->next)
|
||||||
|
@ -2376,6 +2447,7 @@ coff_write_object_contents (abfd)
|
||||||
memset (section.s_name, 0, SCNNMLEN);
|
memset (section.s_name, 0, SCNNMLEN);
|
||||||
sprintf (section.s_name, "/%lu", (unsigned long) string_size);
|
sprintf (section.s_name, "/%lu", (unsigned long) string_size);
|
||||||
string_size += len + 1;
|
string_size += len + 1;
|
||||||
|
long_section_names = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2392,7 +2464,12 @@ coff_write_object_contents (abfd)
|
||||||
section.s_size = current->_raw_size;
|
section.s_size = current->_raw_size;
|
||||||
|
|
||||||
#ifdef COFF_WITH_PE
|
#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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2763,7 +2840,10 @@ coff_write_object_contents (abfd)
|
||||||
}
|
}
|
||||||
else
|
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;
|
internal_f.f_flags |= F_LSYMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,34 @@ Most of this hacked by Steve Chamberlain,
|
||||||
sac@cygnus.com
|
sac@cygnus.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Hey look, some documentation [and in a place you expect to find it]!
|
||||||
|
|
||||||
|
The main reference for the pei format is "Microsoft Portable Executable
|
||||||
|
and Common Object File Format Specification 4.1". Get it if you need to
|
||||||
|
do some serious hacking on this code.
|
||||||
|
|
||||||
|
Another reference:
|
||||||
|
"Peering Inside the PE: A Tour of the Win32 Portable Executable
|
||||||
|
File Format", MSJ 1994, Volume 9.
|
||||||
|
|
||||||
|
The *sole* difference between the pe format and the pei format is that the
|
||||||
|
latter has an MSDOS 2.0 .exe header on the front that prints the message
|
||||||
|
"This app must be run under Windows." (or some such).
|
||||||
|
(FIXME: Whether that statement is *really* true or not is unknown.
|
||||||
|
Are there more subtle differences between pe and pei formats?
|
||||||
|
For now assume there aren't. If you find one, then for God sakes
|
||||||
|
document it here!)
|
||||||
|
|
||||||
|
The Microsoft docs use the word "image" instead of "executable" because
|
||||||
|
the former can also refer to a DLL (shared library). Confusion can arise
|
||||||
|
because the `i' in `pei' also refers to "image". The `pe' format can
|
||||||
|
also create images (i.e. executables), it's just that to run on a win32
|
||||||
|
system you need to use the pei format.
|
||||||
|
|
||||||
|
FIXME: Please add more docs here so the next poor fool that has to hack
|
||||||
|
on this code has a chance of getting something accomplished without
|
||||||
|
wasting too much time.
|
||||||
|
*/
|
||||||
|
|
||||||
#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
|
#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
|
||||||
#define coff_mkobject pe_mkobject
|
#define coff_mkobject pe_mkobject
|
||||||
|
@ -1870,8 +1897,6 @@ pe_bfd_copy_private_bfd_data (ibfd, obfd)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COFF_IMAGE_WITH_PE
|
|
||||||
|
|
||||||
/* Copy private section data. */
|
/* Copy private section data. */
|
||||||
|
|
||||||
#define coff_bfd_copy_private_section_data pe_bfd_copy_private_section_data
|
#define coff_bfd_copy_private_section_data pe_bfd_copy_private_section_data
|
||||||
|
@ -1909,5 +1934,3 @@ pe_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue