From c8e4108c5b822af0cc99d35baea108c1738d55ff Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Thu, 26 Sep 2019 17:13:57 +0200 Subject: [PATCH] Export _start as __start for MIPS targets --- lib/std/special/start.zig | 7 +++++++ src/link.cpp | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/std/special/start.zig b/lib/std/special/start.zig index 69ae65be5e..205766d05b 100644 --- a/lib/std/special/start.zig +++ b/lib/std/special/start.zig @@ -13,6 +13,11 @@ const is_wasm = switch (builtin.arch) { else => false, }; +const is_mips = switch (builtin.arch) { + .mips, .mipsel, .mips64, .mips64el => true, + else => false, +}; + comptime { if (builtin.link_libc) { @export("main", main, .Strong); @@ -22,6 +27,8 @@ comptime { @export("_start", wasm_freestanding_start, .Strong); } else if (builtin.os == .uefi) { @export("EfiMain", EfiMain, .Strong); + } else if (is_mips) { + if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong); } else { if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong); } diff --git a/src/link.cpp b/src/link.cpp index 6690f48838..41fb2ca415 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -1813,14 +1813,9 @@ static void construct_linker_job_elf(LinkJob *lj) { lj->args.append("--allow-shlib-undefined"); } - // MIPS entry point name is __start instead of _start, force the linker to - // use the latter - if (target_is_mips(g->zig_target) || g->zig_target->os == OsZen) { + if (g->zig_target->os == OsZen) { lj->args.append("-e"); lj->args.append("_start"); - } - - if (g->zig_target->os == OsZen) { lj->args.append("--image-base=0x10000000"); } }