2021年2月10日星期三

BTS gives "invalid combination", but only when addressing memory

If I assemble this using nasm -felf64 test.asm, I get the error:

; syntax: nasm  default rel  global main     section .text  main:          call init          ; do stuff          ret     init:          lock bts [initted], 0 ; <-- error: invalid combination of opcode and operands          jc .continue          ret         .continue:          ; do stuff          ret     section .data          initted db 0  

Using lea gives the same result:

...          lea rax, [initted]          lock bts [rax], 0 ; <-- same error          jc .continue  ...  

This also happens with any combination lock or default rel.

The only thing that assembles is changing it to bts rax, 0. Obviously this program doesn't have any threads, but the full one will and if multiple threads try to run init simultaneously it would definitely break.

I've looked it over several times, there's probably something stupid I missed, but I have no idea what it is.

https://stackoverflow.com/questions/66147397/bts-gives-invalid-combination-but-only-when-addressing-memory February 11, 2021 at 09:06AM

没有评论:

发表评论