phase_2的汇编代码如下:
(gdb) disassemble phase_2
Dump of assembler code for function phase_2:
0x0000000000400efc <+0>: push %rbp
0x0000000000400efd <+1>: push %rbx
0x0000000000400efe <+2>: sub $0x28,%rsp
0x0000000000400f02 <+6>: mov %rsp,%rsi
0x0000000000400f05 <+9>: callq 0x40145c <read_six_numbers>
0x0000000000400f0a <+14>: cmpl $0x1,(%rsp)
0x0000000000400f0e <+18>: je 0x400f30 <phase_2+52>
0x0000000000400f10 <+20>: callq 0x40143a <explode_bomb>
0x0000000000400f15 <+25>: jmp 0x400f30 <phase_2+52>
0x0000000000400f17 <+27>: mov -0x4(%rbx),%eax
0x0000000000400f1a <+30>: add %eax,%eax
0x0000000000400f1c <+32>: cmp %eax,(%rbx)
0x0000000000400f1e <+34>: je 0x400f25 <phase_2+41>
0x0000000000400f20 <+36>: callq 0x40143a <explode_bomb>
0x0000000000400f25 <+41>: add $0x4,%rbx
0x0000000000400f29 <+45>: cmp %rbp,%rbx
0x0000000000400f2c <+48>: jne 0x400f17 <phase_2+27>
0x0000000000400f2e <+50>: jmp 0x400f3c <phase_2+64>
0x0000000000400f30 <+52>: lea 0x4(%rsp),%rbx
0x0000000000400f35 <+57>: lea 0x18(%rsp),%rbp
0x0000000000400f3a <+62>: jmp 0x400f17 <phase_2+27>
0x0000000000400f3c <+64>: add $0x28,%rsp
0x0000000000400f40 <+68>: pop %rbx
0x0000000000400f41 <+69>: pop %rbp
0x0000000000400f42 <+70>: retq
暂时我看不出这里面的一些门道,但是,根据这篇文章:
https://stackoverflow.com/questions/9186150/decoding-and-understanding-assembly-code
这里,因为rsp没有被push或者其他操作,所以,可以看做rsp减去0x28bytes, 也就是增加地址,
| sp | sp + 4 | sp + 8 | sp + c | sp + 10 | sp + 14 | rbp = sp + 18
且sp传递给了rsi, 应该是 read-six-numbers的参数,一个数组 t[5].
0x0000000000400f05 <+9>: callq 0x40145c <read_six_numbers>
0x0000000000400f0a <+14>: cmpl $0x1,(%rsp)
0x0000000000400f0e <+18>: je 0x400f30 <phase_2+52>
0x0000000000400f10 <+20>: callq 0x40143a <explode_bomb>
类似于同于:
if (t[0] == 1)
...
else
explode_bomb
然后看一下 +52处
0x0000000000400f30 <+52>: lea 0x4(%rsp),%rbx
0x0000000000400f35 <+57>: lea 0x18(%rsp),%rbp // 好像回退了,这一句和上面的layout联系起来
0x0000000000400f3a <+62>: jmp 0x400f17 <phase_2+27>
-----------------------+27---------------------
0x0000000000400f17 <+27>: mov -0x4(%rbx),%eax
0x0000000000400f1a <+30>: add %eax,%eax
0x0000000000400f1c <+32>: cmp %eax,(%rbx)
0x0000000000400f1e <+34>: je 0x400f25 <phase_2+41>
或者等于:
eax == rbx[-4](eax=t[1])
eax += eax
0x0000000000400f25 <+41>: add $0x4,%rbx
0x0000000000400f29 <+45>: cmp %rbp,%rbx
0x0000000000400f2c <+48>: jne 0x400f17 <phase_2+27>
0x0000000000400f2e <+50>: jmp 0x400f3c <phase_2+64>
(gdb) disassemble read_six_numbers
Dump of assembler code for function read_six_numbers:
0x000000000040145c <+0>: sub $0x18,%rsp
0x0000000000401460 <+4>: mov %rsi,%rdx
0x0000000000401463 <+7>: lea 0x4(%rsi),%rcx
0x0000000000401467 <+11>: lea 0x14(%rsi),%rax
0x000000000040146b <+15>: mov %rax,0x8(%rsp)
0x0000000000401470 <+20>: lea 0x10(%rsi),%rax
0x0000000000401474 <+24>: mov %rax,(%rsp)
0x0000000000401478 <+28>: lea 0xc(%rsi),%r9
0x000000000040147c <+32>: lea 0x8(%rsi),%r8
0x0000000000401480 <+36>: mov $0x4025c3,%esi
0x0000000000401485 <+41>: mov $0x0,%eax
0x000000000040148a <+46>: callq 0x400bf0 <__isoc99_sscanf@plt>
0x000000000040148f <+51>: cmp $0x5,%eax
0x0000000000401492 <+54>: jg 0x401499 <read_six_numbers+61>
0x0000000000401494 <+56>: callq 0x40143a <explode_bomb>
0x0000000000401499 <+61>: add $0x18,%rsp
0x000000000040149d <+65>: retq
End of assembler dump.
---------------------------
End of assembler dump.
(gdb) x/s 0x4025c3
0x4025c3: "%d %d %d %d %d %d"
根据本系列的第一篇文章,我们现在来分析第一个bomb.
其实这里主要是gdb的使用,根据以下的代码:
常用的命令有:
disas // 反汇编当前函数
disas sum // 反汇编函数sum
// ------调试------
// 若调用了其他函数,step/stepi会进入函数内部,而next/nexti不会
stepi // 执行下一条指令
step // 执行下一条语句
nexti // 执行下一条指令
next // 执行下一条语句
print 0x100 // 输出0x100的十进制表示
print /x 555 // 输出555的十六进制表示
print /d $rax // 以十进制输出寄存器%rax中的值
print /x $rax // 以十六进制输出寄存器%rax中的值
print /t $rax // 以二进制输出寄存器%rax中的值
x/s 0xbffff890 //检查地址0xbffff890中存储的字符串
(gdb)
73 input = read_line(); /* Get input */
74 phase_1(input); /* Run the phase */
75 phase_defused(); /* Drat! They figured it out!
76 * Let me know how they did it. */
# 打断点
(gdb) b 73
Breakpoint 1 at 0x400e32: file bomb.c, line 73.
(gdb) b 74
Breakpoint 2 at 0x400e37: file bomb.c, line 74.
(gdb) start # 开始
Temporary breakpoint 3 at 0x400da0: file bomb.c, line 37.
Starting program: /home/user/yubo_work/bomb/bomb
Temporary breakpoint 3, main (argc=1, argv=0x7fffffffe3d8) at bomb.c:37
37 {
(gdb) c
Continuing.
Welcome to my fiendish little bomb. You have 6 phases with
which to blow yourself up. Have a nice day!
Breakpoint 1, main (argc=<optimized out>, argv=<optimized out>) at bomb.c:73
73 input = read_line(); /* Get input */
(gdb) n # read_line 是读取字符串,到这里,gdb会停下来,期望我们输入, 下面我输入一个 "test"
test
Breakpoint 2, main (argc=<optimized out>, argv=<optimized out>) at bomb.c:74
74 phase_1(input); /* Run the phase */
# ==
# 反汇编一下 phase_1
(gdb) disassemble phase_1
Dump of assembler code for function phase_1:
0x0000000000400ee0 <+0>: sub $0x8,%rsp
0x0000000000400ee4 <+4>: mov $0x402400,%esi // %esi用于存储第二个参数
0x0000000000400ee9 <+9>: callq 0x401338 <strings_not_equal>
0x0000000000400eee <+14>: test %eax,%eax
0x0000000000400ef0 <+16>: je 0x400ef7 <phase_1+23>
0x0000000000400ef2 <+18>: callq 0x40143a <explode_bomb>
0x0000000000400ef7 <+23>: add $0x8,%rsp
0x0000000000400efb <+27>: retq
End of assembler dump.
根据这篇文章, https://abcdxyzk.github.io/blog/2012/11/23/assembly-args/
+4处的%esi是一个参数寄存器 for phase_1这个函数, 根据这篇文章: https://www.jianshu.com/p/fd1cfed8a2d2 我们把一个数值给了esi寄存器,那么,这个数字到底是什么呢?
(gdb) p (char*) 0x402400
$1 = 0x402400 "Border relations with Canada have never been better."
我是怎么也想不到 (char*)这种类型。好,我们暂且输入的和这个字符串再一次传递给了 strings_not_equal函数,那么,该函数的返回值是通过eax返回,通过 https://stackoverflow.com/questions/13064809/the-point-of-test-eax-eax 这篇文章的解释,eax为0,则执行JE的内容,这与我们的经验相一致。
Bomblab URL: http://csapp.cs.cmu.edu/3e/labs.html
说白了,这个bomblab实验就是利用二进制文件,逐渐熟悉x86汇编的一个游戏。下面, 我先把main.c摘录下来,这里,版权问题我不深究,如果有问题请告知我一声。
user@user-system:~/yubo_work/bomb$ cat bomb.c
/***************************************************************************
* Dr. Evil's Insidious Bomb, Version 1.1
* Copyright 2011, Dr. Evil Incorporated. All rights reserved.
*
* LICENSE:
*
* Dr. Evil Incorporated (the PERPETRATOR) hereby grants you (the
* VICTIM) explicit permission to use this bomb (the BOMB). This is a
* time limited license, which expires on the death of the VICTIM.
* The PERPETRATOR takes no responsibility for damage, frustration,
* insanity, bug-eyes, carpal-tunnel syndrome, loss of sleep, or other
* harm to the VICTIM. Unless the PERPETRATOR wants to take credit,
* that is. The VICTIM may not distribute this bomb source code to
* any enemies of the PERPETRATOR. No VICTIM may debug,
* reverse-engineer, run "strings" on, decompile, decrypt, or use any
* other technique to gain knowledge of and defuse the BOMB. BOMB
* proof clothing may not be worn when handling this program. The
* PERPETRATOR will not apologize for the PERPETRATOR's poor sense of
* humor. This license is null and void where the BOMB is prohibited
* by law.
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "support.h"
#include "phases.h"
/*
* Note to self: Remember to erase this file so my victims will have no
* idea what is going on, and so they will all blow up in a
* spectaculary fiendish explosion. -- Dr. Evil
*/
FILE *infile;
int main(int argc, char *argv[])
{
char *input;
/* Note to self: remember to port this bomb to Windows and put a
* fantastic GUI on it. */
/* When run with no arguments, the bomb reads its input lines
* from standard input. */
if (argc == 1) {
infile = stdin;
}
/* When run with one argument <file>, the bomb reads from <file>
* until EOF, and then switches to standard input. Thus, as you
* defuse each phase, you can add its defusing string to <file> and
* avoid having to retype it. */
else if (argc == 2) {
if (!(infile = fopen(argv[1], "r"))) {
printf("%s: Error: Couldn't open %s\n", argv[0], argv[1]);
exit(8);
}
}
/* You can't call the bomb with more than 1 command line argument. */
else {
printf("Usage: %s [<input_file>]\n", argv[0]);
exit(8);
}
/* Do all sorts of secret stuff that makes the bomb harder to defuse. */
initialize_bomb();
printf("Welcome to my fiendish little bomb. You have 6 phases with\n");
printf("which to blow yourself up. Have a nice day!\n");
/* Hmm... Six phases must be more secure than one phase! */
input = read_line(); /* Get input */
phase_1(input); /* Run the phase */
phase_defused(); /* Drat! They figured it out!
* Let me know how they did it. */
printf("Phase 1 defused. How about the next one?\n");
/* The second phase is harder. No one will ever figure out
* how to defuse this... */
input = read_line();
phase_2(input);
phase_defused();
printf("That's number 2. Keep going!\n");
/* I guess this is too easy so far. Some more complex code will
* confuse people. */
input = read_line();
phase_3(input);
phase_defused();
printf("Halfway there!\n");
/* Oh yeah? Well, how good is your math? Try on this saucy problem! */
input = read_line();
phase_4(input);
phase_defused();
printf("So you got that one. Try this one.\n");
/* Round and 'round in memory we go, where we stop, the bomb blows! */
input = read_line();
phase_5(input);
phase_defused();
printf("Good work! On to the next...\n");
/* This phase will never be used, since no one will get past the
* earlier ones. But just in case, make this one extra hard. */
input = read_line();
phase_6(input);
phase_defused();
/* Wow, they got it! But isn't something... missing? Perhaps
* something they overlooked? Mua ha ha ha ha! */
return 0;
}
bomb: 文件格式 elf64-x86-64
Disassembly of section .init:
# 删除了好多铺垫的汇编....
Disassembly of section .text:
0000000000400c90 <_start>:
400c90: 31 ed xor %ebp,%ebp
400c92: 49 89 d1 mov %rdx,%r9
400c95: 5e pop %rsi
400c96: 48 89 e2 mov %rsp,%rdx
400c99: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
400c9d: 50 push %rax
400c9e: 54 push %rsp
400c9f: 49 c7 c0 a0 22 40 00 mov $0x4022a0,%r8
400ca6: 48 c7 c1 10 22 40 00 mov $0x402210,%rcx
400cad: 48 c7 c7 a0 0d 40 00 mov $0x400da0,%rdi
400cb4: e8 b7 fe ff ff callq 400b70 <__libc_start_main@plt>
400cb9: f4 hlt
400cba: 90 nop
400cbb: 90 nop
0000000000400cbc <call_gmon_start>:
400cbc: 48 83 ec 08 sub $0x8,%rsp
400cc0: 48 8b 05 19 23 20 00 mov 0x202319(%rip),%rax # 602fe0 <__gmon_start__>
400cc7: 48 85 c0 test %rax,%rax
400cca: 74 02 je 400cce <call_gmon_start+0x12>
400ccc: ff d0 callq *%rax
400cce: 48 83 c4 08 add $0x8,%rsp
400cd2: c3 retq
400cd3: 90 nop
400cd4: 90 nop
400cd5: 90 nop
400cd6: 90 nop
400cd7: 90 nop
400cd8: 90 nop
400cd9: 90 nop
400cda: 90 nop
400cdb: 90 nop
400cdc: 90 nop
400cdd: 90 nop
400cde: 90 nop
400cdf: 90 nop
0000000000400ce0 <deregister_tm_clones>:
400ce0: b8 47 37 60 00 mov $0x603747,%eax
400ce5: 55 push %rbp
400ce6: 48 2d 40 37 60 00 sub $0x603740,%rax
400cec: 48 83 f8 0e cmp $0xe,%rax
400cf0: 48 89 e5 mov %rsp,%rbp
400cf3: 77 02 ja 400cf7 <deregister_tm_clones+0x17>
400cf5: 5d pop %rbp
400cf6: c3 retq
400cf7: b8 00 00 00 00 mov $0x0,%eax
400cfc: 48 85 c0 test %rax,%rax
400cff: 74 f4 je 400cf5 <deregister_tm_clones+0x15>
400d01: 5d pop %rbp
400d02: bf 40 37 60 00 mov $0x603740,%edi
400d07: ff e0 jmpq *%rax
400d09: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
0000000000400d10 <register_tm_clones>:
400d10: b8 40 37 60 00 mov $0x603740,%eax
400d15: 55 push %rbp
400d16: 48 2d 40 37 60 00 sub $0x603740,%rax
400d1c: 48 c1 f8 03 sar $0x3,%rax
400d20: 48 89 e5 mov %rsp,%rbp
400d23: 48 89 c2 mov %rax,%rdx
400d26: 48 c1 ea 3f shr $0x3f,%rdx
400d2a: 48 01 d0 add %rdx,%rax
400d2d: 48 d1 f8 sar %rax
400d30: 75 02 jne 400d34 <register_tm_clones+0x24>
400d32: 5d pop %rbp
400d33: c3 retq
400d34: ba 00 00 00 00 mov $0x0,%edx
400d39: 48 85 d2 test %rdx,%rdx
400d3c: 74 f4 je 400d32 <register_tm_clones+0x22>
400d3e: 5d pop %rbp
400d3f: 48 89 c6 mov %rax,%rsi
400d42: bf 40 37 60 00 mov $0x603740,%edi
400d47: ff e2 jmpq *%rdx
400d49: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
0000000000400d50 <__do_global_dtors_aux>:
400d50: 80 3d 01 2a 20 00 00 cmpb $0x0,0x202a01(%rip) # 603758 <completed.6976>
400d57: 75 11 jne 400d6a <__do_global_dtors_aux+0x1a>
400d59: 55 push %rbp
400d5a: 48 89 e5 mov %rsp,%rbp
400d5d: e8 7e ff ff ff callq 400ce0 <deregister_tm_clones>
400d62: 5d pop %rbp
400d63: c6 05 ee 29 20 00 01 movb $0x1,0x2029ee(%rip) # 603758 <completed.6976>
400d6a: f3 c3 repz retq
400d6c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000400d70 <frame_dummy>:
400d70: 48 83 3d 90 20 20 00 cmpq $0x0,0x202090(%rip) # 602e08 <__JCR_END__>
400d77: 00
400d78: 74 1e je 400d98 <frame_dummy+0x28>
400d7a: b8 00 00 00 00 mov $0x0,%eax
400d7f: 48 85 c0 test %rax,%rax
400d82: 74 14 je 400d98 <frame_dummy+0x28>
400d84: 55 push %rbp
400d85: bf 08 2e 60 00 mov $0x602e08,%edi
400d8a: 48 89 e5 mov %rsp,%rbp
400d8d: ff d0 callq *%rax
400d8f: 5d pop %rbp
400d90: e9 7b ff ff ff jmpq 400d10 <register_tm_clones>
400d95: 0f 1f 00 nopl (%rax)
400d98: e9 73 ff ff ff jmpq 400d10 <register_tm_clones>
400d9d: 90 nop
400d9e: 90 nop
400d9f: 90 nop
0000000000400da0 <main>:
400da0: 53 push %rbx
400da1: 83 ff 01 cmp $0x1,%edi
400da4: 75 10 jne 400db6 <main+0x16>
400da6: 48 8b 05 9b 29 20 00 mov 0x20299b(%rip),%rax # 603748 <stdin@@GLIBC_2.2.5>
400dad: 48 89 05 b4 29 20 00 mov %rax,0x2029b4(%rip) # 603768 <infile>
400db4: eb 63 jmp 400e19 <main+0x79>
400db6: 48 89 f3 mov %rsi,%rbx
400db9: 83 ff 02 cmp $0x2,%edi
400dbc: 75 3a jne 400df8 <main+0x58>
400dbe: 48 8b 7e 08 mov 0x8(%rsi),%rdi
400dc2: be b4 22 40 00 mov $0x4022b4,%esi
400dc7: e8 44 fe ff ff callq 400c10 <fopen@plt>
400dcc: 48 89 05 95 29 20 00 mov %rax,0x202995(%rip) # 603768 <infile>
400dd3: 48 85 c0 test %rax,%rax
400dd6: 75 41 jne 400e19 <main+0x79>
400dd8: 48 8b 4b 08 mov 0x8(%rbx),%rcx
400ddc: 48 8b 13 mov (%rbx),%rdx
400ddf: be b6 22 40 00 mov $0x4022b6,%esi
400de4: bf 01 00 00 00 mov $0x1,%edi
400de9: e8 12 fe ff ff callq 400c00 <__printf_chk@plt>
400dee: bf 08 00 00 00 mov $0x8,%edi
400df3: e8 28 fe ff ff callq 400c20 <exit@plt>
400df8: 48 8b 16 mov (%rsi),%rdx
400dfb: be d3 22 40 00 mov $0x4022d3,%esi
400e00: bf 01 00 00 00 mov $0x1,%edi
400e05: b8 00 00 00 00 mov $0x0,%eax
400e0a: e8 f1 fd ff ff callq 400c00 <__printf_chk@plt>
400e0f: bf 08 00 00 00 mov $0x8,%edi
400e14: e8 07 fe ff ff callq 400c20 <exit@plt>
400e19: e8 84 05 00 00 callq 4013a2 <initialize_bomb>
400e1e: bf 38 23 40 00 mov $0x402338,%edi
400e23: e8 e8 fc ff ff callq 400b10 <puts@plt>
400e28: bf 78 23 40 00 mov $0x402378,%edi
400e2d: e8 de fc ff ff callq 400b10 <puts@plt>
400e32: e8 67 06 00 00 callq 40149e <read_line>
400e37: 48 89 c7 mov %rax,%rdi
400e3a: e8 a1 00 00 00 callq 400ee0 <phase_1>
400e3f: e8 80 07 00 00 callq 4015c4 <phase_defused>
400e44: bf a8 23 40 00 mov $0x4023a8,%edi
400e49: e8 c2 fc ff ff callq 400b10 <puts@plt>
400e4e: e8 4b 06 00 00 callq 40149e <read_line>
400e53: 48 89 c7 mov %rax,%rdi
400e56: e8 a1 00 00 00 callq 400efc <phase_2>
400e5b: e8 64 07 00 00 callq 4015c4 <phase_defused>
400e60: bf ed 22 40 00 mov $0x4022ed,%edi
400e65: e8 a6 fc ff ff callq 400b10 <puts@plt>
400e6a: e8 2f 06 00 00 callq 40149e <read_line>
400e6f: 48 89 c7 mov %rax,%rdi
400e72: e8 cc 00 00 00 callq 400f43 <phase_3>
400e77: e8 48 07 00 00 callq 4015c4 <phase_defused>
400e7c: bf 0b 23 40 00 mov $0x40230b,%edi
400e81: e8 8a fc ff ff callq 400b10 <puts@plt>
400e86: e8 13 06 00 00 callq 40149e <read_line>
400e8b: 48 89 c7 mov %rax,%rdi
400e8e: e8 79 01 00 00 callq 40100c <phase_4>
400e93: e8 2c 07 00 00 callq 4015c4 <phase_defused>
400e98: bf d8 23 40 00 mov $0x4023d8,%edi
400e9d: e8 6e fc ff ff callq 400b10 <puts@plt>
400ea2: e8 f7 05 00 00 callq 40149e <read_line>
400ea7: 48 89 c7 mov %rax,%rdi
400eaa: e8 b3 01 00 00 callq 401062 <phase_5>
400eaf: e8 10 07 00 00 callq 4015c4 <phase_defused>
400eb4: bf 1a 23 40 00 mov $0x40231a,%edi
400eb9: e8 52 fc ff ff callq 400b10 <puts@plt>
400ebe: e8 db 05 00 00 callq 40149e <read_line>
400ec3: 48 89 c7 mov %rax,%rdi
400ec6: e8 29 02 00 00 callq 4010f4 <phase_6>
400ecb: e8 f4 06 00 00 callq 4015c4 <phase_defused>
400ed0: b8 00 00 00 00 mov $0x0,%eax
400ed5: 5b pop %rbx
400ed6: c3 retq
400ed7: 90 nop
400ed8: 90 nop
400ed9: 90 nop
400eda: 90 nop
400edb: 90 nop
400edc: 90 nop
400edd: 90 nop
400ede: 90 nop
400edf: 90 nop
0000000000400ee0 <phase_1>:
400ee0: 48 83 ec 08 sub $0x8,%rsp
400ee4: be 00 24 40 00 mov $0x402400,%esi
400ee9: e8 4a 04 00 00 callq 401338 <strings_not_equal>
400eee: 85 c0 test %eax,%eax
400ef0: 74 05 je 400ef7 <phase_1+0x17>
400ef2: e8 43 05 00 00 callq 40143a <explode_bomb>
400ef7: 48 83 c4 08 add $0x8,%rsp
400efb: c3 retq
0000000000400efc <phase_2>:
400efc: 55 push %rbp
400efd: 53 push %rbx
400efe: 48 83 ec 28 sub $0x28,%rsp
400f02: 48 89 e6 mov %rsp,%rsi
400f05: e8 52 05 00 00 callq 40145c <read_six_numbers>
400f0a: 83 3c 24 01 cmpl $0x1,(%rsp)
400f0e: 74 20 je 400f30 <phase_2+0x34>
400f10: e8 25 05 00 00 callq 40143a <explode_bomb>
400f15: eb 19 jmp 400f30 <phase_2+0x34>
400f17: 8b 43 fc mov -0x4(%rbx),%eax
400f1a: 01 c0 add %eax,%eax
400f1c: 39 03 cmp %eax,(%rbx)
400f1e: 74 05 je 400f25 <phase_2+0x29>
400f20: e8 15 05 00 00 callq 40143a <explode_bomb>
400f25: 48 83 c3 04 add $0x4,%rbx
400f29: 48 39 eb cmp %rbp,%rbx
400f2c: 75 e9 jne 400f17 <phase_2+0x1b>
400f2e: eb 0c jmp 400f3c <phase_2+0x40>
400f30: 48 8d 5c 24 04 lea 0x4(%rsp),%rbx
400f35: 48 8d 6c 24 18 lea 0x18(%rsp),%rbp
400f3a: eb db jmp 400f17 <phase_2+0x1b>
400f3c: 48 83 c4 28 add $0x28,%rsp
400f40: 5b pop %rbx
400f41: 5d pop %rbp
400f42: c3 retq
0000000000400f43 <phase_3>:
400f43: 48 83 ec 18 sub $0x18,%rsp
400f47: 48 8d 4c 24 0c lea 0xc(%rsp),%rcx
400f4c: 48 8d 54 24 08 lea 0x8(%rsp),%rdx
400f51: be cf 25 40 00 mov $0x4025cf,%esi
400f56: b8 00 00 00 00 mov $0x0,%eax
400f5b: e8 90 fc ff ff callq 400bf0 <__isoc99_sscanf@plt>
400f60: 83 f8 01 cmp $0x1,%eax
400f63: 7f 05 jg 400f6a <phase_3+0x27>
400f65: e8 d0 04 00 00 callq 40143a <explode_bomb>
400f6a: 83 7c 24 08 07 cmpl $0x7,0x8(%rsp)
400f6f: 77 3c ja 400fad <phase_3+0x6a>
400f71: 8b 44 24 08 mov 0x8(%rsp),%eax
400f75: ff 24 c5 70 24 40 00 jmpq *0x402470(,%rax,8)
400f7c: b8 cf 00 00 00 mov $0xcf,%eax
400f81: eb 3b jmp 400fbe <phase_3+0x7b>
400f83: b8 c3 02 00 00 mov $0x2c3,%eax
400f88: eb 34 jmp 400fbe <phase_3+0x7b>
400f8a: b8 00 01 00 00 mov $0x100,%eax
400f8f: eb 2d jmp 400fbe <phase_3+0x7b>
400f91: b8 85 01 00 00 mov $0x185,%eax
400f96: eb 26 jmp 400fbe <phase_3+0x7b>
400f98: b8 ce 00 00 00 mov $0xce,%eax
400f9d: eb 1f jmp 400fbe <phase_3+0x7b>
400f9f: b8 aa 02 00 00 mov $0x2aa,%eax
400fa4: eb 18 jmp 400fbe <phase_3+0x7b>
400fa6: b8 47 01 00 00 mov $0x147,%eax
400fab: eb 11 jmp 400fbe <phase_3+0x7b>
400fad: e8 88 04 00 00 callq 40143a <explode_bomb>
400fb2: b8 00 00 00 00 mov $0x0,%eax
400fb7: eb 05 jmp 400fbe <phase_3+0x7b>
400fb9: b8 37 01 00 00 mov $0x137,%eax
400fbe: 3b 44 24 0c cmp 0xc(%rsp),%eax
400fc2: 74 05 je 400fc9 <phase_3+0x86>
400fc4: e8 71 04 00 00 callq 40143a <explode_bomb>
400fc9: 48 83 c4 18 add $0x18,%rsp
400fcd: c3 retq
0000000000400fce <func4>:
400fce: 48 83 ec 08 sub $0x8,%rsp
400fd2: 89 d0 mov %edx,%eax
400fd4: 29 f0 sub %esi,%eax
400fd6: 89 c1 mov %eax,%ecx
400fd8: c1 e9 1f shr $0x1f,%ecx
400fdb: 01 c8 add %ecx,%eax
400fdd: d1 f8 sar %eax
400fdf: 8d 0c 30 lea (%rax,%rsi,1),%ecx
400fe2: 39 f9 cmp %edi,%ecx
400fe4: 7e 0c jle 400ff2 <func4+0x24>
400fe6: 8d 51 ff lea -0x1(%rcx),%edx
400fe9: e8 e0 ff ff ff callq 400fce <func4>
400fee: 01 c0 add %eax,%eax
400ff0: eb 15 jmp 401007 <func4+0x39>
400ff2: b8 00 00 00 00 mov $0x0,%eax
400ff7: 39 f9 cmp %edi,%ecx
400ff9: 7d 0c jge 401007 <func4+0x39>
400ffb: 8d 71 01 lea 0x1(%rcx),%esi
400ffe: e8 cb ff ff ff callq 400fce <func4>
401003: 8d 44 00 01 lea 0x1(%rax,%rax,1),%eax
401007: 48 83 c4 08 add $0x8,%rsp
40100b: c3 retq
000000000040100c <phase_4>:
40100c: 48 83 ec 18 sub $0x18,%rsp
401010: 48 8d 4c 24 0c lea 0xc(%rsp),%rcx
401015: 48 8d 54 24 08 lea 0x8(%rsp),%rdx
40101a: be cf 25 40 00 mov $0x4025cf,%esi
40101f: b8 00 00 00 00 mov $0x0,%eax
401024: e8 c7 fb ff ff callq 400bf0 <__isoc99_sscanf@plt>
401029: 83 f8 02 cmp $0x2,%eax
40102c: 75 07 jne 401035 <phase_4+0x29>
40102e: 83 7c 24 08 0e cmpl $0xe,0x8(%rsp)
401033: 76 05 jbe 40103a <phase_4+0x2e>
401035: e8 00 04 00 00 callq 40143a <explode_bomb>
40103a: ba 0e 00 00 00 mov $0xe,%edx
40103f: be 00 00 00 00 mov $0x0,%esi
401044: 8b 7c 24 08 mov 0x8(%rsp),%edi
401048: e8 81 ff ff ff callq 400fce <func4>
40104d: 85 c0 test %eax,%eax
40104f: 75 07 jne 401058 <phase_4+0x4c>
401051: 83 7c 24 0c 00 cmpl $0x0,0xc(%rsp)
401056: 74 05 je 40105d <phase_4+0x51>
401058: e8 dd 03 00 00 callq 40143a <explode_bomb>
40105d: 48 83 c4 18 add $0x18,%rsp
401061: c3 retq
0000000000401062 <phase_5>:
401062: 53 push %rbx
401063: 48 83 ec 20 sub $0x20,%rsp
401067: 48 89 fb mov %rdi,%rbx
40106a: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
401071: 00 00
401073: 48 89 44 24 18 mov %rax,0x18(%rsp)
401078: 31 c0 xor %eax,%eax
40107a: e8 9c 02 00 00 callq 40131b <string_length>
40107f: 83 f8 06 cmp $0x6,%eax
401082: 74 4e je 4010d2 <phase_5+0x70>
401084: e8 b1 03 00 00 callq 40143a <explode_bomb>
401089: eb 47 jmp 4010d2 <phase_5+0x70>
40108b: 0f b6 0c 03 movzbl (%rbx,%rax,1),%ecx
40108f: 88 0c 24 mov %cl,(%rsp)
401092: 48 8b 14 24 mov (%rsp),%rdx
401096: 83 e2 0f and $0xf,%edx
401099: 0f b6 92 b0 24 40 00 movzbl 0x4024b0(%rdx),%edx
4010a0: 88 54 04 10 mov %dl,0x10(%rsp,%rax,1)
4010a4: 48 83 c0 01 add $0x1,%rax
4010a8: 48 83 f8 06 cmp $0x6,%rax
4010ac: 75 dd jne 40108b <phase_5+0x29>
4010ae: c6 44 24 16 00 movb $0x0,0x16(%rsp)
4010b3: be 5e 24 40 00 mov $0x40245e,%esi
4010b8: 48 8d 7c 24 10 lea 0x10(%rsp),%rdi
4010bd: e8 76 02 00 00 callq 401338 <strings_not_equal>
4010c2: 85 c0 test %eax,%eax
4010c4: 74 13 je 4010d9 <phase_5+0x77>
4010c6: e8 6f 03 00 00 callq 40143a <explode_bomb>
4010cb: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
4010d0: eb 07 jmp 4010d9 <phase_5+0x77>
4010d2: b8 00 00 00 00 mov $0x0,%eax
4010d7: eb b2 jmp 40108b <phase_5+0x29>
4010d9: 48 8b 44 24 18 mov 0x18(%rsp),%rax
4010de: 64 48 33 04 25 28 00 xor %fs:0x28,%rax
4010e5: 00 00
4010e7: 74 05 je 4010ee <phase_5+0x8c>
4010e9: e8 42 fa ff ff callq 400b30 <__stack_chk_fail@plt>
4010ee: 48 83 c4 20 add $0x20,%rsp
4010f2: 5b pop %rbx
4010f3: c3 retq
00000000004010f4 <phase_6>:
4010f4: 41 56 push %r14
4010f6: 41 55 push %r13
4010f8: 41 54 push %r12
4010fa: 55 push %rbp
4010fb: 53 push %rbx
4010fc: 48 83 ec 50 sub $0x50,%rsp
401100: 49 89 e5 mov %rsp,%r13
401103: 48 89 e6 mov %rsp,%rsi
401106: e8 51 03 00 00 callq 40145c <read_six_numbers>
40110b: 49 89 e6 mov %rsp,%r14
40110e: 41 bc 00 00 00 00 mov $0x0,%r12d
401114: 4c 89 ed mov %r13,%rbp
401117: 41 8b 45 00 mov 0x0(%r13),%eax
40111b: 83 e8 01 sub $0x1,%eax
40111e: 83 f8 05 cmp $0x5,%eax
401121: 76 05 jbe 401128 <phase_6+0x34>
401123: e8 12 03 00 00 callq 40143a <explode_bomb>
401128: 41 83 c4 01 add $0x1,%r12d
40112c: 41 83 fc 06 cmp $0x6,%r12d
401130: 74 21 je 401153 <phase_6+0x5f>
401132: 44 89 e3 mov %r12d,%ebx
401135: 48 63 c3 movslq %ebx,%rax
401138: 8b 04 84 mov (%rsp,%rax,4),%eax
40113b: 39 45 00 cmp %eax,0x0(%rbp)
40113e: 75 05 jne 401145 <phase_6+0x51>
401140: e8 f5 02 00 00 callq 40143a <explode_bomb>
401145: 83 c3 01 add $0x1,%ebx
401148: 83 fb 05 cmp $0x5,%ebx
40114b: 7e e8 jle 401135 <phase_6+0x41>
40114d: 49 83 c5 04 add $0x4,%r13
401151: eb c1 jmp 401114 <phase_6+0x20>
401153: 48 8d 74 24 18 lea 0x18(%rsp),%rsi
401158: 4c 89 f0 mov %r14,%rax
40115b: b9 07 00 00 00 mov $0x7,%ecx
401160: 89 ca mov %ecx,%edx
401162: 2b 10 sub (%rax),%edx
401164: 89 10 mov %edx,(%rax)
401166: 48 83 c0 04 add $0x4,%rax
40116a: 48 39 f0 cmp %rsi,%rax
40116d: 75 f1 jne 401160 <phase_6+0x6c>
40116f: be 00 00 00 00 mov $0x0,%esi
401174: eb 21 jmp 401197 <phase_6+0xa3>
401176: 48 8b 52 08 mov 0x8(%rdx),%rdx
40117a: 83 c0 01 add $0x1,%eax
40117d: 39 c8 cmp %ecx,%eax
40117f: 75 f5 jne 401176 <phase_6+0x82>
401181: eb 05 jmp 401188 <phase_6+0x94>
401183: ba d0 32 60 00 mov $0x6032d0,%edx
401188: 48 89 54 74 20 mov %rdx,0x20(%rsp,%rsi,2)
40118d: 48 83 c6 04 add $0x4,%rsi
401191: 48 83 fe 18 cmp $0x18,%rsi
401195: 74 14 je 4011ab <phase_6+0xb7>
401197: 8b 0c 34 mov (%rsp,%rsi,1),%ecx
40119a: 83 f9 01 cmp $0x1,%ecx
40119d: 7e e4 jle 401183 <phase_6+0x8f>
40119f: b8 01 00 00 00 mov $0x1,%eax
4011a4: ba d0 32 60 00 mov $0x6032d0,%edx
4011a9: eb cb jmp 401176 <phase_6+0x82>
4011ab: 48 8b 5c 24 20 mov 0x20(%rsp),%rbx
4011b0: 48 8d 44 24 28 lea 0x28(%rsp),%rax
4011b5: 48 8d 74 24 50 lea 0x50(%rsp),%rsi
4011ba: 48 89 d9 mov %rbx,%rcx
4011bd: 48 8b 10 mov (%rax),%rdx
4011c0: 48 89 51 08 mov %rdx,0x8(%rcx)
4011c4: 48 83 c0 08 add $0x8,%rax
4011c8: 48 39 f0 cmp %rsi,%rax
4011cb: 74 05 je 4011d2 <phase_6+0xde>
4011cd: 48 89 d1 mov %rdx,%rcx
4011d0: eb eb jmp 4011bd <phase_6+0xc9>
4011d2: 48 c7 42 08 00 00 00 movq $0x0,0x8(%rdx)
4011d9: 00
4011da: bd 05 00 00 00 mov $0x5,%ebp
4011df: 48 8b 43 08 mov 0x8(%rbx),%rax
4011e3: 8b 00 mov (%rax),%eax
4011e5: 39 03 cmp %eax,(%rbx)
4011e7: 7d 05 jge 4011ee <phase_6+0xfa>
4011e9: e8 4c 02 00 00 callq 40143a <explode_bomb>
4011ee: 48 8b 5b 08 mov 0x8(%rbx),%rbx
4011f2: 83 ed 01 sub $0x1,%ebp
4011f5: 75 e8 jne 4011df <phase_6+0xeb>
4011f7: 48 83 c4 50 add $0x50,%rsp
4011fb: 5b pop %rbx
4011fc: 5d pop %rbp
4011fd: 41 5c pop %r12
4011ff: 41 5d pop %r13
401201: 41 5e pop %r14
401203: c3 retq
0000000000401204 <fun7>:
401204: 48 83 ec 08 sub $0x8,%rsp
401208: 48 85 ff test %rdi,%rdi
40120b: 74 2b je 401238 <fun7+0x34>
40120d: 8b 17 mov (%rdi),%edx
40120f: 39 f2 cmp %esi,%edx
401211: 7e 0d jle 401220 <fun7+0x1c>
401213: 48 8b 7f 08 mov 0x8(%rdi),%rdi
401217: e8 e8 ff ff ff callq 401204 <fun7>
40121c: 01 c0 add %eax,%eax
40121e: eb 1d jmp 40123d <fun7+0x39>
401220: b8 00 00 00 00 mov $0x0,%eax
401225: 39 f2 cmp %esi,%edx
401227: 74 14 je 40123d <fun7+0x39>
401229: 48 8b 7f 10 mov 0x10(%rdi),%rdi
40122d: e8 d2 ff ff ff callq 401204 <fun7>
401232: 8d 44 00 01 lea 0x1(%rax,%rax,1),%eax
401236: eb 05 jmp 40123d <fun7+0x39>
401238: b8 ff ff ff ff mov $0xffffffff,%eax
40123d: 48 83 c4 08 add $0x8,%rsp
401241: c3 retq
0000000000401242 <secret_phase>:
401242: 53 push %rbx
401243: e8 56 02 00 00 callq 40149e <read_line>
401248: ba 0a 00 00 00 mov $0xa,%edx
40124d: be 00 00 00 00 mov $0x0,%esi
401252: 48 89 c7 mov %rax,%rdi
401255: e8 76 f9 ff ff callq 400bd0 <strtol@plt>
40125a: 48 89 c3 mov %rax,%rbx
40125d: 8d 40 ff lea -0x1(%rax),%eax
401260: 3d e8 03 00 00 cmp $0x3e8,%eax
401265: 76 05 jbe 40126c <secret_phase+0x2a>
401267: e8 ce 01 00 00 callq 40143a <explode_bomb>
40126c: 89 de mov %ebx,%esi
40126e: bf f0 30 60 00 mov $0x6030f0,%edi
401273: e8 8c ff ff ff callq 401204 <fun7>
401278: 83 f8 02 cmp $0x2,%eax
40127b: 74 05 je 401282 <secret_phase+0x40>
40127d: e8 b8 01 00 00 callq 40143a <explode_bomb>
401282: bf 38 24 40 00 mov $0x402438,%edi
401287: e8 84 f8 ff ff callq 400b10 <puts@plt>
40128c: e8 33 03 00 00 callq 4015c4 <phase_defused>
401291: 5b pop %rbx
401292: c3 retq
401293: 90 nop
401294: 90 nop
401295: 90 nop
401296: 90 nop
401297: 90 nop
401298: 90 nop
401299: 90 nop
40129a: 90 nop
40129b: 90 nop
40129c: 90 nop
40129d: 90 nop
40129e: 90 nop
40129f: 90 nop
00000000004012a0 <sig_handler>:
4012a0: 48 83 ec 08 sub $0x8,%rsp
4012a4: bf c0 24 40 00 mov $0x4024c0,%edi
4012a9: e8 62 f8 ff ff callq 400b10 <puts@plt>
4012ae: bf 03 00 00 00 mov $0x3,%edi
4012b3: e8 98 f9 ff ff callq 400c50 <sleep@plt>
4012b8: be 82 25 40 00 mov $0x402582,%esi
4012bd: bf 01 00 00 00 mov $0x1,%edi
4012c2: b8 00 00 00 00 mov $0x0,%eax
4012c7: e8 34 f9 ff ff callq 400c00 <__printf_chk@plt>
4012cc: 48 8b 3d 6d 24 20 00 mov 0x20246d(%rip),%rdi # 603740 <__bss_start>
4012d3: e8 08 f9 ff ff callq 400be0 <fflush@plt>
4012d8: bf 01 00 00 00 mov $0x1,%edi
4012dd: e8 6e f9 ff ff callq 400c50 <sleep@plt>
4012e2: bf 8a 25 40 00 mov $0x40258a,%edi
4012e7: e8 24 f8 ff ff callq 400b10 <puts@plt>
4012ec: bf 10 00 00 00 mov $0x10,%edi
4012f1: e8 2a f9 ff ff callq 400c20 <exit@plt>
00000000004012f6 <invalid_phase>:
4012f6: 48 83 ec 08 sub $0x8,%rsp
4012fa: 48 89 fa mov %rdi,%rdx
4012fd: be 92 25 40 00 mov $0x402592,%esi
401302: bf 01 00 00 00 mov $0x1,%edi
401307: b8 00 00 00 00 mov $0x0,%eax
40130c: e8 ef f8 ff ff callq 400c00 <__printf_chk@plt>
401311: bf 08 00 00 00 mov $0x8,%edi
401316: e8 05 f9 ff ff callq 400c20 <exit@plt>
000000000040131b <string_length>:
40131b: 80 3f 00 cmpb $0x0,(%rdi)
40131e: 74 12 je 401332 <string_length+0x17>
401320: 48 89 fa mov %rdi,%rdx
401323: 48 83 c2 01 add $0x1,%rdx
401327: 89 d0 mov %edx,%eax
401329: 29 f8 sub %edi,%eax
40132b: 80 3a 00 cmpb $0x0,(%rdx)
40132e: 75 f3 jne 401323 <string_length+0x8>
401330: f3 c3 repz retq
401332: b8 00 00 00 00 mov $0x0,%eax
401337: c3 retq
0000000000401338 <strings_not_equal>:
401338: 41 54 push %r12
40133a: 55 push %rbp
40133b: 53 push %rbx
40133c: 48 89 fb mov %rdi,%rbx
40133f: 48 89 f5 mov %rsi,%rbp
401342: e8 d4 ff ff ff callq 40131b <string_length>
401347: 41 89 c4 mov %eax,%r12d
40134a: 48 89 ef mov %rbp,%rdi
40134d: e8 c9 ff ff ff callq 40131b <string_length>
401352: ba 01 00 00 00 mov $0x1,%edx
401357: 41 39 c4 cmp %eax,%r12d
40135a: 75 3f jne 40139b <strings_not_equal+0x63>
40135c: 0f b6 03 movzbl (%rbx),%eax
40135f: 84 c0 test %al,%al
401361: 74 25 je 401388 <strings_not_equal+0x50>
401363: 3a 45 00 cmp 0x0(%rbp),%al
401366: 74 0a je 401372 <strings_not_equal+0x3a>
401368: eb 25 jmp 40138f <strings_not_equal+0x57>
40136a: 3a 45 00 cmp 0x0(%rbp),%al
40136d: 0f 1f 00 nopl (%rax)
401370: 75 24 jne 401396 <strings_not_equal+0x5e>
401372: 48 83 c3 01 add $0x1,%rbx
401376: 48 83 c5 01 add $0x1,%rbp
40137a: 0f b6 03 movzbl (%rbx),%eax
40137d: 84 c0 test %al,%al
40137f: 75 e9 jne 40136a <strings_not_equal+0x32>
401381: ba 00 00 00 00 mov $0x0,%edx
401386: eb 13 jmp 40139b <strings_not_equal+0x63>
401388: ba 00 00 00 00 mov $0x0,%edx
40138d: eb 0c jmp 40139b <strings_not_equal+0x63>
40138f: ba 01 00 00 00 mov $0x1,%edx
401394: eb 05 jmp 40139b <strings_not_equal+0x63>
401396: ba 01 00 00 00 mov $0x1,%edx
40139b: 89 d0 mov %edx,%eax
40139d: 5b pop %rbx
40139e: 5d pop %rbp
40139f: 41 5c pop %r12
4013a1: c3 retq
00000000004013a2 <initialize_bomb>:
4013a2: 48 83 ec 08 sub $0x8,%rsp
4013a6: be a0 12 40 00 mov $0x4012a0,%esi
4013ab: bf 02 00 00 00 mov $0x2,%edi
4013b0: e8 db f7 ff ff callq 400b90 <signal@plt>
4013b5: 48 83 c4 08 add $0x8,%rsp
4013b9: c3 retq
00000000004013ba <initialize_bomb_solve>:
4013ba: f3 c3 repz retq
00000000004013bc <blank_line>:
4013bc: 55 push %rbp
4013bd: 53 push %rbx
4013be: 48 83 ec 08 sub $0x8,%rsp
4013c2: 48 89 fb mov %rdi,%rbx
4013c5: eb 17 jmp 4013de <blank_line+0x22>
4013c7: e8 94 f8 ff ff callq 400c60 <__ctype_b_loc@plt>
4013cc: 48 83 c3 01 add $0x1,%rbx
4013d0: 48 0f be ed movsbq %bpl,%rbp
4013d4: 48 8b 00 mov (%rax),%rax
4013d7: f6 44 68 01 20 testb $0x20,0x1(%rax,%rbp,2)
4013dc: 74 0f je 4013ed <blank_line+0x31>
4013de: 0f b6 2b movzbl (%rbx),%ebp
4013e1: 40 84 ed test %bpl,%bpl
4013e4: 75 e1 jne 4013c7 <blank_line+0xb>
4013e6: b8 01 00 00 00 mov $0x1,%eax
4013eb: eb 05 jmp 4013f2 <blank_line+0x36>
4013ed: b8 00 00 00 00 mov $0x0,%eax
4013f2: 48 83 c4 08 add $0x8,%rsp
4013f6: 5b pop %rbx
4013f7: 5d pop %rbp
4013f8: c3 retq
00000000004013f9 <skip>:
4013f9: 53 push %rbx
4013fa: 48 63 05 5f 23 20 00 movslq 0x20235f(%rip),%rax # 603760 <num_input_strings>
401401: 48 8d 3c 80 lea (%rax,%rax,4),%rdi
401405: 48 c1 e7 04 shl $0x4,%rdi
401409: 48 81 c7 80 37 60 00 add $0x603780,%rdi
401410: 48 8b 15 51 23 20 00 mov 0x202351(%rip),%rdx # 603768 <infile>
401417: be 50 00 00 00 mov $0x50,%esi
40141c: e8 5f f7 ff ff callq 400b80 <fgets@plt>
401421: 48 89 c3 mov %rax,%rbx
401424: 48 85 c0 test %rax,%rax
401427: 74 0c je 401435 <skip+0x3c>
401429: 48 89 c7 mov %rax,%rdi
40142c: e8 8b ff ff ff callq 4013bc <blank_line>
401431: 85 c0 test %eax,%eax
401433: 75 c5 jne 4013fa <skip+0x1>
401435: 48 89 d8 mov %rbx,%rax
401438: 5b pop %rbx
401439: c3 retq
000000000040143a <explode_bomb>:
40143a: 48 83 ec 08 sub $0x8,%rsp
40143e: bf a3 25 40 00 mov $0x4025a3,%edi
401443: e8 c8 f6 ff ff callq 400b10 <puts@plt>
401448: bf ac 25 40 00 mov $0x4025ac,%edi
40144d: e8 be f6 ff ff callq 400b10 <puts@plt>
401452: bf 08 00 00 00 mov $0x8,%edi
401457: e8 c4 f7 ff ff callq 400c20 <exit@plt>
000000000040145c <read_six_numbers>:
40145c: 48 83 ec 18 sub $0x18,%rsp
401460: 48 89 f2 mov %rsi,%rdx
401463: 48 8d 4e 04 lea 0x4(%rsi),%rcx
401467: 48 8d 46 14 lea 0x14(%rsi),%rax
40146b: 48 89 44 24 08 mov %rax,0x8(%rsp)
401470: 48 8d 46 10 lea 0x10(%rsi),%rax
401474: 48 89 04 24 mov %rax,(%rsp)
401478: 4c 8d 4e 0c lea 0xc(%rsi),%r9
40147c: 4c 8d 46 08 lea 0x8(%rsi),%r8
401480: be c3 25 40 00 mov $0x4025c3,%esi
401485: b8 00 00 00 00 mov $0x0,%eax
40148a: e8 61 f7 ff ff callq 400bf0 <__isoc99_sscanf@plt>
40148f: 83 f8 05 cmp $0x5,%eax
401492: 7f 05 jg 401499 <read_six_numbers+0x3d>
401494: e8 a1 ff ff ff callq 40143a <explode_bomb>
401499: 48 83 c4 18 add $0x18,%rsp
40149d: c3 retq
000000000040149e <read_line>:
40149e: 48 83 ec 08 sub $0x8,%rsp
4014a2: b8 00 00 00 00 mov $0x0,%eax
4014a7: e8 4d ff ff ff callq 4013f9 <skip>
4014ac: 48 85 c0 test %rax,%rax
4014af: 75 6e jne 40151f <read_line+0x81>
4014b1: 48 8b 05 90 22 20 00 mov 0x202290(%rip),%rax # 603748 <stdin@@GLIBC_2.2.5>
4014b8: 48 39 05 a9 22 20 00 cmp %rax,0x2022a9(%rip) # 603768 <infile>
4014bf: 75 14 jne 4014d5 <read_line+0x37>
4014c1: bf d5 25 40 00 mov $0x4025d5,%edi
4014c6: e8 45 f6 ff ff callq 400b10 <puts@plt>
4014cb: bf 08 00 00 00 mov $0x8,%edi
4014d0: e8 4b f7 ff ff callq 400c20 <exit@plt>
4014d5: bf f3 25 40 00 mov $0x4025f3,%edi
4014da: e8 01 f6 ff ff callq 400ae0 <getenv@plt>
4014df: 48 85 c0 test %rax,%rax
4014e2: 74 0a je 4014ee <read_line+0x50>
4014e4: bf 00 00 00 00 mov $0x0,%edi
4014e9: e8 32 f7 ff ff callq 400c20 <exit@plt>
4014ee: 48 8b 05 53 22 20 00 mov 0x202253(%rip),%rax # 603748 <stdin@@GLIBC_2.2.5>
4014f5: 48 89 05 6c 22 20 00 mov %rax,0x20226c(%rip) # 603768 <infile>
4014fc: b8 00 00 00 00 mov $0x0,%eax
401501: e8 f3 fe ff ff callq 4013f9 <skip>
401506: 48 85 c0 test %rax,%rax
401509: 75 14 jne 40151f <read_line+0x81>
40150b: bf d5 25 40 00 mov $0x4025d5,%edi
401510: e8 fb f5 ff ff callq 400b10 <puts@plt>
401515: bf 00 00 00 00 mov $0x0,%edi
40151a: e8 01 f7 ff ff callq 400c20 <exit@plt>
40151f: 8b 15 3b 22 20 00 mov 0x20223b(%rip),%edx # 603760 <num_input_strings>
401525: 48 63 c2 movslq %edx,%rax
401528: 48 8d 34 80 lea (%rax,%rax,4),%rsi
40152c: 48 c1 e6 04 shl $0x4,%rsi
401530: 48 81 c6 80 37 60 00 add $0x603780,%rsi
401537: 48 89 f7 mov %rsi,%rdi
40153a: b8 00 00 00 00 mov $0x0,%eax
40153f: 48 c7 c1 ff ff ff ff mov $0xffffffffffffffff,%rcx
401546: f2 ae repnz scas %es:(%rdi),%al
401548: 48 f7 d1 not %rcx
40154b: 48 83 e9 01 sub $0x1,%rcx
40154f: 83 f9 4e cmp $0x4e,%ecx
401552: 7e 46 jle 40159a <read_line+0xfc>
401554: bf fe 25 40 00 mov $0x4025fe,%edi
401559: e8 b2 f5 ff ff callq 400b10 <puts@plt>
40155e: 8b 05 fc 21 20 00 mov 0x2021fc(%rip),%eax # 603760 <num_input_strings>
401564: 8d 50 01 lea 0x1(%rax),%edx
401567: 89 15 f3 21 20 00 mov %edx,0x2021f3(%rip) # 603760 <num_input_strings>
40156d: 48 98 cltq
40156f: 48 6b c0 50 imul $0x50,%rax,%rax
401573: 48 bf 2a 2a 2a 74 72 movabs $0x636e7572742a2a2a,%rdi
40157a: 75 6e 63
40157d: 48 89 b8 80 37 60 00 mov %rdi,0x603780(%rax)
401584: 48 bf 61 74 65 64 2a movabs $0x2a2a2a64657461,%rdi
40158b: 2a 2a 00
40158e: 48 89 b8 88 37 60 00 mov %rdi,0x603788(%rax)
401595: e8 a0 fe ff ff callq 40143a <explode_bomb>
40159a: 83 e9 01 sub $0x1,%ecx
40159d: 48 63 c9 movslq %ecx,%rcx
4015a0: 48 63 c2 movslq %edx,%rax
4015a3: 48 8d 04 80 lea (%rax,%rax,4),%rax
4015a7: 48 c1 e0 04 shl $0x4,%rax
4015ab: c6 84 01 80 37 60 00 movb $0x0,0x603780(%rcx,%rax,1)
4015b2: 00
4015b3: 83 c2 01 add $0x1,%edx
4015b6: 89 15 a4 21 20 00 mov %edx,0x2021a4(%rip) # 603760 <num_input_strings>
4015bc: 48 89 f0 mov %rsi,%rax
4015bf: 48 83 c4 08 add $0x8,%rsp
4015c3: c3 retq
00000000004015c4 <phase_defused>:
4015c4: 48 83 ec 78 sub $0x78,%rsp
4015c8: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
4015cf: 00 00
4015d1: 48 89 44 24 68 mov %rax,0x68(%rsp)
4015d6: 31 c0 xor %eax,%eax
4015d8: 83 3d 81 21 20 00 06 cmpl $0x6,0x202181(%rip) # 603760 <num_input_strings>
4015df: 75 5e jne 40163f <phase_defused+0x7b>
4015e1: 4c 8d 44 24 10 lea 0x10(%rsp),%r8
4015e6: 48 8d 4c 24 0c lea 0xc(%rsp),%rcx
4015eb: 48 8d 54 24 08 lea 0x8(%rsp),%rdx
4015f0: be 19 26 40 00 mov $0x402619,%esi
4015f5: bf 70 38 60 00 mov $0x603870,%edi
4015fa: e8 f1 f5 ff ff callq 400bf0 <__isoc99_sscanf@plt>
4015ff: 83 f8 03 cmp $0x3,%eax
401602: 75 31 jne 401635 <phase_defused+0x71>
401604: be 22 26 40 00 mov $0x402622,%esi
401609: 48 8d 7c 24 10 lea 0x10(%rsp),%rdi
40160e: e8 25 fd ff ff callq 401338 <strings_not_equal>
401613: 85 c0 test %eax,%eax
401615: 75 1e jne 401635 <phase_defused+0x71>
401617: bf f8 24 40 00 mov $0x4024f8,%edi
40161c: e8 ef f4 ff ff callq 400b10 <puts@plt>
401621: bf 20 25 40 00 mov $0x402520,%edi
401626: e8 e5 f4 ff ff callq 400b10 <puts@plt>
40162b: b8 00 00 00 00 mov $0x0,%eax
401630: e8 0d fc ff ff callq 401242 <secret_phase>
401635: bf 58 25 40 00 mov $0x402558,%edi
40163a: e8 d1 f4 ff ff callq 400b10 <puts@plt>
40163f: 48 8b 44 24 68 mov 0x68(%rsp),%rax
401644: 64 48 33 04 25 28 00 xor %fs:0x28,%rax
40164b: 00 00
40164d: 74 05 je 401654 <phase_defused+0x90>
40164f: e8 dc f4 ff ff callq 400b30 <__stack_chk_fail@plt>
401654: 48 83 c4 78 add $0x78,%rsp
401658: c3 retq
401659: 90 nop
40165a: 90 nop
40165b: 90 nop
40165c: 90 nop
40165d: 90 nop
40165e: 90 nop
40165f: 90 nop
0000000000401660 <sigalrm_handler>:
401660: 48 83 ec 08 sub $0x8,%rsp
401664: b9 00 00 00 00 mov $0x0,%ecx
401669: ba 78 26 40 00 mov $0x402678,%edx
40166e: be 01 00 00 00 mov $0x1,%esi
401673: 48 8b 3d d6 20 20 00 mov 0x2020d6(%rip),%rdi # 603750 <stderr@@GLIBC_2.2.5>
40167a: b8 00 00 00 00 mov $0x0,%eax
40167f: e8 bc f5 ff ff callq 400c40 <__fprintf_chk@plt>
401684: bf 01 00 00 00 mov $0x1,%edi
401689: e8 92 f5 ff ff callq 400c20 <exit@plt>
000000000040168e <rio_readlineb>:
40168e: 41 57 push %r15
401690: 41 56 push %r14
401692: 41 55 push %r13
401694: 41 54 push %r12
401696: 55 push %rbp
401697: 53 push %rbx
401698: 48 83 ec 38 sub $0x38,%rsp
40169c: 49 89 f6 mov %rsi,%r14
40169f: 48 89 54 24 18 mov %rdx,0x18(%rsp)
4016a4: 48 83 fa 01 cmp $0x1,%rdx
4016a8: 0f 86 c9 00 00 00 jbe 401777 <rio_readlineb+0xe9>
4016ae: 48 89 fb mov %rdi,%rbx
4016b1: 41 bd 01 00 00 00 mov $0x1,%r13d
4016b7: 4c 8d 67 10 lea 0x10(%rdi),%r12
4016bb: eb 30 jmp 4016ed <rio_readlineb+0x5f>
4016bd: ba 00 20 00 00 mov $0x2000,%edx
4016c2: 4c 89 e6 mov %r12,%rsi
4016c5: 8b 3b mov (%rbx),%edi
4016c7: e8 94 f4 ff ff callq 400b60 <read@plt>
4016cc: 89 43 04 mov %eax,0x4(%rbx)
4016cf: 85 c0 test %eax,%eax
4016d1: 79 12 jns 4016e5 <rio_readlineb+0x57>
4016d3: e8 18 f4 ff ff callq 400af0 <__errno_location@plt>
4016d8: 83 38 04 cmpl $0x4,(%rax)
4016db: 74 10 je 4016ed <rio_readlineb+0x5f>
4016dd: 0f 1f 00 nopl (%rax)
4016e0: e9 a1 00 00 00 jmpq 401786 <rio_readlineb+0xf8>
4016e5: 85 c0 test %eax,%eax
4016e7: 74 71 je 40175a <rio_readlineb+0xcc>
4016e9: 4c 89 63 08 mov %r12,0x8(%rbx)
4016ed: 8b 6b 04 mov 0x4(%rbx),%ebp
4016f0: 85 ed test %ebp,%ebp
4016f2: 7e c9 jle 4016bd <rio_readlineb+0x2f>
4016f4: 85 ed test %ebp,%ebp
4016f6: 41 0f 95 c7 setne %r15b
4016fa: 41 0f b6 c7 movzbl %r15b,%eax
4016fe: 89 44 24 0c mov %eax,0xc(%rsp)
401702: 45 0f b6 ff movzbl %r15b,%r15d
401706: 48 8b 4b 08 mov 0x8(%rbx),%rcx
40170a: 48 89 ce mov %rcx,%rsi
40170d: b9 01 00 00 00 mov $0x1,%ecx
401712: 4c 89 fa mov %r15,%rdx
401715: 48 89 74 24 10 mov %rsi,0x10(%rsp)
40171a: 48 8d 7c 24 2f lea 0x2f(%rsp),%rdi
40171f: e8 9c f4 ff ff callq 400bc0 <__memcpy_chk@plt>
401724: 4c 03 7c 24 10 add 0x10(%rsp),%r15
401729: 4c 89 7b 08 mov %r15,0x8(%rbx)
40172d: 8b 44 24 0c mov 0xc(%rsp),%eax
401731: 29 c5 sub %eax,%ebp
401733: 89 6b 04 mov %ebp,0x4(%rbx)
401736: 83 f8 01 cmp $0x1,%eax
401739: 75 13 jne 40174e <rio_readlineb+0xc0>
40173b: 49 83 c6 01 add $0x1,%r14
40173f: 0f b6 44 24 2f movzbl 0x2f(%rsp),%eax
401744: 41 88 46 ff mov %al,-0x1(%r14)
401748: 3c 0a cmp $0xa,%al
40174a: 75 18 jne 401764 <rio_readlineb+0xd6>
40174c: eb 2f jmp 40177d <rio_readlineb+0xef>
40174e: 83 7c 24 0c 00 cmpl $0x0,0xc(%rsp)
401753: 75 3a jne 40178f <rio_readlineb+0x101>
401755: 44 89 e8 mov %r13d,%eax
401758: eb 03 jmp 40175d <rio_readlineb+0xcf>
40175a: 44 89 e8 mov %r13d,%eax
40175d: 83 f8 01 cmp $0x1,%eax
401760: 75 1b jne 40177d <rio_readlineb+0xef>
401762: eb 34 jmp 401798 <rio_readlineb+0x10a>
401764: 41 83 c5 01 add $0x1,%r13d
401768: 49 63 c5 movslq %r13d,%rax
40176b: 48 3b 44 24 18 cmp 0x18(%rsp),%rax
401770: 73 0b jae 40177d <rio_readlineb+0xef>
401772: e9 76 ff ff ff jmpq 4016ed <rio_readlineb+0x5f>
401777: 41 bd 01 00 00 00 mov $0x1,%r13d
40177d: 41 c6 06 00 movb $0x0,(%r14)
401781: 49 63 c5 movslq %r13d,%rax
401784: eb 17 jmp 40179d <rio_readlineb+0x10f>
401786: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax
40178d: eb 0e jmp 40179d <rio_readlineb+0x10f>
40178f: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax
401796: eb 05 jmp 40179d <rio_readlineb+0x10f>
401798: b8 00 00 00 00 mov $0x0,%eax
40179d: 48 83 c4 38 add $0x38,%rsp
4017a1: 5b pop %rbx
4017a2: 5d pop %rbp
4017a3: 41 5c pop %r12
4017a5: 41 5d pop %r13
4017a7: 41 5e pop %r14
4017a9: 41 5f pop %r15
4017ab: c3 retq
Disoassembly of section .fini:
# 删除一些无关紧要的东西
文件的主旨大意就是这了,后面的文章就是分析每一个bomb
项目需要,要在本地的host上测试相关的deb更新的情况,下面是具体实现的脚本。
user@linux:~$ cat setup_deb_local_server.sh
#!/bin/bash
#1. mkdir <packagedir>
#2. dpkg-scanpackages packagedir | gzip > packagedir/Packages.gz
#3. user@linux:~$ cat /etc/apt/sources.list.d/test.list
#deb [trusted=yes] file:////home/user/ local_deb/
#4. apt-get update
# https://unix.stackexchange.com/questions/87130/how-to-quickly-create-a-local-apt-repository-for-random-packages-using-a-debian#
# https://www.cyberciti.biz/faq/sudo-append-data-text-to-file-on-linux-unix-macos/
DEB_DIR="/home/user/SX03.000_lite/l4e_deb_packages"
DEB_LOCAL_DIR="~/local_debs"
function mkdir_package(){
if [ -d $DEB_LOCAL_DIR ]; then
rm -rf $DEB_LOCAL_DIR
else
mkdir ~/local_debs
fi
cp $DEB_DIR/*.deb ~/local_debs
}
function reflash_deb(){
echo "first make sure you move deb to dir"
dpkg-scanpackages ~/local_debs | gzip > ~/local_debs/Packages.gz
}
function change_source_lists(){
pushd /etc/apt/sources.list.d
(sudo rm cuda-10-2-local-10.2.89.list nvidia-l4t-apt-source.list visionworks-sfm-repo.list visionworks-repo.list visionworks-tracking-repo.list)
if [ -f eswin-apt-source.list ]; then
(sudo mv eswin-apt-source.list eswin_deb.list.backup )
else
(sudo rm /etc/test_deb.list)
#(sudo touch /etc/test_deb.list)
fi
(echo -e "deb [trusted=yes] file:/// /home/user/local_debs/" | sudo tee -a /etc/apt/sources.list.d/test_deb.list)
popd
pushd /etc/apt
(sudo mv sources.list sources.list.backup)
popd
}
mkdir_package
reflash_deb
change_source_lists
这里直接使用一个脚本,把相关的debian包安装到对应的目录下,然后就可以执行sudo apt update
【http://jianjian.blog.51cto.com/35031/395468】
这些是软件包安装前后自动运行的可执行脚本. 统称为控制文件, 是 Deian 软件包的”控制”部分它们是:
preinst
Debian软件包(“.deb”)解压前执行的脚本, 为正在被升级的包停止相关服务,直到升级或安装完成。 (成功后执行 ‘postinst’ 脚本)。
postinst
主要完成软件包(“.deb”)安装完成后所需的配置工作. 通常, postinst 脚本要求用户输入, 和/或警告用户如果接受默认值, 应该记得按要求返回重新配置这个软件。 一个软件包安装或升级完成后,postinst 脚本驱动命令, 启动或重起相应的服务。
prerm
停止一个软件包的相关进程, 要卸载软件包的相关文件前执行。
postrm
修改相关文件或连接, 和/或卸载软件包所创建的文件。 当前的所有配置文件都可在 /var/lib/dpkg/info 目录下找到, 与 foo 软件包相关的命名以 “foo” 开头,以 “preinst”, “postinst”, 等为扩展。这个目录下的 foo.list 文件列出了软件包安装的所有文件。Debian里用apt-get安装或卸载软件时,会常发生前处理或后处理的错误,这时只要删除 对应的脚本文件,重新执行安装或卸载即可
[https://blog.csdn.net/yingyingququ/article/details/108848019]
preinst->postinst
prerm->postrm
prerm->postrm->postrm
prerm->preinst->postrm->postinst
这里,可以结合 官方手册来看这个问题:
https://www.debian.org/doc/debian-policy/ap-flowcharts.html
请参考这个文章
dts文件是由dtc工具编译,其工具在: out/target/product/xxx/obj/KERNEL_OBJ/scripts/dtc/dtc
要分析编译出的dtb文件,需要将dtb文件反向解析出dts文件,使用方法如下:
dtc -I dtb 123.dtb -O dts -o xxx.dts // I 大写 i ,表示输入,dtc -h 可以查看各个参数意义
dts –> dtc 用法:
dtc -I dts 123.dts -O dtb -o xxx.dtb
openembeded 有三个关键词:
bitbake: 可以想象成make
recipes: 是bitbake的入口文件,涉及到构建依赖 源码下载 配置 编译 build install 卸载等动作
layers: 在OpenEmbeded中,layer的概念是一个 recipes和相关配置文件的搜集整理集合,典型的分层主题是: kernel bsp board等。
最有用的layers是位于 build/conf/bblayers.conf 中
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk$ cat build/conf/bblayers.conf
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "7"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/vimer/riscv_test/w500/freedom-u-sdk/openembedded-core/meta \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-oe \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-python \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-multimedia \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-filesystems \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-networking \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-gnome \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-xfce \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-riscv \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-clang \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-sifive \
/home/vimer/riscv_test/w500/freedom-u-sdk/meta-tensorflow-lite \
...
在上面的这些layers中,里面每一层的recipes文件,bitbake根据他们create task: fetch configure compile package.
上面的meta-*是每一个顶级layer,里面一般包含三种bitbake的元数据:
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk$ tree meta-sifive/conf/ -L 1
meta-sifive/conf/
├── layer.conf
└── machine
1 directory, 1 file
./recipes-*/ (recipe files with .bb extension)
Good practices with Layers:
Only the maintainer of a layer is supposed to modify it Anyone willing to add or modify recipes need to create a separate layer that should be appended to the previous ones
bitbake是OpenEmbeded的基础构建,目前工作中需要对这个命令有一个基本的了解,所以这里 暂时记录一下,方便我们后面的使用。
参考以下资料: https://www.kancloud.cn/digest/yocto/138624
一般的工程,都有一个初始化的脚本来enable bitbake的命令 以 freedom-u-sdk 为例,他的setup.sh为:
. ./meta-sifive/setup.sh
命令: bitbake -s
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ bitbake -s | grep qemu
nativesdk-qemu :6.0.0-r0
nativesdk-qemu-helper :1.0-r9
nativesdk-qemuwrapper-cross :1.0-r0
qemu :6.0.0-r0
qemu-helper-native :1.0-r1
qemu-native :6.0.0-r0
qemu-system-native :6.0.0-r0
qemuwrapper-cross :1.0-r0
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer path priority
==========================================================================
meta /home/vimer/riscv_test/w500/freedom-u-sdk/openembedded-core/meta 5
meta-oe /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-oe 6
meta-python /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-python 7
meta-multimedia /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-multimedia 6
meta-filesystems /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-filesystems 6
meta-networking /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-networking 5
meta-gnome /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-gnome 7
meta-xfce /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-xfce 7
meta-riscv /home/vimer/riscv_test/w500/freedom-u-sdk/meta-riscv 6
meta-clang /home/vimer/riscv_test/w500/freedom-u-sdk/meta-clang 7
meta-sifive /home/vimer/riscv_test/w500/freedom-u-sdk/meta-sifive 8
meta-tensorflow-lite /home/vimer/riscv_test/w500/freedom-u-sdk/meta-tensorflow-lite 6
结合这里,我才意思到,OE的一点初步的设计思想,确实需要好好读一读spec。
这里,bitbake-layers是利用了分层的思想,也就是后面你想对一个已经存在的工程进行修改,最好的方法是增加自己 的layers,去修改自己的东西,就比如上图中的数字就是这个层的执行顺序,可以暂时浅显的理解。下面新添加一个layers做下实验.
build$
bitbake-layers create-layer --priority 9 ../meta-test/mets-my-test-layer
NOTE: Starting bitbake server...
Add your new layer with 'bitbake-layers add-layer ../meta-test/mets-my-test-layer'
新的layers具有以下的文件清单:
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk$ tree meta-test/
meta-test/
└── mets-my-test-layer
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
└── example
└── example_0.1.bb
4 directories, 4 files
对于一个new layer, recommended actions are:
Update the REDEME
Update the priority in conf/layer.conf file
Apply your modifications and/or addons for the distrubtion.
但是这里有一个问题,就是使用针对原来 setup.sh不会把这个新的layer添加进入 show-layer命令,这个还有待考察如何做。
上面已经新建了一个layer, 但是还没有添加进去,这里使用 bitbake-layer add-layer 命令添加。
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk$ cd meta-sifive/
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/meta-sifive$ bitbake-layers add-layer ../meta-test/mets-my-test-layer/
NOTE: Starting bitbake server...
Unable to find bblayers.conf
你看他最后报的错误,是找不到一个文件,那么,这个文件是在哪里呢?在build目录下:
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/meta-sifive$ cd ../build/
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ bitbake-layers add-layer ../meta-test/mets-my-test-layer/
NOTE: Starting bitbake server...
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer path priority
==========================================================================
meta /home/vimer/riscv_test/w500/freedom-u-sdk/openembedded-core/meta 5
meta-oe /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-oe 6
meta-python /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-python 7
meta-multimedia /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-multimedia 6
meta-filesystems /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-filesystems 6
meta-networking /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-networking 5
meta-gnome /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-gnome 7
meta-xfce /home/vimer/riscv_test/w500/freedom-u-sdk/meta-openembedded/meta-xfce 7
meta-riscv /home/vimer/riscv_test/w500/freedom-u-sdk/meta-riscv 6
meta-clang /home/vimer/riscv_test/w500/freedom-u-sdk/meta-clang 7
meta-sifive /home/vimer/riscv_test/w500/freedom-u-sdk/meta-sifive 8
meta-tensorflow-lite /home/vimer/riscv_test/w500/freedom-u-sdk/meta-tensorflow-lite 6
mets-my-test-layer /home/vimer/riscv_test/w500/freedom-u-sdk/meta-test/mets-my-test-layer 9
看,这个时候就有咱们自己的新层了。
有了自己的layers, 这个时候就应该考虑如何往他里面添加app了。也就是添加recipes等文件
常用的命令是:
add 添加recipes
modify 提取源码
upgrade 更新recipes
serch 搜索package
可以参考这里: https://blog.csdn.net/qq_34160841/article/details/107287365
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ mkdir my_sources
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build/my_sources$ devtool add my-app my_app/
NOTE: Starting bitbake server...
NOTE: Starting bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
NOTE: Reconnecting to bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
NOTE: Retrying server connection (#1)...
NOTE: Starting bitbake server...
INFO: Using source tree as build directory since that would be the default for this recipe
INFO: Recipe /home/vimer/riscv_test/w500/freedom-u-sdk/build/workspace/recipes/my-app/my-app.bb has been automatically created; further editing may be required to make it fully functional
devtool 创建了一个名为 my-app的workspace, 用来存放 recipe 等文件的,在build目录下。
workspace的目录结构如下:
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build$ tree workspace/
workspace/
├── appends
│ └── my-app.bbappend
├── conf
│ └── layer.conf
├── README
└── recipes
└── my-app
└── my-app.bb
vimer@user-HP:~/riscv_test/w500/freedom-u-sdk/build/my_sources$ devtool build my-app
NOTE: Starting bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
Loading cache: 100% | | ETA: --:--:--
Loaded 0 entries from dependency cache.
Parsing recipes: 100% |###########################################################################| Time: 0:00:19
Parsing of 2658 .bb files complete (0 cached, 2658 parsed). 4031 targets, 186 skipped, 1 masked, 0 errors.
NOTE: Reconnecting to bitbake server...
NOTE: Previous bitbake instance shutting down?, waiting to retry...
NOTE: Retrying server connection (#1)...
Loading cache: 100% |#############################################################################| Time: 0:00:01
Loaded 4030 entries from dependency cache.
Parsing recipes: 100% |###########################################################################| Time: 0:00:00
Parsing of 2658 .bb files complete (2657 cached, 1 parsed). 4031 targets, 186 skipped, 1 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.51.1"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "riscv64-oe-linux"
MACHINE = "unmatched"
DISTRO = "nodistro"
DISTRO_VERSION = "2021.09.00"
TUNE_FEATURES = "riscv64 sifive-7-series"
meta
meta-oe
meta-python
meta-multimedia
meta-filesystems
meta-networking
meta-gnome
meta-xfce
meta-riscv
meta-clang
meta-sifive
meta-tensorflow-lite
mets-my-test-layer
workspace = "w500-dev:59cf33b17066bd50c8827b64cf18f70f18407e6e"
Initialising tasks: 100% |########################################################################| Time: 0:00:00
Sstate summary: Wanted 14 Local 0 Network 0 Missed 14 Current 63 (0% match, 81% complete)
Removing 10 stale sstate objects for arch riscv64: 100% |#########################################| Time: 0:00:00
NOTE: Executing Tasks
NOTE: my-app: compiling from external source tree /home/vimer/riscv_test/w500/freedom-u-sdk/build/my_sources/my_app
NOTE: Tasks Summary: Attempted 553 tasks of which 505 didn't need to be rerun and all succeeded.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 1 seconds
NOTE: Build completion summary:
NOTE: do_populate_sysroot: 0.0% sstate reuse(0 setscene, 6 scratch)
NOTE: do_package: 0.0% sstate reuse(0 setscene, 5 scratch)
NOTE: do_packagedata: 0.0% sstate reuse(0 setscene, 5 scratch)
如果想更全面的认识bitbake:
https://blog.csdn.net/Archer1991/article/details/62423014