B
Branch causes an unconditional branch to a label at a PC-relative offset, with a hint that this is not a subroutine call or return.
在PC相对偏移处对标签进行无条件分支,并提示这不是子程序调用或返回。
操作码 助记符 标志 含义
0x9 1001 LS C=0,Z=1 无符号数小于或等于
404e5c: 97fff37d bl 401c50 <strdup@plt> // strdup()
404e60: aa0003f6 mov x22, x0 // x22=x0
dest = strdup(a);
404e64: 97fff2ef bl 401a20 <strlen@plt> // strlen(x0)
404e68: f108001f cmp x0, #0x200 // x0 ?= 512
404e6c: 54000189 b.ls 404e9c <ferror@plt+0x2fbc> // b.plast // <=
if (strlen(a) > 0x200) {
// b.ls 404e9c
}
顺序为从左到右,即当 x0 <= 0x200时跳转。gcc 下Arm cmp指令与Intel的顺序不一样,Intel是从右向左的比较。
404e64: 97fff2ef bl 401a20 <strlen@plt> // strlen(x0)
404e68: f108001f cmp x0, #0x200 // x0 ?= 512
404e6c: 54000189 b.ls 404e9c <ferror@plt+0x2fbc> // ls(<=), 0x200 <= x0
有两种写法:
if (strlen(a) <= 0x200) {
// b.ls 404e9c
}
或者
if (0x200 > strlen(a)) {
// b.ls 404e9c
}