[Bug gas/13046] New: Calling equ'd symbols

2011-07-30 Thread wayo.cavazos at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=13046

   Summary: Calling equ'd symbols
   Product: binutils
   Version: 2.21
Status: NEW
  Severity: normal
  Priority: P2
 Component: gas
AssignedTo: unassig...@sources.redhat.com
ReportedBy: wayo.cava...@gmail.com


Here's a small NASM program:

[BITS 64]
[ORG 0x0020]

b_print_newline equ 0x00100040

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:

 <.data>:
   0:   e8 3b 00 f0 ff  callq  0xfff00040
   5:   c3  retq


Here's a GAS version:

.set b_print_newline , 0x00100040

.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 20 --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:

 <.data>:
   0:   ff 14 25 40 00 10 00callq  *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  0xfff00040

vs GAS:

0:  ff 14 25 40 00 10 00callq  *0x100040


Also, here's the program in FASM:

b_print_newline equ 0x00100040

use64
org 0x0020

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:

 <.data>:
   0:   e8 3b 00 f0 ff  callq  0xfff00040
   5:   c3  retq

I brought this issue up on the binutils list. It was suggested that I open a
bug for this:

http://sourceware.org/ml/binutils/2011-07/msg00277.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/13046] Calling equ'd symbols

2011-07-31 Thread wayo.cavazos at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=13046

--- Comment #2 from wayo.cavazos at gmail dot com 2011-07-31 19:58:18 UTC ---

> You have "call b_print_newline" where b_print_newline is 0x100040
> and you get "callq *0x100040".  What is wrong with that?  Please
> tell me why you think binutis is wrong.  Please don't mention NASM
> here since I can say NASM is wrong.

I brought the issue up on the mailing list because I wanted to know how to
write the NASM version of the program in GAS. I was then told (by you) to
report a bug:

http://sourceware.org/ml/binutils/2011-07/msg00277.html

Perhaps it's not a bug. I just would like to know how to port the NASM/FASM
example to GAS.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils