I have been experiencing a very strange invalid opcode exception in QEMU. It only happens in code that was generated by a C compiler (not my assembly code). Here is a disassembly of the troublesome function along with the instruction pointer address. I am compiling with clang and am using lld. Any suggestions? Thanks.
RIP - FFFFFFFFAA0000ED
Code: Select all
ffffffffaa000070 <x86_64_init>:
ffffffffaa000070: 55 push %rbp
ffffffffaa000071: 48 89 e5 mov %rsp,%rbp
ffffffffaa000074: 48 81 ec 50 42 01 00 sub $0x14250,%rsp
ffffffffaa00007b: 31 c0 xor %eax,%eax
ffffffffaa00007d: 48 89 7d f8 mov %rdi,-0x8(%rbp)
ffffffffaa000081: 48 8d 8d e8 5e ff ff lea -0xa118(%rbp),%rcx
ffffffffaa000088: 48 ba 10 00 00 aa ff movabs $0xffffffffaa000010,%rdx
ffffffffaa00008f: ff ff ff
ffffffffaa000092: 31 f6 xor %esi,%esi
ffffffffaa000094: bf 10 a1 00 00 mov $0xa110,%edi
ffffffffaa000099: 48 89 bd e0 5e ff ff mov %rdi,-0xa120(%rbp)
ffffffffaa0000a0: 48 89 cf mov %rcx,%rdi
ffffffffaa0000a3: 48 8b 8d e0 5e ff ff mov -0xa120(%rbp),%rcx
ffffffffaa0000aa: 48 89 95 d8 5e ff ff mov %rdx,-0xa128(%rbp)
ffffffffaa0000b1: 48 89 ca mov %rcx,%rdx
ffffffffaa0000b4: 4c 8b 85 d8 5e ff ff mov -0xa128(%rbp),%r8
ffffffffaa0000bb: 89 85 d4 5e ff ff mov %eax,-0xa12c(%rbp)
ffffffffaa0000c1: 41 ff d0 callq *%r8
ffffffffaa0000c4: 48 89 e1 mov %rsp,%rcx
ffffffffaa0000c7: ba 22 14 00 00 mov $0x1422,%edx
ffffffffaa0000cc: 48 8d b5 e8 5e ff ff lea -0xa118(%rbp),%rsi
ffffffffaa0000d3: 48 89 8d c8 5e ff ff mov %rcx,-0xa138(%rbp)
ffffffffaa0000da: 48 89 d1 mov %rdx,%rcx
ffffffffaa0000dd: 48 8b bd c8 5e ff ff mov -0xa138(%rbp),%rdi
ffffffffaa0000e4: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi)
ffffffffaa0000e7: 48 b9 00 00 00 aa ff movabs $0xffffffffaa000000,%rcx
ffffffffaa0000ee: ff ff ff
ffffffffaa0000f1: 48 89 85 c0 5e ff ff mov %rax,-0xa140(%rbp)
ffffffffaa0000f8: ff d1 callq *%rcx
ffffffffaa0000fa: 48 81 c4 50 42 01 00 add $0x14250,%rsp
ffffffffaa000101: 5d pop %rbp
ffffffffaa000102: c3 retq
ffffffffaa000103: cc int3