From 9ebf25d1458988b6aa75d4608062f18f802c6a38 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 24 Apr 2020 15:36:08 -0400 Subject: [PATCH] link: change default executable mode to 0o777 Jonathan S writes: On common systems with a 022 umask, this will still result in a file created with 755 permissions, but it works appropriately if the system is configured more leniently. (As another data point, C's fopen seems to open files with the 666 mode.) --- lib/std/mem.zig | 2 +- src-self-hosted/link.zig | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 5966f8bc9..54b5a8a50 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -2061,7 +2061,7 @@ pub fn alignBackward(addr: usize, alignment: usize) usize { /// The alignment must be a power of 2 and greater than 0. pub fn alignBackwardGeneric(comptime T: type, addr: T, alignment: T) T { assert(@popCount(T, alignment) == 1); - // 000010000 // example addr + // 000010000 // example alignment // 000001111 // subtract 1 // 111110000 // binary not return addr & ~(alignment - 1); diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index 9ab462e32..cb6aa40af 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -7,7 +7,11 @@ const fs = std.fs; const elf = std.elf; const codegen = @import("codegen.zig"); -const executable_mode = 0o755; +/// On common systems with a 0o022 umask, 0o777 will still result in a file created +/// with 0o755 permissions, but it works appropriately if the system is configured +/// more leniently. As another data point, C's fopen seems to open files with the +/// 666 mode. +const executable_mode = 0o777; const default_entry_addr = 0x8000000; pub const ErrorMsg = struct {