[lld-macho] Ensure reads from nlist_64 structs are aligned when necessary
authorJez Ng <jezng@fb.com>
Thu, 21 May 2020 22:26:35 +0000 (15:26 -0700)
committerJez Ng <jezng@fb.com>
Tue, 2 Jun 2020 20:19:38 +0000 (13:19 -0700)
commit1e1a3f67ee717ebb71c461e51c5c233a13f25edb
tree36bdda9575c6febe64532c07dbfc060d9c22d866
parentf04d1c3b90c19f5c01b99f8fcd5794a6b338f124
[lld-macho] Ensure reads from nlist_64 structs are aligned when necessary

My test refactoring in D80217 seems to have caused yaml2obj to emit
unaligned nlist_64 structs, causing ASAN'd lld to be unhappy. I don't
think this is an issue with yaml2obj though -- llvm-mc also seems to
emit unaligned nlist_64s. This diff makes lld able to safely do aligned
reads under ASAN builds while hopefully creating no overhead for regular
builds on architectures that support unaligned reads.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D80414
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/MachOStructs.h [new file with mode: 0644]
lld/MachO/SyntheticSections.cpp
lld/MachO/Writer.cpp