Nasm : 当你也需要调试符号时如何使用 ORG 指令?

Nasm : how to use ORG directive when you want debug symbol too?

这个问题得到了部分回答here ,但是当您不得不使用它时,它们对生成带有 ORG 指令的 elf 文件没有帮助。

我需要一种方法来组合 nasm use 和 ORG 指令来生成等效的 Elf 文件。 这就是我现在的处理方式:

nasm -f elf64 -F dwarf -g Main.s -o Main.elf  

但是nasm一直拒绝,因为我需要ORG。

这是为了给你的问题一个精确的解决方案,以防其他人遇到同样的情况:

如果您想将二进制原点设置为 0x7c00(如在普通内核中 boot-loader)

ld -Ttext=0x7c00 --oformat binary -o Main.bin Main.elf