0
votes

The test is on 64-bit/x86 Ubuntu 12.04. With GCC 4.6.3.

So basically I am manipulating some x64 assembly code. And I observed that RIP-relative addressing require the absolute address to be 16-byte aligned.

Here is an example when debugging using gdb:

0x40f38d <S_0x40F614+61>        xorpd  0x84d3(%rip),%xmm0   # 0x417868 <S_0x417DE0>

This memory reference to address 0x417868 fail (segmentation fault), as this address is only 8-byte aligned.

0x40f38d <S_0x40F614+61>        xorpd  0x8a4b(%rip),%xmm0   # 0x417de0 <S_0x417DE0>

This memory reference can work, as address 0x417de0 is 16 byte aligned.

This is my observation, and I didn't find any official materials discussing about this issue. Could anyone tell me

  1. Is this 16-byte alignment requirement universally true?
  2. If so, then does any official document/manual talking about this?
1
It's the xorpd instruction that requires 16-byte alignment for the memory operand.Mysticial

1 Answers

4
votes

It's the xorpd instruction. It causes and Exception of type 4, which happens when you specify an unaligned memory location without the VEX prefix. (So vxorpd wouldn't fault on unaligned.)

Intel Manuals

However, it's not the only one, there are about 106 more instructions that cause the same thing.