mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-26 23:21:11 +00:00
[BOLT] Incorporate umask into the output file permission
Fix https://github.com/llvm/llvm-project/issues/65061 Reviewed By: maksfb, Amir Differential Revision: https://reviews.llvm.org/D159407
This commit is contained in:
parent
16fd879980
commit
473b9dd442
@ -564,8 +564,10 @@ void MachORewriteInstance::rewriteFile() {
|
||||
writeInstrumentationSection("I__literal16", OS);
|
||||
|
||||
Out->keep();
|
||||
EC = sys::fs::setPermissions(opts::OutputFilename,
|
||||
sys::fs::perms::all_all);
|
||||
EC = sys::fs::setPermissions(
|
||||
opts::OutputFilename,
|
||||
static_cast<sys::fs::perms>(sys::fs::perms::all_all &
|
||||
~sys::fs::getUmask()));
|
||||
check_error(EC, "cannot set permissions of output file");
|
||||
}
|
||||
|
||||
|
@ -5366,7 +5366,10 @@ void RewriteInstance::rewriteFile() {
|
||||
}
|
||||
|
||||
Out->keep();
|
||||
EC = sys::fs::setPermissions(opts::OutputFilename, sys::fs::perms::all_all);
|
||||
EC = sys::fs::setPermissions(
|
||||
opts::OutputFilename,
|
||||
static_cast<sys::fs::perms>(sys::fs::perms::all_all &
|
||||
~sys::fs::getUmask()));
|
||||
check_error(EC, "cannot set permissions of output file");
|
||||
}
|
||||
|
||||
|
13
bolt/test/permission.test
Normal file
13
bolt/test/permission.test
Normal file
@ -0,0 +1,13 @@
|
||||
# Ensure that the permissions of the optimized binary file comply with the
|
||||
# system's umask.
|
||||
|
||||
# This test performs a logical AND operation on the results of the `stat -c %a
|
||||
# %t.bolt` and `umask` commands (both results are displayed in octal), and
|
||||
# checks whether the result is equal to 0.
|
||||
REQUIRES: system-linux
|
||||
|
||||
RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q
|
||||
RUN: llvm-bolt %t -o %t.bolt
|
||||
RUN: echo $(( 8#$(stat -c %a %t.bolt) & 8#$(umask) )) | FileCheck %s
|
||||
|
||||
CHECK: 0
|
Loading…
Reference in New Issue
Block a user