Created
February 8, 2023 15:51
-
-
Save inclyc/d68942cc2e609c1cecf58180b759e660 to your computer and use it in GitHub Desktop.
Pure analysis test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int pure(int a); // 定义在翻译单元外 | |
| int main() { | |
| for(int i = 0;i < 10;i++){ | |
| pure(1); | |
| } // 此循环被删除,说明可以分析出 pure | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test.asm: test | |
| objdump -C -S $< > $@ | |
| test: main.o pure.o | |
| clang -flto=thin -O2 $^ -o $@ | |
| %.o: %.c | |
| clang -flto=thin -O2 $< -c -o $@ | |
| .PHONY: clean | |
| clean: | |
| @rm -f *.o | |
| @rm test.asm | |
| @rm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int pure(int a){ | |
| return a + 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test: file format elf64-x86-64 | |
| Disassembly of section .init: | |
| 0000000000401000 <_init>: | |
| 401000: f3 0f 1e fa endbr64 | |
| 401004: 48 83 ec 08 sub $0x8,%rsp | |
| 401008: 48 8b 05 e9 2f 00 00 mov 0x2fe9(%rip),%rax # 403ff8 <__gmon_start__@Base> | |
| 40100f: 48 85 c0 test %rax,%rax | |
| 401012: 74 02 je 401016 <_init+0x16> | |
| 401014: ff d0 call *%rax | |
| 401016: 48 83 c4 08 add $0x8,%rsp | |
| 40101a: c3 ret | |
| Disassembly of section .text: | |
| 0000000000401020 <_start>: | |
| 401020: f3 0f 1e fa endbr64 | |
| 401024: 31 ed xor %ebp,%ebp | |
| 401026: 49 89 d1 mov %rdx,%r9 | |
| 401029: 5e pop %rsi | |
| 40102a: 48 89 e2 mov %rsp,%rdx | |
| 40102d: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp | |
| 401031: 50 push %rax | |
| 401032: 54 push %rsp | |
| 401033: 45 31 c0 xor %r8d,%r8d | |
| 401036: 31 c9 xor %ecx,%ecx | |
| 401038: 48 c7 c7 10 11 40 00 mov $0x401110,%rdi | |
| 40103f: ff 15 ab 2f 00 00 call *0x2fab(%rip) # 403ff0 <__libc_start_main@GLIBC_2.34> | |
| 401045: f4 hlt | |
| 401046: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) | |
| 40104d: 00 00 00 | |
| 0000000000401050 <_dl_relocate_static_pie>: | |
| 401050: f3 0f 1e fa endbr64 | |
| 401054: c3 ret | |
| 401055: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) | |
| 40105c: 00 00 00 | |
| 40105f: 90 nop | |
| 0000000000401060 <deregister_tm_clones>: | |
| 401060: b8 10 40 40 00 mov $0x404010,%eax | |
| 401065: 48 3d 10 40 40 00 cmp $0x404010,%rax | |
| 40106b: 74 13 je 401080 <deregister_tm_clones+0x20> | |
| 40106d: b8 00 00 00 00 mov $0x0,%eax | |
| 401072: 48 85 c0 test %rax,%rax | |
| 401075: 74 09 je 401080 <deregister_tm_clones+0x20> | |
| 401077: bf 10 40 40 00 mov $0x404010,%edi | |
| 40107c: ff e0 jmp *%rax | |
| 40107e: 66 90 xchg %ax,%ax | |
| 401080: c3 ret | |
| 401081: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) | |
| 401088: 00 00 00 00 | |
| 40108c: 0f 1f 40 00 nopl 0x0(%rax) | |
| 0000000000401090 <register_tm_clones>: | |
| 401090: be 10 40 40 00 mov $0x404010,%esi | |
| 401095: 48 81 ee 10 40 40 00 sub $0x404010,%rsi | |
| 40109c: 48 89 f0 mov %rsi,%rax | |
| 40109f: 48 c1 ee 3f shr $0x3f,%rsi | |
| 4010a3: 48 c1 f8 03 sar $0x3,%rax | |
| 4010a7: 48 01 c6 add %rax,%rsi | |
| 4010aa: 48 d1 fe sar %rsi | |
| 4010ad: 74 11 je 4010c0 <register_tm_clones+0x30> | |
| 4010af: b8 00 00 00 00 mov $0x0,%eax | |
| 4010b4: 48 85 c0 test %rax,%rax | |
| 4010b7: 74 07 je 4010c0 <register_tm_clones+0x30> | |
| 4010b9: bf 10 40 40 00 mov $0x404010,%edi | |
| 4010be: ff e0 jmp *%rax | |
| 4010c0: c3 ret | |
| 4010c1: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) | |
| 4010c8: 00 00 00 00 | |
| 4010cc: 0f 1f 40 00 nopl 0x0(%rax) | |
| 00000000004010d0 <__do_global_dtors_aux>: | |
| 4010d0: f3 0f 1e fa endbr64 | |
| 4010d4: 80 3d 35 2f 00 00 00 cmpb $0x0,0x2f35(%rip) # 404010 <__TMC_END__> | |
| 4010db: 75 13 jne 4010f0 <__do_global_dtors_aux+0x20> | |
| 4010dd: 55 push %rbp | |
| 4010de: 48 89 e5 mov %rsp,%rbp | |
| 4010e1: e8 7a ff ff ff call 401060 <deregister_tm_clones> | |
| 4010e6: c6 05 23 2f 00 00 01 movb $0x1,0x2f23(%rip) # 404010 <__TMC_END__> | |
| 4010ed: 5d pop %rbp | |
| 4010ee: c3 ret | |
| 4010ef: 90 nop | |
| 4010f0: c3 ret | |
| 4010f1: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) | |
| 4010f8: 00 00 00 00 | |
| 4010fc: 0f 1f 40 00 nopl 0x0(%rax) | |
| 0000000000401100 <frame_dummy>: | |
| 401100: f3 0f 1e fa endbr64 | |
| 401104: eb 8a jmp 401090 <register_tm_clones> | |
| 401106: 66 90 xchg %ax,%ax | |
| 401108: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) | |
| 40110f: 00 | |
| 0000000000401110 <main>: | |
| 401110: 31 c0 xor %eax,%eax | |
| 401112: c3 ret | |
| 401113: 90 nop | |
| 401114: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) | |
| 40111b: 00 00 00 | |
| 40111e: 66 90 xchg %ax,%ax | |
| 0000000000401120 <pure>: | |
| 401120: 8d 47 01 lea 0x1(%rdi),%eax | |
| 401123: c3 ret | |
| Disassembly of section .fini: | |
| 0000000000401124 <_fini>: | |
| 401124: f3 0f 1e fa endbr64 | |
| 401128: 48 83 ec 08 sub $0x8,%rsp | |
| 40112c: 48 83 c4 08 add $0x8,%rsp | |
| 401130: c3 ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment