Skip to content

Commit e0e93a4

Browse files
kito-chengcmuellner
authored andcommitted
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 0d42de6 commit e0e93a4

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
@@ -389,6 +389,29 @@ NOTE: This option does not affect inline assembly.
389389
The precedence among `-m[no]-scalar-strict-align`, `-m[no-]vector-strict-align`,
390390
and `-m[no-]strict-align` is determined by the last one specified.
391391

392+
=== `-fcf-protection=[full|branch|return|none]`/`-fcf-protection`
393+
394+
395+
Enable control flow protection. The compiler will insert control flow integrity
396+
instructions to protect the program against control flow hijacking attacks.
397+
398+
`-fcf-protection` is alias to `-fcf-protection=full`.
399+
400+
- `none`: Disable control flow protection.
401+
- `full`: Protect all control flow instructions, will enable branch protection
402+
and return protection if the `Zimop` extension is available.
403+
- `branch`: Protect branch instructions only by insert landing pad.
404+
- `return`: Protect return instructions only, this require `Zimop` extension.
405+
406+
=== `-mcf-branch-label-scheme=[unlabeled|func-sig]`
407+
408+
Specify the label scheme for the `-fcf-protection=branch`. The default is value
409+
is platform defined.
410+
411+
- `unlabeled`: Use simple label scheme, the label is always `0`.
412+
- `func-sig`: Use function signature as the label, the label is generated by the
413+
compiler, the rule is defined in psABI spec.
414+
392415
== TODO
393416

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

0 commit comments

Comments
 (0)