mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
Improve objdump's display of PE header information.
PR 31953
This commit is contained in:
parent
85402ee9ed
commit
91b999864f
@ -492,7 +492,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
|
|||||||
a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
|
a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
|
||||||
a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
|
a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
|
||||||
a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
|
a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
|
||||||
a->Reserved1 = H_GET_32 (abfd, src->Reserved1);
|
a->Win32Version = H_GET_32 (abfd, src->Win32Version);
|
||||||
a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
|
a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
|
||||||
a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
|
a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
|
||||||
a->CheckSum = H_GET_32 (abfd, src->CheckSum);
|
a->CheckSum = H_GET_32 (abfd, src->CheckSum);
|
||||||
@ -755,7 +755,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
|
|||||||
aouthdr_out->MajorSubsystemVersion);
|
aouthdr_out->MajorSubsystemVersion);
|
||||||
H_PUT_16 (abfd, extra->MinorSubsystemVersion,
|
H_PUT_16 (abfd, extra->MinorSubsystemVersion,
|
||||||
aouthdr_out->MinorSubsystemVersion);
|
aouthdr_out->MinorSubsystemVersion);
|
||||||
H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1);
|
H_PUT_32 (abfd, extra->Win32Version, aouthdr_out->Win32Version);
|
||||||
H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
|
H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
|
||||||
H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
|
H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
|
||||||
H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
|
H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
|
||||||
@ -2849,7 +2849,7 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile)
|
|||||||
fprintf (file, "MinorImageVersion\t%d\n", i->MinorImageVersion);
|
fprintf (file, "MinorImageVersion\t%d\n", i->MinorImageVersion);
|
||||||
fprintf (file, "MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
|
fprintf (file, "MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
|
||||||
fprintf (file, "MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
|
fprintf (file, "MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
|
||||||
fprintf (file, "Win32Version\t\t%08x\n", i->Reserved1);
|
fprintf (file, "Win32Version\t\t%08x\n", i->Win32Version);
|
||||||
fprintf (file, "SizeOfImage\t\t%08x\n", i->SizeOfImage);
|
fprintf (file, "SizeOfImage\t\t%08x\n", i->SizeOfImage);
|
||||||
fprintf (file, "SizeOfHeaders\t\t%08x\n", i->SizeOfHeaders);
|
fprintf (file, "SizeOfHeaders\t\t%08x\n", i->SizeOfHeaders);
|
||||||
fprintf (file, "CheckSum\t\t%08x\n", i->CheckSum);
|
fprintf (file, "CheckSum\t\t%08x\n", i->CheckSum);
|
||||||
|
@ -227,6 +227,17 @@ pe_filter (bfd *abfd)
|
|||||||
return bfd_get_flavour (abfd) == bfd_target_coff_flavour;
|
return bfd_get_flavour (abfd) == bfd_target_coff_flavour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return string representation of the platform id
|
||||||
|
stored in upper 2 bits of Win32Version field. */
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
pe_platform_id_str (unsigned int platform_id)
|
||||||
|
{
|
||||||
|
static const char *const platform_id_str_table[4] =
|
||||||
|
{ "WinNT", "WinCE", "Win32s", "Win9x" };
|
||||||
|
return platform_id_str_table[platform_id & 0x3];
|
||||||
|
}
|
||||||
|
|
||||||
/* Display the list of name (from TABLE) for FLAGS, using comma to
|
/* Display the list of name (from TABLE) for FLAGS, using comma to
|
||||||
separate them. A name is displayed if FLAGS & VAL is not 0. */
|
separate them. A name is displayed if FLAGS & VAL is not 0. */
|
||||||
|
|
||||||
@ -424,8 +435,10 @@ dump_pe_file_header (bfd * abfd,
|
|||||||
printf (_("Magic:\t\t\t\t%x\t\t- %s\n"), data,
|
printf (_("Magic:\t\t\t\t%x\t\t- %s\n"), data,
|
||||||
data == 0x020b ? "PE32+" : _("Unknown"));
|
data == 0x020b ? "PE32+" : _("Unknown"));
|
||||||
|
|
||||||
printf (_("Version:\t\t\t%x\n"),
|
printf (_("Linker Version:\t\t\t%x\t\t- %u.%02u\n"),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.standard.vstamp));
|
(int) bfd_h_get_16 (abfd, xhdr.standard.vstamp),
|
||||||
|
(int) (bfd_h_get_16 (abfd, xhdr.standard.vstamp) & 0xff),
|
||||||
|
(int) (bfd_h_get_16 (abfd, xhdr.standard.vstamp) >> 8));
|
||||||
|
|
||||||
printf (_("Text Size:\t\t\t%#lx\n"),
|
printf (_("Text Size:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.standard.tsize));
|
(long) bfd_h_get_32 (abfd, xhdr.standard.tsize));
|
||||||
@ -448,18 +461,33 @@ dump_pe_file_header (bfd * abfd,
|
|||||||
(long) bfd_h_get_32 (abfd, xhdr.SectionAlignment));
|
(long) bfd_h_get_32 (abfd, xhdr.SectionAlignment));
|
||||||
printf (_("File Alignment:\t\t\t%#lx\n"),
|
printf (_("File Alignment:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.FileAlignment));
|
(long) bfd_h_get_32 (abfd, xhdr.FileAlignment));
|
||||||
printf (_("Major OS Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorOperatingSystemVersion));
|
printf (_("Image Version:\t\t\t%lx\t\t- %u.%02u\n"),
|
||||||
printf (_("Minor OS ersion:\t\t%d\n"),
|
(long) bfd_h_get_32 (abfd, xhdr.MajorImageVersion),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorOperatingSystemVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MajorImageVersion),
|
||||||
printf (_("Major Image Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorImageVersion));
|
|
||||||
printf (_("Minor Image Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorImageVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MinorImageVersion));
|
||||||
printf (_("Major Subsystem Version:\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorSubsystemVersion));
|
printf (_("Minimal Subsystem Version:\t%lx\t\t- %u.%02u\n"),
|
||||||
printf (_("Minor Subsystem Version:\t%d\n"),
|
(long) bfd_h_get_32 (abfd, xhdr.MajorSubsystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MajorSubsystemVersion),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorSubsystemVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MinorSubsystemVersion));
|
||||||
|
|
||||||
|
printf (_("Minimal OS Version:\t\t%lx\t\t- %u.%02u\n"),
|
||||||
|
(long) bfd_h_get_32 (abfd, xhdr.MajorOperatingSystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MajorOperatingSystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MinorOperatingSystemVersion));
|
||||||
|
|
||||||
|
printf (_("Overwrite OS Version:\t\t%lx\t\t- "),
|
||||||
|
(long) bfd_h_get_32 (abfd, xhdr.Win32Version));
|
||||||
|
if (bfd_h_get_32 (abfd, xhdr.Win32Version) == 0)
|
||||||
|
printf (_("(default)\n"));
|
||||||
|
else
|
||||||
|
printf (_("%u.%02u (build %u, platform %s)\n"),
|
||||||
|
((int) (bfd_h_get_32 (abfd, xhdr.Win32Version) & 0xff)),
|
||||||
|
((int) ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 8) & 0xff)),
|
||||||
|
((int) ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 16) & 0x3fff)),
|
||||||
|
pe_platform_id_str ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 30) & 0x3));
|
||||||
|
|
||||||
printf (_("Size Of Image:\t\t\t%#lx\n"),
|
printf (_("Size Of Image:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.SizeOfImage));
|
(long) bfd_h_get_32 (abfd, xhdr.SizeOfImage));
|
||||||
printf (_("Size Of Headers:\t\t%#lx\n"),
|
printf (_("Size Of Headers:\t\t%#lx\n"),
|
||||||
@ -509,8 +537,10 @@ dump_pe_file_header (bfd * abfd,
|
|||||||
printf (_("Magic:\t\t\t\t%x\t\t- %s\n"), data,
|
printf (_("Magic:\t\t\t\t%x\t\t- %s\n"), data,
|
||||||
data == 0x010b ? "PE32" : _("Unknown"));
|
data == 0x010b ? "PE32" : _("Unknown"));
|
||||||
|
|
||||||
printf (_("Version:\t\t\t%x\n"),
|
printf (_("Linker Version:\t\t\t%x\t\t- %u.%02u\n"),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.standard.vstamp));
|
(int) bfd_h_get_16 (abfd, xhdr.standard.vstamp),
|
||||||
|
(int) (bfd_h_get_16 (abfd, xhdr.standard.vstamp) & 0xff),
|
||||||
|
(int) (bfd_h_get_16 (abfd, xhdr.standard.vstamp) >> 8));
|
||||||
|
|
||||||
printf (_("Text Size:\t\t\t%#lx\n"),
|
printf (_("Text Size:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.standard.tsize));
|
(long) bfd_h_get_32 (abfd, xhdr.standard.tsize));
|
||||||
@ -544,18 +574,33 @@ dump_pe_file_header (bfd * abfd,
|
|||||||
(long) bfd_h_get_32 (abfd, xhdr.SectionAlignment));
|
(long) bfd_h_get_32 (abfd, xhdr.SectionAlignment));
|
||||||
printf (_("File Alignment:\t\t\t%#lx\n"),
|
printf (_("File Alignment:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.FileAlignment));
|
(long) bfd_h_get_32 (abfd, xhdr.FileAlignment));
|
||||||
printf (_("Major OS Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorOperatingSystemVersion));
|
printf (_("Image Version:\t\t\t%lx\t\t- %u.%02u\n"),
|
||||||
printf (_("Minor OS ersion:\t\t%d\n"),
|
(long) bfd_h_get_32 (abfd, xhdr.MajorImageVersion),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorOperatingSystemVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MajorImageVersion),
|
||||||
printf (_("Major Image Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorImageVersion));
|
|
||||||
printf (_("Minor Image Version:\t\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorImageVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MinorImageVersion));
|
||||||
printf (_("Major Subsystem Version:\t%d\n"),
|
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MajorSubsystemVersion));
|
printf (_("Minimal Subsystem Version:\t%lx\t\t- %u.%02u\n"),
|
||||||
printf (_("Minor Subsystem Version:\t%d\n"),
|
(long) bfd_h_get_32 (abfd, xhdr.MajorSubsystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MajorSubsystemVersion),
|
||||||
(int) bfd_h_get_16 (abfd, xhdr.MinorSubsystemVersion));
|
(int) bfd_h_get_16 (abfd, xhdr.MinorSubsystemVersion));
|
||||||
|
|
||||||
|
printf (_("Minimal OS Version:\t\t%lx\t\t- %u.%02u\n"),
|
||||||
|
(long) bfd_h_get_32 (abfd, xhdr.MajorOperatingSystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MajorOperatingSystemVersion),
|
||||||
|
(int) bfd_h_get_16 (abfd, xhdr.MinorOperatingSystemVersion));
|
||||||
|
|
||||||
|
printf (_("Overwrite OS Version:\t\t%lx\t\t- "),
|
||||||
|
(long) bfd_h_get_32 (abfd, xhdr.Win32Version));
|
||||||
|
if (bfd_h_get_32 (abfd, xhdr.Win32Version) == 0)
|
||||||
|
printf (_("(default)\n"));
|
||||||
|
else
|
||||||
|
printf (_("%u.%02u (build %u, platform %s)\n"),
|
||||||
|
((int) (bfd_h_get_32 (abfd, xhdr.Win32Version) & 0xff)),
|
||||||
|
((int) ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 8) & 0xff)),
|
||||||
|
((int) ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 16) & 0x3fff)),
|
||||||
|
pe_platform_id_str ((bfd_h_get_32 (abfd, xhdr.Win32Version) >> 30) & 0x3));
|
||||||
|
|
||||||
printf (_("Size Of Image:\t\t\t%#lx\n"),
|
printf (_("Size Of Image:\t\t\t%#lx\n"),
|
||||||
(long) bfd_h_get_32 (abfd, xhdr.SizeOfImage));
|
(long) bfd_h_get_32 (abfd, xhdr.SizeOfImage));
|
||||||
printf (_("Size Of Headers:\t\t%#lx\n"),
|
printf (_("Size Of Headers:\t\t%#lx\n"),
|
||||||
|
@ -215,7 +215,7 @@ struct internal_extra_pe_aouthdr
|
|||||||
short MinorImageVersion; /* exe or dll being created, default to 0. */
|
short MinorImageVersion; /* exe or dll being created, default to 0. */
|
||||||
short MajorSubsystemVersion; /* Minimum subsystem version required to */
|
short MajorSubsystemVersion; /* Minimum subsystem version required to */
|
||||||
short MinorSubsystemVersion; /* run exe; default to 3.1. */
|
short MinorSubsystemVersion; /* run exe; default to 3.1. */
|
||||||
uint32_t Reserved1; /* Seems to be 0. */
|
uint32_t Win32Version; /* Set to 0. */
|
||||||
uint32_t SizeOfImage; /* Size of memory to allocate for prog. */
|
uint32_t SizeOfImage; /* Size of memory to allocate for prog. */
|
||||||
uint32_t SizeOfHeaders; /* Size of PE header and section table. */
|
uint32_t SizeOfHeaders; /* Size of PE header and section table. */
|
||||||
uint32_t CheckSum; /* Set to 0. */
|
uint32_t CheckSum; /* Set to 0. */
|
||||||
|
@ -264,7 +264,7 @@ typedef struct
|
|||||||
char MinorImageVersion[2];
|
char MinorImageVersion[2];
|
||||||
char MajorSubsystemVersion[2];
|
char MajorSubsystemVersion[2];
|
||||||
char MinorSubsystemVersion[2];
|
char MinorSubsystemVersion[2];
|
||||||
char Reserved1[4];
|
char Win32Version[4];
|
||||||
char SizeOfImage[4];
|
char SizeOfImage[4];
|
||||||
char SizeOfHeaders[4];
|
char SizeOfHeaders[4];
|
||||||
char CheckSum[4];
|
char CheckSum[4];
|
||||||
@ -303,7 +303,7 @@ typedef struct
|
|||||||
char MinorImageVersion[2];
|
char MinorImageVersion[2];
|
||||||
char MajorSubsystemVersion[2];
|
char MajorSubsystemVersion[2];
|
||||||
char MinorSubsystemVersion[2];
|
char MinorSubsystemVersion[2];
|
||||||
char Reserved1[4];
|
char Win32Version[4];
|
||||||
char SizeOfImage[4];
|
char SizeOfImage[4];
|
||||||
char SizeOfHeaders[4];
|
char SizeOfHeaders[4];
|
||||||
char CheckSum[4];
|
char CheckSum[4];
|
||||||
|
Loading…
Reference in New Issue
Block a user