- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在 assembly 步进,但发生了一些奇怪的事情。
我有两个独立的闪存 block ,它们都包含代码。因为它们相距甚远,所以从一个 block 到另一个 block 的函数调用需要一个中间跳转,也就是 veneer
这是由链接器自动生成的。
到目前为止,这一直有效,我做了一些事情 - 不知道是什么 - 来打破它。
0x1001a9ca: 0x0cf0c5fe bl 0x10027758 <__atiupy_PutOutput2_veneer>
执行完后PC为0x100275ce
哪个是错误的。
如果我在反汇编窗口中滚动到 0x10027758
, 我看到标签 __atiupy_PutOutput2_veneer
.
为什么会跳错地址?
更新
它从 C 代码跳到 C++ 代码。是的,我有 extern "C"
在.h
对于从 C 代码调用的 C++ 代码中的函数。
C 编译选项是:-x c -Wall -Werror -std=c99 -nostdlib -mthumb -mtune=cortex-m4 -mlittle-endian -Wdouble-promotion -DNDEBUG -fdata-sections -ffunction-sections -c -save-temps=obj -g3 -gdwarf-2
C++ 编译选项是:-mthumb -mlittle-endian -x c++ -gdwarf-2 -g3 -fomit-frame-pointer -fnothrow-opt -ffreestanding -fverbose-asm -std=c++11 -c -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions
根据要求,一些反汇编使用 objdump -d
.
即将跳转到0x10027758
的地方(但从未到达那里)
1001a9bc <mp_hal_stdout_tx_strn_cooked>:
1001a9bc: b580 push {r7, lr}
1001a9be: b082 sub sp, #8
1001a9c0: af00 add r7, sp, #0
1001a9c2: 6078 str r0, [r7, #4]
1001a9c4: 6039 str r1, [r7, #0]
1001a9c6: 6878 ldr r0, [r7, #4]
1001a9c8: 6839 ldr r1, [r7, #0]
1001a9ca: f00c fec5 bl 10027758 <__atiupy_PutOutput2_veneer>
1001a9ce: f107 0708 add.w r7, r7, #8
1001a9d2: 46bd mov sp, r7
1001a9d4: bd80 pop {r7, pc}
1001a9d6: bf00 nop
应该跳转到哪里
10027758 <__atiupy_PutOutput2_veneer>:
10027758: b401 push {r0}
1002775a: 4802 ldr r0, [pc, #8] ; (10027764 <__atiupy_PutOutput2_veneer+0xc>)
1002775c: 4684 mov ip, r0
1002775e: bc01 pop {r0}
10027760: 4760 bx ip
10027762: bf00 nop
10027764: 00035abd .word 0x00035abd
它实际上跳转到0x100275ce
但我粘贴了位于此处的整个函数
100275c8 <___ZN21CKinetisI2CController7DisableEv_veneer>:
100275c8: b401 push {r0}
100275ca: 4802 ldr r0, [pc, #8] ; (100275d4 <___ZN21CKinetisI2CController7DisableEv_veneer+0xc>)
100275cc: 4684 mov ip, r0
100275ce: bc01 pop {r0}
100275d0: 4760 bx ip
100275d2: bf00 nop
100275d4: 00029b2d .word 0x00029b2d
我在 mp_hal_stdout_tx_strn_cooked
处设置了一个断点然后使用 stepi
进行组装
p/x $pc
$2 = 0x1001a9c6
disass
Dump of assembler code for function mp_hal_stdout_tx_strn_cooked:
0x1001a9bc <+0>: push {r7, lr}
0x1001a9be <+2>: sub sp, #8
0x1001a9c0 <+4>: add r7, sp, #0
0x1001a9c2 <+6>: str r0, [r7, #4]
0x1001a9c4 <+8>: str r1, [r7, #0]
=> 0x1001a9c6 <+10>: ldr r0, [r7, #4]
0x1001a9c8 <+12>: ldr r1, [r7, #0]
0x1001a9ca <+14>: bl 0x10027758 <__atiupy_PutOutput2_veneer>
0x1001a9ce <+18>: add.w r7, r7, #8
0x1001a9d2 <+22>: mov sp, r7
0x1001a9d4 <+24>: pop {r7, pc}
End of assembler dump.
stepi
stepi
0x1001a9c8 23 atiupy_PutOutput2(str, len);
disass
Dump of assembler code for function mp_hal_stdout_tx_strn_cooked:
0x1001a9bc <+0>: push {r7, lr}
0x1001a9be <+2>: sub sp, #8
0x1001a9c0 <+4>: add r7, sp, #0
0x1001a9c2 <+6>: str r0, [r7, #4]
0x1001a9c4 <+8>: str r1, [r7, #0]
0x1001a9c6 <+10>: ldr r0, [r7, #4]
=> 0x1001a9c8 <+12>: ldr r1, [r7, #0]
0x1001a9ca <+14>: bl 0x10027758 <__atiupy_PutOutput2_veneer>
0x1001a9ce <+18>: add.w r7, r7, #8
0x1001a9d2 <+22>: mov sp, r7
0x1001a9d4 <+24>: pop {r7, pc}
End of assembler dump.
stepi
stepi
0x1001a9ca 23 atiupy_PutOutput2(str, len);
diasass
Undefined command: "diasass". Try "help".
disass
Dump of assembler code for function mp_hal_stdout_tx_strn_cooked:
0x1001a9bc <+0>: push {r7, lr}
0x1001a9be <+2>: sub sp, #8
0x1001a9c0 <+4>: add r7, sp, #0
0x1001a9c2 <+6>: str r0, [r7, #4]
0x1001a9c4 <+8>: str r1, [r7, #0]
0x1001a9c6 <+10>: ldr r0, [r7, #4]
0x1001a9c8 <+12>: ldr r1, [r7, #0]
=> 0x1001a9ca <+14>: bl 0x10027758 <__atiupy_PutOutput2_veneer>
0x1001a9ce <+18>: add.w r7, r7, #8
0x1001a9d2 <+22>: mov sp, r7
0x1001a9d4 <+24>: pop {r7, pc}
End of assembler dump.
stepi
stepi
0x100275ce in ___ZN21CKinetisI2CController7DisableEv_veneer ()
disass
Dump of assembler code for function ___ZN21CKinetisI2CController7DisableEv_veneer:
0x100275c8 <+0>: push {r0}
0x100275ca <+2>: ldr r0, [pc, #8] ; (0x100275d4 <___ZN21CKinetisI2CController7DisableEv_veneer+12>)
0x100275cc <+4>: mov r12, r0
=> 0x100275ce <+6>: pop {r0}
0x100275d0 <+8>: bx r12
0x100275d2 <+10>: nop
0x100275d4 <+12>: ldr r3, [sp, #180] ; 0xb4
0x100275d6 <+14>: movs r2, r0
End of assembler dump.
stepi
stepi
0x100275d0 in ___ZN21CKinetisI2CController7DisableEv_veneer ()
disass
Dump of assembler code for function ___ZN21CKinetisI2CController7DisableEv_veneer:
0x100275c8 <+0>: push {r0}
0x100275ca <+2>: ldr r0, [pc, #8] ; (0x100275d4 <___ZN21CKinetisI2CController7DisableEv_veneer+12>)
0x100275cc <+4>: mov r12, r0
0x100275ce <+6>: pop {r0}
=> 0x100275d0 <+8>: bx r12
0x100275d2 <+10>: nop
0x100275d4 <+12>: ldr r3, [sp, #180] ; 0xb4
0x100275d6 <+14>: movs r2, r0
End of assembler dump.
编译前的汇编文件
有人想要编译器输出的汇编文件,而不是 objdump
的解释。此输出是编译选项 -save-temps=obj
的结果
.LFE14:
.size mp_hal_stdout_tx_strn, .-mp_hal_stdout_tx_strn
.section .text.mp_hal_stdout_tx_strn_cooked,"ax",%progbits
.align 2
.global mp_hal_stdout_tx_strn_cooked
.thumb
.thumb_func
.type mp_hal_stdout_tx_strn_cooked, %function
mp_hal_stdout_tx_strn_cooked:
.LFB15:
.loc 1 22 0
.cfi_startproc
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
.LCFI11:
.cfi_def_cfa_offset 8
.cfi_offset 7, -8
.cfi_offset 14, -4
sub sp, sp, #8
.LCFI12:
.cfi_def_cfa_offset 16
add r7, sp, #0
.LCFI13:
.cfi_def_cfa_register 7
str r0, [r7, #4]
str r1, [r7, #0]
.loc 1 23 0
ldr r0, [r7, #4]
ldr r1, [r7, #0]
bl atiupy_PutOutput2
.loc 1 25 0
add r7, r7, #8
mov sp, r7
pop {r7, pc}
.cfi_endproc
(悲伤)更新
我创建了最小示例,但问题没有发生。因此,我认为这与我的环境有关。我将开始恢复本地更改并进行更新。我不会将下面的代码称为完整,因为您需要链接器文件,但由于它不会重现问题,所以我认为提供所有内容没有意义。
main.cpp
#include "common.h"
int main()
{
test1();
}
int main_test()
{
int a = 5;
a = 23424 * a;
return a;
}
测试.c
#include "common.h"
void test1()
{
int a;
a = main_test();
a *= 2;
}
common.h
#ifdef __cplusplus
extern "C" {
#endif //#ifdef __cplusplus
int main_test();
void test1();
#ifdef __cplusplus
}
#endif //#ifdef __cplusplus
main.obj 位于“下部”闪存 block 中,而 test.obj 位于上部 block 中。从上跳到下时,PC正确跳转到veneer
的正确地址.
最佳答案
已解决:电源循环修复了它。一定是上部闪存 block 的电气问题导致硬件执行单元从闪存中读取错误值。
关于c - ARM 程序集 - bl 分支到错误的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52208836/
'bl' 或带有链接指令的分支几乎总是变成 0xebfffffe 但是,处理器和 GNU binutils objdump 以某种方式知道分支位置: 00000000 : 0: e1a0c0
我对一件事感到困惑。我在我以前的 mvc 应用程序中使用了存储库模式(不是通用的),并且我曾经在那里包含某种业务逻辑。此刻我读到了服务层模式,其中应该包含 BL。但是现在我不知道是否有更多的抽象和额外
你能解释一下下面的汇编代码是如何工作的吗? xor ebx, ebx; mov bl, byte ptr[ecx]; cmp ebx, 0; 我不明白为什么你将字节移动到 bl 然后比较 ebx 而不
public class TestBL { public static void AddFolder(string folderName) { using (var t
我正在学习 ARM 汇编,但我现在陷入困境。 我知道链接寄存器,如果我没记错的话,它会保存函数调用完成时要返回的地址。 所以如果我们有类似的东西(取自 ARM 文档): 0 | here 1 |
我正在重构我们的 BI 层以使我们的代码更加“松散耦合”,我很想听听你们认为可能会做出哪些有趣的改进? 目前,我们的 API 是这样的:- // Fetch a collection of objec
这里有一个很棒的 d3 极地时钟示例 - http://bl.ocks.org/mbostock/1096355 . 我有几个关于幕后情况的问题,如果有人愿意花点时间解释一下。 1. d3.trans
已解决:电源循环修复了它。一定是上部闪存 block 的电气问题导致硬件执行单元从闪存中读取错误值 我正在 assembly 步进,但发生了一些奇怪的事情。 我有两个独立的闪存 block ,它们都包
我计划将验证逻辑放在业务逻辑层中,其中可能包括: [Required], [Length > 0] 等。使用数据注释。但是,我还需要一个验证规则,在将 DAL 插入数据库之前检查对象是否重复,例如[I
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 5 年前。 Improve
我一点也不是 javascript、jquery、json 专家。 我的目标是使用来自 bl.ock.us 的力导向图示例创建一组数据的图表。 . 1)我写了一个python脚本来生成json格式。
我最近收到一个项目,其中包含多个没有 MVC 结构的 Web 应用程序。对于初学者,我创建了一个包含主要业务逻辑的库 (DLL)。问题出在缓存上——如果我使用当前的 Web 上下文缓存对象,那么我最终
这是我的困境,我知道在 JSF 中访问器方法会被多次调用,因此我知道不要将昂贵的业务逻辑(如数据库访问)放在访问器方法中。如果我绝对必须将业务逻辑放入我的访问器中怎么办。在这种情况下我该怎么办?以下是
https://gist.github.com/dukevis/9039575 我有代码,当我在编辑时通过本地主机查看它时,没有任何错误并且显示正常。然而,当我将其上传到 gist 并通过 bl.oc
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 6 年前。 Improv
这个问题已经有答案了: execve shellcode linux segmentation fault (1 个回答) 已关闭 7 年前。 知道为什么这会导致段错误吗? mov 字节 [esi +
我有一个带有 API、BL 和 DAL 层的 Node.js 应用程序,我想验证用户输入。 目前我正在 BL 函数的开头进行验证,因此它兼作用户输入验证器和内部应用程序验证器(来自其他类的调用) 我担
This我的例子是来自example1和示例2(bl.ocks.org/larskotthoff/7022289)。 我的index.html与example2相同,但我想合并example1的 Vi
我试图更好地理解为什么在调用 BL 指令之前推送 LR。我知道 BL 指令将分支到另一个子例程,然后将 PC 恢复到 BL 调用之后的指令地址,但为什么 LR 在 BL 被称为?我已经编写了下面用于阶
我正在尝试构建 iOS 应用程序,但在 Debug模式下遇到错误。 ld: b/bl/blx thumb2 branch out of range (17330692 max is +/-16MB):
我是一名优秀的程序员,十分优秀!