BaseTools/GenFw: Parse IBT/BTI support status from ELF note

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4405

When performing ELF to PE/COFF conversion, parse any notes sections to
decide whether the image supports forward CFI landing pads. This will be
used to set the associated DllCharacteristicsEx flag in a subsequent
patch.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Ard Biesheuvel
2023-03-26 10:38:01 +02:00
committed by mergify[bot]
parent cdf6ff1719
commit 6c299acf48
2 changed files with 59 additions and 0 deletions

View File

@@ -59,6 +59,15 @@ typedef struct {
UINT32 n_type; /* Type of this note. */
} Elf_Note;
#define NT_GNU_PROPERTY_TYPE_0 5
#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
#define GNU_PROPERTY_X86_FEATURE_1_IBT 0x1
#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x1
#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x2
/* Indexes into the e_ident array. Keep synced with
http://www.sco.com/developers/gabi/latest/ch4.eheader.html */
#define EI_MAG0 0 /* Magic number, byte 0. */