[PATCH v6 2/5] x86: Add SFrame support for x86 architecture
Florian Weimer
fweimer@redhat.com
Wed Jul 2 07:23:43 GMT 2025
* Adhemerval Zanella Netto:
>> + if (*(unsigned char *)(pc+0) == 0x48
>> + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
>
> This is strictly UB, although x86_64 supports unaligned access. You can
> use something like:
>
> #define __read_unaligned_t(__type, __ptr) ({ \
> const struct { type x; } __attribute__((__packed__)) * __pptr = \
> (typeof(_pptr))(__ptr); \
> __pptr->x; \
> })
> #define read_unaligned(ptr) __read_unaligned_t(typeof(*(ptr)), (ptr))
>
> Or the memcpy to a temporary (as we do on some code internally). Afaik
> the packet attribute tend to generate better code.
I would just use memcmp. GCC will expand it inline if the ordering is
not used.
Thanks,
Florian
More information about the Libc-alpha
mailing list