[PATCH] D76900: Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)
H.J Lu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 20:55:03 PDT 2020
hjl.tools added a comment.
In D76900#1953937 <https://reviews.llvm.org/D76900#1953937>, @xiangzhangllvm wrote:
> I find your patch will not deal with internal function.
> I tested GCC, It really will generate endbr for static functions:
>
> gcc version 9.3.1 20200317 (Red Hat 9.3.1-1) (GCC)
> [xiangzh1 at gnu-tgl-1 ~/tmp]$cat t.c
> extern int foo2(int a);
>
> extern int foo2(int a)
> {
> return a*6;
> }
>
> static int foo3(int a)
> {
> return a*7;
> }
>
> int foo(int a){
> // int (*pf3)(int) = foo;
> // int b = foo2(a) +foo3(a) + pf3(a);
> int b = foo2(a) +foo3(a);
> return b;
> }
> [xiangzh1 at gnu-tgl-1 ~/tmp]$
> [xiangzh1 at gnu-tgl-1 ~/tmp]$gcc -fcf-protection t.c -S -o t.s
You need -O2 to turn on optimization:
[hjl at gnu-cfl-2 tmp]$ cat y.c
__attribute__ ((noclone, noinline))
static int foo3(int a)
{
return a*7;
}
extern int b;
void
foo(int a)
{
b = foo3(a);
}
[hjl at gnu-cfl-2 tmp]$ gcc -fcf-protection -O2 -S y.c
[hjl at gnu-cfl-2 tmp]$ cat y.s
.file "y.c"
.text
.p2align 4
.type foo3, @function
foo3:
.LFB0:
.cfi_startproc
leal 0(,%rdi,8), %eax
subl %edi, %eax
ret
.cfi_endproc
.LFE0:
.size foo3, .-foo3
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB1:
.cfi_startproc
endbr64
call foo3
movl %eax, b(%rip)
ret
.cfi_endproc
.LFE1:
.size foo, .-foo
.ident "GCC: (GNU) 9.3.1 20200317 (Red Hat 9.3.1-1)"
.section .note.GNU-stack,"", at progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
[hjl at gnu-cfl-2 tmp]$
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76900/new/
https://reviews.llvm.org/D76900
More information about the llvm-commits
mailing list