PenYiWang via llvm-dev
2019-Jan-25 01:30 UTC
[llvm-dev] What's definition to type of function in -fsanitize=cfi-icall in llvm/clang 7?
Hi
I learn llvm/clang cfi from this repo and also the usenix '14 paper.
https://github.com/trailofbits/clang-cfi-showcase/blob/master/cfi_icall.c
As usenix '14 paper says, the type of functoin is determined only by number
of argument.
But I try in llvm/clang 7, I found that it is getting complicated.
For example,
#include<stdio.h>
int func(int a,float b,char c){
printf("hi %d,%f,%c\n",a,b,c);
return a+1;
}
int main(){
int (*fp)(int,float,char);
fp = func;
fp(1,1.0,'c');
return 0;
}
clang -flto -fsanitize=cfi -fvisibility=hidden -O0 ./test.c
And the use objdump to see the executable :
00000000004005a0 <__typeid__ZTSFiifcE_global_addr>:
4005a0: e9 4b ff ff ff jmpq 4004f0 <func.cfi>
4005a5: cc int3
4005a6: cc int3
4005a7: cc int3
4005a8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
4005af: 00
>From the type id mangling "iifc", I can guess that the type of
return value
and the type of every argument are the factors to determine the type of a
function.
I wonder that what's the definition of type of a function in llvm/clang 7.
Is there any document I can study?
Or I should study the code in compiler fronted (clang)?
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190125/44bcd019/attachment.html>
Chandler Carruth via llvm-dev
2019-Jan-25 09:56 UTC
[llvm-dev] What's definition to type of function in -fsanitize=cfi-icall in llvm/clang 7?
+Peter Collingbourne <pcc at google.com> On Thu, Jan 24, 2019 at 5:30 PM PenYiWang via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi > > I learn llvm/clang cfi from this repo and also the usenix '14 paper. > https://github.com/trailofbits/clang-cfi-showcase/blob/master/cfi_icall.c > > As usenix '14 paper says, the type of functoin is determined only by > number of argument. > > But I try in llvm/clang 7, I found that it is getting complicated. > > For example, > > #include<stdio.h> > > int func(int a,float b,char c){ > printf("hi %d,%f,%c\n",a,b,c); > return a+1; > } > > int main(){ > int (*fp)(int,float,char); > fp = func; > fp(1,1.0,'c'); > > return 0; > } > > clang -flto -fsanitize=cfi -fvisibility=hidden -O0 ./test.c > > And the use objdump to see the executable : > > 00000000004005a0 <__typeid__ZTSFiifcE_global_addr>: > 4005a0: e9 4b ff ff ff jmpq 4004f0 <func.cfi> > 4005a5: cc int3 > 4005a6: cc int3 > 4005a7: cc int3 > 4005a8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) > 4005af: 00 > > From the type id mangling "iifc", I can guess that the type of return > value and the type of every argument are the factors to determine the type > of a function. > > I wonder that what's the definition of type of a function in llvm/clang 7. > > Is there any document I can study? > > Or I should study the code in compiler fronted (clang)? > > Thank you. > > > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190125/8f94f86a/attachment.html>