[PATCH] D80414: [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 14:11:25 PDT 2020


alexshap added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:233
   for (size_t i = 0, n = nList.size(); i < n; ++i) {
-    const nlist_64 &sym = nList[i];
+    nlist_64 sym;
+    // nlist_64 structs should be 64-bit-aligned according to the C++ language
----------------
i suspect you might face the same issue with other data structures which should be properly aligned too,
so it would be good to think about a general consistent approach how to handle it.
Just for the record I'd like to mention how libObject solves this problem:

https://llvm.org/doxygen/MachOObjectFile_8cpp_source.html#l04264 
https://llvm.org/doxygen/MachOObjectFile_8cpp_source.html#l00068


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