[PATCH] D62718: [llvm-objcopy] Change output file permissions to be the same as the input file
Alex Brachet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 00:32:48 PDT 2019
abrachet created this revision.
Herald added subscribers: llvm-commits, MaskRay, jakehehrlich, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62718
Files:
llvm/test/tools/llvm-objcopy/ELF/same-permissions.test
llvm/tools/llvm-objcopy/Buffer.cpp
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -206,9 +206,8 @@
/// format-agnostic modifications, i.e. preserving dates.
static Error executeObjcopy(const CopyConfig &Config) {
sys::fs::file_status Stat;
- if (Config.PreserveDates)
- if (auto EC = sys::fs::status(Config.InputFilename, Stat))
- return createFileError(Config.InputFilename, EC);
+ if (auto EC = sys::fs::status(Config.InputFilename, Stat))
+ return createFileError(Config.InputFilename, EC);
if (Config.InputFormat == "binary") {
auto BufOrErr = MemoryBuffer::getFile(Config.InputFilename);
@@ -242,6 +241,10 @@
return E;
}
+ if (std::error_code E =
+ sys::fs::setPermissions(Config.OutputFilename, Stat.permissions()))
+ return errorCodeToError(E);
+
return Error::success();
}
Index: llvm/tools/llvm-objcopy/Buffer.cpp
===================================================================
--- llvm/tools/llvm-objcopy/Buffer.cpp
+++ llvm/tools/llvm-objcopy/Buffer.cpp
@@ -36,7 +36,7 @@
}
Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
- FileOutputBuffer::create(getName(), Size, FileOutputBuffer::F_executable);
+ FileOutputBuffer::create(getName(), Size);
// FileOutputBuffer::create() returns an Error that is just a wrapper around
// std::error_code. Wrap it in FileError to include the actual filename.
if (!BufferOrErr)
Index: llvm/test/tools/llvm-objcopy/ELF/same-permissions.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/same-permissions.test
@@ -0,0 +1,5 @@
+# RUN: llvm-objcopy %p/Inputs/alloc-symtab.o %t
+# RUN: stat --printf=%a %p/Inputs/alloc-symtab.o > %t1
+# RUN: stat --printf=%a %t > %t2
+# RUN: diff %t1 %t2
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62718.202376.patch
Type: text/x-patch
Size: 1928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190531/2db29db6/attachment.bin>
More information about the llvm-commits
mailing list