这是一个小型NASM计划:
[BITS 64]
[ORG 0x0000000000200000]
b_print_newline equ 0x0000000000100040
start:
call b_print_newline
ret
组装:
$ nasm -f bin pr-nl-a.asm -o pr-nl-a.app
反汇编:
$ objdump -D -b binary -m i386:x86-64 pr-nl-a.app
pr-nl-a.app: file format binary
Disassembly of section .data:
0000000000000000 <.data>:
0: e8 3b 00 f0 ff callq 0xfffffffffff00040
5: c3 retq
这是GAS版本:
.set b_print_newline , 0x0000000000100040
.text
.global _start
_start:
call b_print_newline
ret
汇编并链接它:
$ as -o pr-nl-b.o pr-nl-b.s
$ ld -Ttext 200000 --oformat binary -o pr-nl-b.app pr-nl-b.o
反汇编:
$ objdump -D -b binary -m i386:x86-64 pr-nl-b.app
pr-nl-b.app: file format binary
Disassembly of section .data:
0000000000000000 <.data>:
0: ff 14 25 40 00 10 00 callq *0x100040
7: c3 retq
如您所见,反汇编代码略有不同。 NASM中call
的代码:
0: e8 3b 00 f0 ff callq 0xfffffffffff00040
vs GAS:
0: ff 14 25 40 00 10 00 callq *0x100040
有关如何正确实施GAS版本的任何建议吗?
以下是FASM中的程序:
b_print_newline equ 0x0000000000100040
use64
org 0x0000000000200000
start: call b_print_newline
ret
它做对了:
$ objdump -D -b binary -m i386:x86-64 pr-nl-c.app
pr-nl-c.app: file format binary
Disassembly of section .data:
0000000000000000 <.data>:
0: e8 3b 00 f0 ff callq 0xfffffffffff00040
5: c3 retq
答案 0 :(得分:0)
将“.org 0x0000000000200000”添加到GAS文件中。