amd64 registers/instructions are not recognized when using the binary output format and the GAS parser
Reported by Postmodern | December 5th, 2011 @ 02:01 AM
Even when specifying --machine=amd64 with the GAS
parser and default output format of bin, YASM does not
recognize amd64 registers or instructions.
_start:
push $0x3b
popq %rax # set %rax to 0x3b
cltd # %rdx (arg 3: envp) is set to 0
movq $0x68732f2f6e69622f,%rbx # set %rbx to "/bin//sh"
pushq %rdx # push 0
pushq %rbx # push "/bin//sh"
pushq %rsp
popq %rdi # %rdi (arg 1: path) points to "/bin//sh"
pushq %rdx # push 0
pushq %rdi # push ptr to path
pushq %rsp
popq %rsi # %rsi (arg 2: argv) points to ["/bin//sh",0]
syscall # execve(path,argv,envp)
$ yasm --parser=gas --arch=x86 --machine=amd64 test.s -o test.o
test.s:3: error: Unrecognized register name `%rax'
test.s:3: warning: `rax' is a register in 64-bit mode
test.s:3: warning: `popq' is an instruction in 64-bit mode
test.s:5: error: Unrecognized register name `%rbx'
test.s:5: warning: `rbx' is a register in 64-bit mode
test.s:6: error: Unrecognized register name `%rdx'
test.s:6: warning: `rdx' is a register in 64-bit mode
test.s:6: warning: `pushq' is an instruction in 64-bit mode
test.s:7: error: Unrecognized register name `%rbx'
test.s:7: warning: `rbx' is a register in 64-bit mode
test.s:7: warning: `pushq' is an instruction in 64-bit mode
test.s:8: error: Unrecognized register name `%rsp'
test.s:8: warning: `rsp' is a register in 64-bit mode
test.s:8: warning: `pushq' is an instruction in 64-bit mode
test.s:9: error: Unrecognized register name `%rdi'
test.s:9: warning: `rdi' is a register in 64-bit mode
test.s:9: warning: `popq' is an instruction in 64-bit mode
test.s:10: error: Unrecognized register name `%rdx'
test.s:10: warning: `rdx' is a register in 64-bit mode
test.s:10: warning: `pushq' is an instruction in 64-bit mode
test.s:11: error: Unrecognized register name `%rdi'
test.s:11: warning: `rdi' is a register in 64-bit mode
test.s:11: warning: `pushq' is an instruction in 64-bit mode
test.s:12: error: Unrecognized register name `%rsp'
test.s:12: warning: `rsp' is a register in 64-bit mode
test.s:12: warning: `pushq' is an instruction in 64-bit mode
test.s:13: error: Unrecognized register name `%rsi'
test.s:13: warning: `rsi' is a register in 64-bit mode
test.s:13: warning: `popq' is an instruction in 64-bit mode
YASM version: 1.1.0.2352
Comments and changes to this ticket
-

Peter Johnson December 16th, 2011 @ 08:03 AM
- → State changed from new to resolved
You need to use the directive ".code64" at the top of your source file.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Yasm Modular Assembler Project