From c5cfc9bf686b5d39d8524c72950eb332814f9707 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 15 Jan 2020 17:49:55 +0100 Subject: [PATCH] Move definition of __aeabi_read_tp --- lib/std/os/linux/arm-eabi.zig | 9 --------- lib/std/special/c.zig | 2 -- lib/std/special/compiler_rt.zig | 2 ++ lib/std/special/compiler_rt/arm.zig | 10 ++++++++++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 2e55abd6881858c3d6fe46447a9dc7e2dfaa806f..0fbbbc4085d1cff0c4213444a3d6c72536ec306a 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -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" : diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 9ff794d5b520a61392227a09c8a790b9449bb936..0a911ba52b640134c3516a2d59501c81955709c2 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -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 }); } } diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 03e50493c87db5fe68779dc95a67e2edca4ce210..2128883545dd987875046945667d1a227ebc3a1e 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -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 }); diff --git a/lib/std/special/compiler_rt/arm.zig b/lib/std/special/compiler_rt/arm.zig index da4b5954831f292058027eca337f0f7155a65562..6dab675fc5da01cafea746799014b0f9944ba36c 100644 --- a/lib/std/special/compiler_rt/arm.zig +++ b/lib/std/special/compiler_rt/arm.zig @@ -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 -- 2.54.0