Skip to content

Commit 5c64887

Browse files
committed
Add options for enable code gen with CFI -fcf-protection=[full|branch|return|none] and -mcf-label-scheme=[unlabeled|func-sig]
Resue the options defined by X86 CET, `-fcf-protection=[full|branch|return|none]` `-fcf-protection=branch` for landing pad (`Zicfilp`), `-fcf-protection=return` for landing pad (`Zicfiss`) and `-fcf-protection=full` for enable both if possible, landing pad just require instrcution defined by base extension, so compiler will emit landing pad even without `Zicfilp` extension, but `-fcf-protection=return` will require at least `Zimop` since the instrcution isn't included in base extension. Also we defined another option for specify the labeling scheme: `unlabeled` and `func-sig`. The `unlabeled` scheme is always use `lpad 0`, and `func-sig` is based on the function signature, the rule is defined in psABI.
1 parent 602b398 commit 5c64887

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/toolchain-conventions.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,29 @@ NOTE: This option does not affect inline assembly.
406406
The precedence among `-m[no]-scalar-strict-align`, `-m[no-]vector-strict-align`,
407407
and `-m[no-]strict-align` is determined by the last one specified.
408408

409+
=== `-fcf-protection=[full|branch|return|none]`/`-fcf-protection`
410+
411+
412+
Enable control flow protection. The compiler will insert control flow integrity
413+
instructions to protect the program against control flow hijacking attacks.
414+
415+
`-fcf-protection` is alias to `-fcf-protection=full`.
416+
417+
- `none`: Disable control flow protection.
418+
- `full`: Protect all control flow instructions, will enable branch protection
419+
and return protection if the `Zimop` extension is available.
420+
- `branch`: Protect branch instructions only by insert landing pad.
421+
- `return`: Protect return instructions only, this require `Zimop` extension.
422+
423+
=== `-mcf-branch-label-scheme=[unlabeled|func-sig]`
424+
425+
Specify the label scheme for the `-fcf-protection=branch`. The default is value
426+
is platform defined.
427+
428+
- `unlabeled`: Use simple label scheme, the label is always `0`.
429+
- `func-sig`: Use function signature as the label, the label is generated by the
430+
compiler, the rule is defined in psABI spec.
431+
409432
== TODO
410433

411434
- `-mdiv`, `-mno-div`, `-mfdiv`, `-mno-fdiv`, `-msave-restore`,

0 commit comments

Comments
 (0)