组装 - 获取外部标签地址

发布于 2025-02-06 07:34:45 字数 615 浏览 2 评论 0原文

外部标签(指代码或数据无关紧要)是当前源文件中找不到的标签,稍后用链接器引用。我可以获取连续声明的许多外部标签(指向代码)的地址吗?而且,这些标签实际上是宏。

以示例解释:

我有一个源A.ASM, acro 宣布为 global

.macro label n
.global label\n
label\n:
push (n)
ret

和一个源B.masm,带有一些 label(s)< /em>标记为 extern

labels_array:
.extern label0
.extern label1

我可以用movlea从<<代码> labels_array ?

这样:

mov $labels_array, %ebx #label0 here
mov 4(%ebx), %eax       #label1 here

如果没有,还有另一种方法吗?谢谢。

Extern labels(refers to code or data, does not matter) are labels not found in the current source file and referenced later with the linker. Can I get the address of many extern labels(pointing to code) that are declared consecutively. Also, those labels are actually a macro.

Explaining it with example:

I have a source A.asm with the macro declared as global:

.macro label n
.global label\n
label\n:
push (n)
ret

And a source B.asm, with some label(s) marked as extern:

labels_array:
.extern label0
.extern label1

Can I get the address of each label with mov or lea starting from labels_array?

Like this:

mov $labels_array, %ebx #label0 here
mov 4(%ebx), %eax       #label1 here

If not, is there another way? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文