结构体里的变量8字节对齐 指的是相对于结构体首地址的偏移是8字节的整数倍
ldrexd的指令 要求的是被操作的内存地址的8字节对齐
p:0x56401b274264
p->a:0x56401b274264
p->b:0x56401b274268
p->c:0x56401b27426c
p->d:0x56401b274274
p->e:0x56401b27427c
p->f:0x56401b274284
p->g:0x56401b274288
a:0x7ffdfc13ee60
b:0x7ffdfc13ee64
c:0x7ffdfc13ee68
d:0x7ffdfc13ee70
cat attribute.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct attr {
char a __attribute__((__aligned__(8)));
int b ;
double c __attribute__((__aligned__(8)));
long d __attribute__((__aligned__(8)));
char e __attribute__((__aligned__(2)));
char f __attribute__((__aligned__(8)));
char g __attribute__((__aligned__(4)));
}__attribute__((__aligned__(8)));
int main()
{
struct attr abc;
char * tmpp = malloc(sizeof(struct attr)+100);
struct attr *p =tmpp+4;
printf("p:%p
",p);
printf("p->a:%p
",&p->a);
printf("p->b:%p
",&p->b);
printf("p->c:%p
",&p->c);
printf("p->d:%p
",&p->d);
printf("p->e:%p
",&p->e);
printf("p->f:%p
",&p->f);
printf("p->g:%p
",&p->g);
abc.a = 1;
abc.b = 2;
abc.c = 3;
abc.d = 4;
printf("a:%p
",&abc.a);
printf("b:%p
",&abc.b);
printf("c:%p
",&abc.c);
printf("d:%p
",&abc.d);
}