[lld] r251637 - [lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 09:50:27 PDT 2015


Author: lhames
Date: Thu Oct 29 11:50:26 2015
New Revision: 251637

URL: http://llvm.org/viewvc/llvm-project?rev=251637&view=rev
Log:
[lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
    lld/trunk/test/mach-o/rpath.yaml

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp?rev=251637&r1=251636&r2=251637&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp Thu Oct 29 11:50:26 2015
@@ -429,7 +429,7 @@ uint32_t MachOFileLayout::loadCommandsSi
 
   // 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 @@ std::error_code MachOFileLayout::writeLo
     // 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

Modified: lld/trunk/test/mach-o/rpath.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/rpath.yaml?rev=251637&r1=251636&r2=251637&view=diff
==============================================================================
--- lld/trunk/test/mach-o/rpath.yaml (original)
+++ lld/trunk/test/mach-o/rpath.yaml Thu Oct 29 11:50:26 2015
@@ -34,5 +34,5 @@ global-symbols:
 
 
 # CHECK-BINARY-WRITE: cmd LC_RPATH
-# CHECK-BINARY-WRITE-NEXT:  cmdsize 44
+# CHECK-BINARY-WRITE-NEXT:  cmdsize 40
 # CHECK-BINARY-WRITE-NEXT:  path @loader_path/../Frameworks (offset 12)




More information about the llvm-commits mailing list