authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-09-26 17:13:57+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-09-26 17:13:57+02:00
logc8e4108c5b822af0cc99d35baea108c1738d55ff
tree1c4cf0eeba4bc8f5e1f995e4a96a89e6c5c82ebc
parenta9be62f0858749ae479d05167392c7cf965da3ce

Export _start as __start for MIPS targets


2 files changed, 8 insertions(+), 6 deletions(-)

lib/std/special/start.zig+7
......@@ -13,6 +13,11 @@ const is_wasm = switch (builtin.arch) {
1313 else => false,
1414};
1515
16const is_mips = switch (builtin.arch) {
17 .mips, .mipsel, .mips64, .mips64el => true,
18 else => false,
19};
20
1621comptime {
1722 if (builtin.link_libc) {
1823 @export("main", main, .Strong);
......@@ -22,6 +27,8 @@ comptime {
2227 @export("_start", wasm_freestanding_start, .Strong);
2328 } else if (builtin.os == .uefi) {
2429 @export("EfiMain", EfiMain, .Strong);
30 } else if (is_mips) {
31 if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
2532 } else {
2633 if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
2734 }
src/link.cpp+1-6
......@@ -1813,14 +1813,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
18131813 lj->args.append("--allow-shlib-undefined");
18141814 }
18151815
1816 // MIPS entry point name is __start instead of _start, force the linker to
1817 // use the latter
1818 if (target_is_mips(g->zig_target) || g->zig_target->os == OsZen) {
1816 if (g->zig_target->os == OsZen) {
18191817 lj->args.append("-e");
18201818 lj->args.append("_start");
1821 }
1822
1823 if (g->zig_target->os == OsZen) {
18241819 lj->args.append("--image-base=0x10000000");
18251820 }
18261821}