Move definition of __aeabi_read_tp

This commit is contained in:
LemonBoy 2020-01-15 17:49:55 +01:00
parent 5d5345728a
commit c5cfc9bf68
4 changed files with 12 additions and 11 deletions

View File

@ -88,15 +88,6 @@ pub fn syscall6(
/// This matches the libc clone function.
pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
// LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass
// that to llvm via zig, see https://github.com/ziglang/zig/issues/2883.
// LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig.
pub fn getThreadPointer() callconv(.C) usize {
return asm volatile ("mrc p15, 0, %[ret], c13, c0, 3"
: [ret] "=r" (-> usize)
);
}
pub fn restore() callconv(.Naked) void {
return asm volatile ("svc #0"
:

View File

@ -32,8 +32,6 @@ comptime {
@export(strlen, .{ .name = "strlen", .linkage = .Strong });
} else if (is_msvc) {
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
} else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {
@export(std.os.linux.getThreadPointer, .{ .name = "__aeabi_read_tp", .linkage = .Strong });
}
}

View File

@ -177,6 +177,8 @@ comptime {
@export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
@export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
@export(@import("compiler_rt/arm.zig").__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
@export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
@export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
@export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });

View File

@ -32,6 +32,7 @@ pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
@setRuntimeSafety(false);
_ = memset(dest, 0, n);
}
pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {
unreachable;
}
@ -42,6 +43,15 @@ pub fn __aeabi_unwind_cpp_pr2() callconv(.C) void {
unreachable;
}
// This function can only clobber r0 according to the ABI
pub fn __aeabi_read_tp() callconv(.Naked) void {
asm volatile (
\\ mrc p15, 0, r0, c13, c0, 3
\\ bx lr
);
unreachable;
}
// The following functions are wrapped in an asm block to ensure the required
// calling convention is always respected