[PATCH] D37462: [LLD] Fix padding of .eh_frame when in executable segment
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 11:14:52 PDT 2017
ruiu added inline comments.
================
Comment at: ELF/SyntheticSections.cpp:525
- memcpy(Buf, D.data(), D.size());
+ size_t DataSize = D.size();
+ memcpy(Buf, D.data(), DataSize);
+
+ size_t AlignSize = alignTo(DataSize, sizeof(typename ELFT::uint));
+
+ // Must be padded with zero if needed.
+ if (AlignSize > DataSize)
+ memset(Buf + DataSize, 0, AlignSize - DataSize);
// Fix the size field. -4 since size does not include the size field itself.
----------------
I think you can simplify the code by adding this piece of code here.
constexpr size_t Wordsize = sizeof(typename ELFT::uint);
// Zero-clear trailing padding if exists.
memset(Buf + D.size(), 0, Wordsize - D.size() % Wordsize);
https://reviews.llvm.org/D37462
More information about the llvm-commits
mailing list