From 6785fd72d503fd13bfec31a2897694f1590031eb Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 27 Aug 2023 21:17:05 +0930 Subject: PE dos_message I was looking at dos_message and wondering why we have H_PUT_32 in _bfd_XXi_only_swap_filehdr_out but no H_GET_32 in pe_bfd_object_p. On a big-endian machine this would result in scrambling the code and strings constained in dos_message. Rather than fix the lack of H_GET_32 in pe_bfd_object_p, I decided it doesn't make sense to store dos_message internally as an array of ints. include/ * coff/internal.h (struct internal_extra_pe_filehdr): Make dos_message a char array. * coff/msdos.h (struct external_DOS_hdr): Flatten dos_message. * coff/pe.h (struct external_PEI_filehdr): Likewise. bfd/ * libcoff-in.h (struct pe_tdata): Make dos_message a char array. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): memcpy dos_message to output. * peicode.h (pe_mkobject): Don't memset already zeroed pe_opthdr. Tidy allocation of tdata.pe_obj_data. Set up dos_message from.. (default_dos_message): ..this. New static array. --- include/coff/internal.h | 2 +- include/coff/msdos.h | 2 +- include/coff/pe.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include/coff') diff --git a/include/coff/internal.h b/include/coff/internal.h index 7a566ca..f33817e 100644 --- a/include/coff/internal.h +++ b/include/coff/internal.h @@ -54,7 +54,7 @@ struct internal_extra_pe_filehdr unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */ unsigned short e_res2[10]; /* Reserved words, all 0x0 */ bfd_vma e_lfanew; /* File address of new exe header, 0x80 */ - unsigned int dos_message[16]; /* Text which always follows DOS header. */ + char dos_message[64]; /* Text which always follows DOS header. */ bfd_vma nt_signature; /* required NT signature, 0x4550 */ }; diff --git a/include/coff/msdos.h b/include/coff/msdos.h index b879e45..5f09c76 100644 --- a/include/coff/msdos.h +++ b/include/coff/msdos.h @@ -48,7 +48,7 @@ struct external_DOS_hdr char e_oeminfo[2]; /* OEM information. */ char e_res2[10][2]; /* Reserved words, all 0x0. */ char e_lfanew[4]; /* File address of new exe header, usually 0x80. */ - char dos_message[16][4]; /* Other stuff, always follow DOS header. */ + char dos_message[64]; /* Other stuff, always follow DOS header. */ }; /* The actual DOS header only includes up to the e_ovno field. */ diff --git a/include/coff/pe.h b/include/coff/pe.h index 6b26d53..7e69e6f 100644 --- a/include/coff/pe.h +++ b/include/coff/pe.h @@ -218,7 +218,7 @@ struct external_PEI_filehdr char e_oeminfo[2]; /* OEM information; e_oemid specific, 0x0. */ char e_res2[10][2]; /* Reserved words, all 0x0. */ char e_lfanew[4]; /* File address of new exe header, usually 0x80. */ - char dos_message[16][4]; /* Other stuff, always follow DOS header. */ + char dos_message[64]; /* Other stuff, always follow DOS header. */ /* Note: additional bytes may be inserted before the signature. Use the e_lfanew field to find the actual location of the NT signature. */ -- cgit v1.1