Dynamic Binary Translation.ppt
《Dynamic Binary Translation.ppt》由会员分享,可在线阅读,更多相关《Dynamic Binary Translation.ppt(39页珍藏版)》请在麦多课文档分享上搜索。
1、Ras Bodik CS 164 Lecture 24,1,Dynamic Binary Translation,Lecture 24acknowledgement: E. Duesterwald (IBM), S. Amarasinghe (MIT),Ras Bodik CS 164 Lecture 24,2,Lecture Outline,Binary Translation: Why, What, and When.Why: Guarding against buffer overrunsWhat, when: overview of two dynamic translators: D
2、ynamo-RIO by HP, MIT CodeMorph by TransmetaTechniques used in dynamic translators Path profiling,Ras Bodik CS 164 Lecture 24,3,Motivation: preventing buffer overruns,Recall the typical buffer overrun attack:program calls a method foo()foo() copies a string into an on-stack array: string supplied by
3、the user users malicious code copied into foos array foos return address overwritten to point to user codefoo() returns unknowingly jumping to the user code,Ras Bodik CS 164 Lecture 24,4,Preventing buffer overrun attacks,Two general approaches:static (compile-time): analyze the program find all arra
4、y writes that may outside array bounds program proven safe before you run itdynamic (run-time): analyze the execution make sure no write outside an array happens execution proven safe (enough to achieve security),Ras Bodik CS 164 Lecture 24,5,Dynamic buffer overrun prevention,the idea, again:prevent
5、 writes outside the intended array as is done in Java harder in C: must add “size” to each array done in CCured, a Berkeley project,Ras Bodik CS 164 Lecture 24,6,A different idea,perhaps less safe, but easier to implement: goal: detect that return address was overwritten.instrument the program so th
6、at it keeps an extra copy of the return address:store aside the return address when function called (store it in an inaccessible shadow stack) when returning, check that the return address in AR matches the stored one; if mismatch, terminate program,Ras Bodik CS 164 Lecture 24,7,Commercially interes
7、ting,Similar idea behind the product by key problem: reducing overhead of instrumentation whats instrumentation, anyway? adding statements to an existing program in our case, to x86 executables Determina uses binary translation,Ras Bodik CS 164 Lecture 24,8,What is Binary Translation?,Translating a
8、program in one binary format to another, for example: MIPS x86 (to port programs across platforms)We can view “binary format” liberally: Java bytecode x86 (to avoid interpretation) x86 x86 (to optimize the executable),Ras Bodik CS 164 Lecture 24,9,When does the translation happen?,Static (off-line):
9、 before the program is run Pros: no serious translation-time constraints Dynamic (on-line): while the program is running Pros: access to complete program (program is fully linked) access to program state (including values of data structs) can adapt to changes in program behaviorNote: Pros(dynamic) =
10、 Cons(static),Ras Bodik CS 164 Lecture 24,10,Why? Translation Allows Program Modification,Program,Compiler,Runtime System,Static,Dynamic,Load time optimizers Shared library mechanism,DebuggersInterpretersJust-In-Time CompilersDynamic OptimizersProfilersDynamic CheckersinstrumentersEtc.,Ras Bodik CS
11、164 Lecture 24,11,Applications, in more detail,profilers: add instrumentation instructions to count basic block execution counts (e.g., gprof) load-time optimizers: remove caller/callee save instructions (callers/callees known after DLLs are linked) replace long jumps with short jumps (code position
12、 known after linking) dynamic checkers finding memory access bugs (e.g., Rational Purify),Ras Bodik CS 164 Lecture 24,12,Dynamic Program Modifiers,Running Program,Dynamic Program Modifier: Observe/Manipulate Every Instruction in the Running Program,Hardware Platform,Ras Bodik CS 164 Lecture 24,13,In
13、 more detail,common setup,CPU,OS,DLL,application,CodeMorph,OS,DLL,application,CPU=VLIW,CodeMorph (Transmeta),Dynamo-RIO (HP, MIT),CPU=x86,DLL,application,Dynamo,OS,Ras Bodik CS 164 Lecture 24,14,Dynamic Program Modifiers,Requirements: Ability to intercept execution at arbitrary points Observe execut
14、ing instructions Modify executing instructions Transparency - modified program is not specially prepared Efficiency - amortize overhead and achieve near-native performance Robustness Maintain full control and capture all code- sampling is not an option (there are security applications),Ras Bodik CS
15、164 Lecture 24,15,HP Dynamo-RIO,Building a dynamic program modifier Trick I: adding a code cache Trick II: linking Trick III: efficient indirect branch handling Trick IV: picking traces Dynamo-RIO performance Run-time trace optimizations,Ras Bodik CS 164 Lecture 24,16,next VPC,Instruction Interprete
16、r,System I: Basic Interpreter,decode,fetch next instruction,execute,exception handling,update VPC,Intercept executionObserve & modify executing instructionsTransparency Efficiency? - up to several 100 X slowdown,Ras Bodik CS 164 Lecture 24,17,context switch,BASIC BLOCK CACHE,non-control-flow instruc
17、tions,Trick I: Adding a Code Cache,next VPC,fetch block at VPC,lookup VPC,emit block,exception handling,execute block,Ras Bodik CS 164 Lecture 24,18,add %eax, %ecx cmp $4, %eax jle $0x40106f,add %eax, %ecx cmp $4, %eax jle jmp mov %eax, eax-slot # spill eax mov &dstub1, %eax # store ptr to stub tabl
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- DYNAMICBINARYTRANSLATIONPPT
