aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-09 13:53:56 -0500
committerGitHub <noreply@github.com>2020-01-09 13:53:56 -0500
commit5e345ff0ee9eb70d7f5f7167227f6a1e8903f428 (patch)
tree34d82c8ef040fc30fe895043d7a84d75552d36cf /lib/std/start.zig
parent5ab5de89c03bf9b3f08dfaa78d3b0fe41a72cdea (diff)
parentc51b79c56e32594e4fb119fc760ae38b69fb9bbb (diff)
downloadzig-5e345ff0ee9eb70d7f5f7167227f6a1e8903f428.tar.gz
zig-5e345ff0ee9eb70d7f5f7167227f6a1e8903f428.zip
Merge pull request #3955 from LemonBoy/fix-1528
Pointer arithmetic affects the alignment factor
Diffstat (limited to 'lib/std/start.zig')
-rw-r--r--lib/std/start.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index b982692a08..c3844e4d1e 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -142,14 +142,14 @@ fn posixCallMainAndExit() noreturn {
const argc = starting_stack_ptr[0];
const argv = @ptrCast([*][*:0]u8, starting_stack_ptr + 1);
- const envp_optional = @ptrCast([*:null]?[*:0]u8, argv + argc + 1);
+ const envp_optional = @ptrCast([*:null]?[*:0]u8, @alignCast(@alignOf(usize), argv + argc + 1));
var envp_count: usize = 0;
while (envp_optional[envp_count]) |_| : (envp_count += 1) {}
const envp = @ptrCast([*][*:0]u8, envp_optional)[0..envp_count];
if (builtin.os == .linux) {
// Find the beginning of the auxiliary vector
- const auxv = @ptrCast([*]std.elf.Auxv, envp.ptr + envp_count + 1);
+ const auxv = @ptrCast([*]std.elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1));
std.os.linux.elf_aux_maybe = auxv;
// Initialize the TLS area
const gnu_stack_phdr = std.os.linux.tls.initTLS() orelse @panic("ELF missing stack size");