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.
This commit is contained in:
Alan Modra
2023-08-27 21:17:05 +09:30
parent 8606b47e94
commit 6785fd72d5
7 changed files with 21 additions and 34 deletions

View File

@@ -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 */
};

View File

@@ -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. */

View File

@@ -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. */