I am trying to assemble some 64-bit code and the assembling fails on the line:
addq $0xffffff7fc0005000, %rax
with the error:
Error operand type mismatch for `add'
The first operand is a 64-bit value and the latter a register which should assemble fine. This instruction is preceded by a .code64
pseudo-op. I am assembling with
x86_64-elf-as test.s -o test.o --64
As for the assembler itself, when called with --version
it returns:
GNU assembler (GNU Binutils) 2.32
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-elf'.
$0xffffff7fc0005000
almost looks like what someone would do if they were writing a higher half kernel with the kernel in the last 2GiB of virtual address space. If that were true thenaddq $0xffffff7fc0005000
is wrong and likely should have been the canonical address$0xffffffffc0005000
– Stefaniestefanoaddq $0xffffffffc0005000, %rax
since$0xffffffffc0005000
can be represented as a 32 bit signed value$0xc0005000
which when sign extended to 64-bits is also$0xffffffffc0005000
. (Bit 31 the top most bit of 0xc0005000 is the value 1 so when sign extended all the bits in the 64-bit value take on the value 1). – Stefaniestefanowarning: signed dword immediate exceeds bounds
) – Ligniform