From: Eduardo Cavazos <wayo.cavazos@gmail.com>
To: binutils@sourceware.org
Subject: Calling equ'd symbols in GAS
Date: Fri, 29 Jul 2011 03:21:00 -0000 [thread overview]
Message-ID: <1311901088.3441.202.camel@dharmatech-ThinkPad-T61> (raw)
Hello,
Here's a small NASM program:
[BITS 64]
[ORG 0x0000000000200000]
b_print_newline equ 0x0000000000100040
start:
call b_print_newline
ret
Assemble it:
$ nasm -f bin pr-nl-a.asm -o pr-nl-a.app
Disassemble it:
$ 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
Here's a GAS version:
.set b_print_newline , 0x0000000000100040
.text
.global _start
_start:
call b_print_newline
ret
Assemble and link it:
$ as -o pr-nl-b.o pr-nl-b.s
$ ld -Ttext 200000 --oformat binary -o pr-nl-b.app pr-nl-b.o
Disassemble it:
$ 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
As you can see, the disassembled code differs slightly. The code for
`call` in NASM:
0: e8 3b 00 f0 ff callq 0xfffffffffff00040
vs GAS:
0: ff 14 25 40 00 10 00 callq *0x100040
Any suggestions for how to implement the GAS version properly?
Also, here's the program in FASM:
b_print_newline equ 0x0000000000100040
use64
org 0x0000000000200000
start: call b_print_newline
ret
It does the right thing:
$ 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
Ed
next reply other threads:[~2011-07-29 0:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 3:21 Eduardo Cavazos [this message]
2011-07-29 3:49 ` Alan Modra
2011-07-29 6:11 ` Eduardo Cavazos
2011-07-29 6:32 ` Alan Modra
2011-07-29 6:50 ` Eduardo Cavazos
2011-07-29 7:35 ` Alan Modra
2011-07-29 7:46 ` Eduardo Cavazos
2011-07-29 9:26 ` Alan Modra
2011-07-29 11:03 ` Eduardo Cavazos
2011-07-29 14:57 ` H.J. Lu
[not found] ` <1312156228.3441.284.camel@dharmatech-ThinkPad-T61>
2011-08-01 19:29 ` H.J. Lu
2011-08-01 21:42 ` Eduardo Cavazos
2011-08-05 4:14 ` Alan Modra
2011-08-05 14:13 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311901088.3441.202.camel@dharmatech-ThinkPad-T61 \
--to=wayo.cavazos@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).