| ... | @@ -435,6 +435,22 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn { | ... | @@ -435,6 +435,22 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn { |
| 435 | // Here we look for the stack size in our program headers and use setrlimit | 435 | // Here we look for the stack size in our program headers and use setrlimit |
| 436 | // to ask for more stack space. | 436 | // to ask for more stack space. |
| 437 | expandStackSize(phdrs); | 437 | expandStackSize(phdrs); |
| | 438 | |
| | 439 | { |
| | 440 | const opt_init_array_start = @extern([*]*const fn () callconv(.C) void, .{ |
| | 441 | .name = "__init_array_start", |
| | 442 | .linkage = .weak, |
| | 443 | }); |
| | 444 | const opt_init_array_end = @extern([*]*const fn () callconv(.C) void, .{ |
| | 445 | .name = "__init_array_end", |
| | 446 | .linkage = .weak, |
| | 447 | }); |
| | 448 | if (opt_init_array_start) |init_array_start| { |
| | 449 | const init_array_end = opt_init_array_end.?; |
| | 450 | const slice = init_array_start[0 .. init_array_end - init_array_start]; |
| | 451 | for (slice) |func| func(); |
| | 452 | } |
| | 453 | } |
| 438 | } | 454 | } |
| 439 | | 455 | |
| 440 | std.posix.exit(callMainWithArgs(argc, argv, envp)); | 456 | std.posix.exit(callMainWithArgs(argc, argv, envp)); |