[PATCH v1 0/3] Switch get/put unaligned to use memcpy

From: Ian Rogers
Date: Mon Jun 16 2025 - 20:58:14 EST


The existing type punning approach with packed structs requires
-fno-strict-aliasing to be passed to the compiler for
correctness. This is true in the kernel tree but not in the tools
directory resulting in this suggested patch from Eric Biggers
<ebiggers@xxxxxxxxxx>:
https://lore.kernel.org/lkml/20250614044133.660848-2-ebiggers@xxxxxxxxxx/

Requiring -fno-strict-aliasing seems unfortunate and so this patch
makes the unaligned code work via memcpy for type punning rather than
the packed attribute.

Ian Rogers (3):
vdso: Switch get/put unaligned from packed struct to memcpy
tools headers: Update the linux/unaligned.h copy with the kernel
sources
tools headers: Remove unneeded ignoring of warnings in unaligned.h

include/vdso/unaligned.h | 48 ++++++++++++++++++++++++++++-----
tools/include/linux/unaligned.h | 4 ---
tools/include/vdso/unaligned.h | 48 ++++++++++++++++++++++++++++-----
3 files changed, 84 insertions(+), 16 deletions(-)

--
2.50.0.rc2.692.g299adb8693-goog