[PATCH] D80414: [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 12:32:59 PDT 2020
smeenai added a comment.
In D80414#2055477 <https://reviews.llvm.org/D80414#2055477>, @efriedma wrote:
> Alternatively, we have some integer wrappers in llvm/Support/Endian.h that deal with both endianness and alignment. For example, you could define nlist_64 like this:
>
> struct nlist_64 {
> support::ulittle32_t n_strx;
> uint8_t n_type;
> uint8_t n_sect;
> support::ulittle16_t n_desc;
> support::ulittle64_t n_value;
> };
>
Ah, those look really neat! Thanks for the pointer.
I don't know if it'd be wise to change BinaryFormat's `nlist_64` definition at this point (the pervasive pattern with Mach-O is to use various `swapStruct` overloads to handle endianness), but we can look into that for LLD. Under the hood, those seem to use `memcpy` as well, but with some `__builtin_assume_aligned` trickery that might help with the elision?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80414/new/
https://reviews.llvm.org/D80414
More information about the llvm-commits
mailing list