[lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.
llvm-svn: 251637
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index bbf62de..d157755 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -429,7 +429,7 @@
// Add LC_RPATH
for (const StringRef &path : _file.rpaths) {
- size += sizeof(rpath_command) + pointerAlign(path.size()+1);
+ size += pointerAlign(sizeof(rpath_command) + path.size() + 1);
++count;
}
@@ -855,7 +855,7 @@
// Add LC_RPATH
for (const StringRef &path : _file.rpaths) {
rpath_command *rpc = reinterpret_cast<rpath_command *>(lc);
- uint32_t size = sizeof(rpath_command) + pointerAlign(path.size()+1);
+ uint32_t size = pointerAlign(sizeof(rpath_command) + path.size() + 1);
rpc->cmd = LC_RPATH;
rpc->cmdsize = size;
rpc->path = sizeof(rpath_command); // offset