Skip to content

Commit

Permalink
start: Always inline the call to std.os.linux.pie.relocate().
Browse files Browse the repository at this point in the history
At this stage, we're not ready to make calls yet on some architectures (e.g. MIPS).
  • Loading branch information
alexrp committed Jul 29, 2024
1 parent d6c637c commit d633b35
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/std/start.zig
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,11 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn {
break :init @as([*]elf.Phdr, @ptrFromInt(at_phdr))[0..at_phnum];
};

// Apply the initial relocations as early as possible in the startup
// process.
// Apply the initial relocations as early as possible in the startup process. We cannot
// make calls yet on some architectures (e.g. MIPS) *because* they haven't been applied yet,
// so this must be fully inlined.
if (builtin.position_independent_executable) {
std.os.linux.pie.relocate(phdrs);
@call(.always_inline, std.os.linux.pie.relocate, .{phdrs});
}

// This must be done after PIE relocations have been applied or we may crash
Expand Down

0 comments on commit d633b35

Please sign in to comment.