diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -256,9 +256,10 @@ Filename, static_cast(Stat.permissions() & ~sys::fs::getUmask()))) #else + // Drop umask, S_ISUID and S_ISGID bits. if (auto EC = sys::fs::setPermissions( FD, static_cast(Stat.permissions() & - ~sys::fs::getUmask()))) + ~(sys::fs::getUmask() | 06000)))) #endif return createFileError(Filename, EC);