[PATCH] D81575: [llvm-objcopy] Fix RPathLC.cmdsize
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 20:52:56 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc966ed8dc7ce: [llvm-objcopy][MachO] Fix cmdsize of LC_RPATH (authored by alexshap).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81575/new/
https://reviews.llvm.org/D81575
Files:
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
Index: llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -87,7 +87,7 @@
MachO::rpath_command RPathLC;
RPathLC.cmd = MachO::LC_RPATH;
RPathLC.path = sizeof(MachO::rpath_command);
- RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size(), 8);
+ RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
LC.MachOLoadCommand.rpath_command_data = RPathLC;
LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
std::copy(Path.begin(), Path.end(), LC.Payload.begin());
Index: llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
===================================================================
--- llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
+++ llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
@@ -21,3 +21,12 @@
# RUN: | FileCheck --check-prefix=NO-INPUT %s
# NO-INPUT: no input file specified
+
+## Check that cmdsize accounts for NULL terminator.
+# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64
+# RUN: llvm-install-name-tool -add_rpath abcd %t.x86_64
+# RUN: llvm-objdump -p %t.x86_64 | FileCheck %s --check-prefix=RPATH-SIZE
+
+# RPATH-SIZE: cmd LC_RPATH
+# RPATH-SIZE-NEXT: cmdsize 24
+# RPATH-SIZE-NEXT: path abcd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81575.270299.patch
Type: text/x-patch
Size: 1423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200612/062a670a/attachment.bin>
More information about the llvm-commits
mailing list