bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/30145] No way to specify PE IMAGE_SCN_* characteristics


From: pali at kernel dot org
Subject: [Bug ld/30145] No way to specify PE IMAGE_SCN_* characteristics
Date: Sat, 27 May 2023 12:02:48 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30145

--- Comment #8 from Pali Rohár <pali at kernel dot org> ---
Thank you. I have looked at the change and from documented IMAGE_SCN_* flags at
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format and for dumping
in section_flag_xlat[] are missing: IMAGE_SCN_GPREL, IMAGE_SCN_MEM_16BIT and
IMAGE_SCN_ALIGN_*

And in older version of PE spec are defined also these section characteristics:
#define IMAGE_SCN_TYPE_DSECT     0x00000001  // Reserved.
#define IMAGE_SCN_TYPE_NO_LOAD   0x00000002  // Reserved.
#define IMAGE_SCN_TYPE_GROUPED   0x00000004  // Section is grouped with other
sections by name.
#define IMAGE_SCN_TYPE_COPY      0x00000010  // Reserved.
#define IMAGE_SCN_LNK_OVERLAY    0x00000400  // Section contains an overlay.

Just few weeks ago I sent a patch for readpe to recognizie all known PE machine
types: https://github.com/mentebinaria/readpe/issues/186 So maybe you can reuse
it for decode_machine_number() function.

And I have one other suggestion for string names in section_flag_xlat[].
Constants with prefix IMAGE_SCN_LNK_*, IMAGE_SCN_ALIGN_* and also some
IMAGE_SCN_TYPE_* are something like instructions for linker, so they should not
appear in the final PE executable binary, but only in COFF object files
(without PE header). Maybe it would make sense to print them IMAGE_SCN_LNK_*
with LNK_ prefix? E.g. as  { IMAGE_SCN_LNK_OTHER,       "LNK_OTHER" },

About IMAGE_DOS_SIGNATURE magic, I agree that printing it has no reason as it
is required to be in the DOS header. But what can be interesting is magic
number of Optional Header (after the File/COFF header). It can be either
IMAGE_NT_OPTIONAL_HDR32_MAGIC (0x10b aka PE32), IMAGE_NT_OPTIONAL_HDR64_MAGIC
(0x20b aka PE32+) or IMAGE_ROM_OPTIONAL_HDR_MAGIC (0x107 aka ROM, used in
COFF-only images).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]