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) {...@@ -13,6 +13,11 @@ const is_wasm = switch (builtin.arch) {
13 else => false,13 else => false,
14};14};
1515
16const is_mips = switch (builtin.arch) {
17 .mips, .mipsel, .mips64, .mips64el => true,
18 else => false,
19};
20
16comptime {21comptime {
17 if (builtin.link_libc) {22 if (builtin.link_libc) {
18 @export("main", main, .Strong);23 @export("main", main, .Strong);
...@@ -22,6 +27,8 @@ comptime {...@@ -22,6 +27,8 @@ comptime {
22 @export("_start", wasm_freestanding_start, .Strong);27 @export("_start", wasm_freestanding_start, .Strong);
23 } else if (builtin.os == .uefi) {28 } else if (builtin.os == .uefi) {
24 @export("EfiMain", EfiMain, .Strong);29 @export("EfiMain", EfiMain, .Strong);
30 } else if (is_mips) {
31 if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
25 } else {32 } else {
26 if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);33 if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
27 }34 }
src/link.cpp+1-6
...@@ -1813,14 +1813,9 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1813,14 +1813,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
1813 lj->args.append("--allow-shlib-undefined");1813 lj->args.append("--allow-shlib-undefined");
1814 }1814 }
18151815
1816 // MIPS entry point name is __start instead of _start, force the linker to1816 if (g->zig_target->os == OsZen) {
1817 // use the latter
1818 if (target_is_mips(g->zig_target) || g->zig_target->os == OsZen) {
1819 lj->args.append("-e");1817 lj->args.append("-e");
1820 lj->args.append("_start");1818 lj->args.append("_start");
1821 }
1822
1823 if (g->zig_target->os == OsZen) {
1824 lj->args.append("--image-base=0x10000000");1819 lj->args.append("--image-base=0x10000000");
1825 }1820 }
1826}1821}