Skip to content

Commit b7d91db

Browse files
tphan-ventanamergify[bot]
authored andcommitted
BaseTools/GenFW: RISC-V: Detect Zicfilp extension
Parse the ELF file for RISC-V Zicfilp extension support to identify forward control flow integrity (FCFI) features. Signed-off-by: Tuan Phan <[email protected]>
1 parent cb8c8c9 commit b7d91db

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

BaseTools/Source/C/GenFw/Elf64Convert.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ ParseNoteSection (
802802
Prop2 = GNU_PROPERTY_X86_FEATURE_1_IBT;
803803
break;
804804

805+
case EM_RISCV64:
806+
Prop0 = GNU_PROPERTY_RISCV64_FEATURE_1_AND;
807+
Prop2 = GNU_PROPERTY_RISCV64_FEATURE_1_FCFI;
808+
break;
809+
805810
default:
806811
return;
807812
}

BaseTools/Source/C/GenFw/elf_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ typedef struct {
6868
#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x1
6969
#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x2
7070

71+
#define GNU_PROPERTY_RISCV64_FEATURE_1_AND 0xc0000000
72+
#define GNU_PROPERTY_RISCV64_FEATURE_1_FCFI 0x1 /* zicfilp */
73+
7174
/* Indexes into the e_ident array. Keep synced with
7275
http://www.sco.com/developers/gabi/latest/ch4.eheader.html */
7376
#define EI_MAG0 0 /* Magic number, byte 0. */

0 commit comments

Comments
 (0)