[PATCH] libelf: Use offsetof to get field of unaligned
Wed Dec 15 22:40:08 GMT 2021
* Mark Wielaard:
> This seems a wrong warning since we aren't accessing the field member
> of the struct, but are taking the address of it. But we can do the
> same by adding the field offsetof to the base address. Which doesn't
> trigger a runtime error.
I think the warning is correct. I believe it is motivated by the GCC
optimizers using this to infer alignment of the original pointer. It
won't make a difference for this expression, but it can cause crashes
elsewhere with strict-alignment targets.
More information about the Elfutils-devel