32 位 Linux 汇编 - 将文件链接在一起(gas 和 ld)
我写了一个名为 strlen 的函数:
.section .text
.global strlen
.type strlen, @function
strlen:
... code ...
我像这样组装了它:
as --32 strlen.asm -o strlen.o
然后我在 asm 中编写了一个程序来打印 argv ,我想与它链接。我也是用同样的方法组装的。现在我想将它们链接在一起,以便实际程序可以使用 strlen。我尝试过:
ld printnum.o strlen.o -m elf_i386 -o printnum
但这会产生:
printnum.o: In function `loop':
(.text+0x5): undefined reference to `strlen'
我一定错过了一些非常简单的东西。谢谢!
I wrote a function called strlen:
.section .text
.global strlen
.type strlen, @function
strlen:
... code ...
I assembled this like so:
as --32 strlen.asm -o strlen.o
Then I wrote a program in asm to print argv which I want to link with this. I assembled that the same way. Now I want to link them together so that the actual program can use strlen. I tried:
ld printnum.o strlen.o -m elf_i386 -o printnum
but that yields:
printnum.o: In function `loop':
(.text+0x5): undefined reference to `strlen'
I must be missing something really simple. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
早些时候,我愚蠢地在 strlen.o 上运行了
strip
,这显然删除了所有符号。干得好,我。Earlier I stupidly ran
strip
on strlen.o which obviously removed all of the symbols. Good job me.