@@ -325,7 +325,7 @@ fn _start() callconv(.naked) noreturn {
325325 ,
326326 .csky = >
327327 // The CSKY ABI assumes that `gb` is set to the address of the GOT in order for
328- // position-independent code to work. We depend on this in `std.os.linux. pie` to locate
328+ // position-independent code to work. We depend on this in `std.pie` to locate
329329 // `_DYNAMIC` as well.
330330 // r8 = FP
331331 \\ grs t0, 1f
@@ -514,33 +514,33 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.c) noreturn {
514514 while (envp_optional [envp_count ]) | _ | : (envp_count += 1 ) {}
515515 const envp = @as ([* ][* :0 ]u8 , @ptrCast (envp_optional ))[0.. envp_count ];
516516
517- if (native_os == .linux ) {
518- // Find the beginning of the auxiliary vector
519- const auxv : [* ]elf.Auxv = @ptrCast (@alignCast (envp .ptr + envp_count + 1 ));
520-
521- var at_hwcap : usize = 0 ;
522- const phdrs = init : {
523- var i : usize = 0 ;
524- var at_phdr : usize = 0 ;
525- var at_phnum : usize = 0 ;
526- while (auxv [i ].a_type != elf .AT_NULL ) : (i += 1 ) {
527- switch (auxv [i ].a_type ) {
528- elf .AT_PHNUM = > at_phnum = auxv [i ].a_un .a_val ,
529- elf .AT_PHDR = > at_phdr = auxv [i ].a_un .a_val ,
530- elf .AT_HWCAP = > at_hwcap = auxv [i ].a_un .a_val ,
531- else = > continue ,
532- }
517+ // Find the beginning of the auxiliary vector
518+ const auxv : [* ]elf.Auxv = @ptrCast (@alignCast (envp .ptr + envp_count + 1 ));
519+
520+ var at_hwcap : usize = 0 ;
521+ const phdrs = init : {
522+ var i : usize = 0 ;
523+ var at_phdr : usize = 0 ;
524+ var at_phnum : usize = 0 ;
525+ while (auxv [i ].a_type != elf .AT_NULL ) : (i += 1 ) {
526+ switch (auxv [i ].a_type ) {
527+ elf .AT_PHNUM = > at_phnum = auxv [i ].a_un .a_val ,
528+ elf .AT_PHDR = > at_phdr = auxv [i ].a_un .a_val ,
529+ elf .AT_HWCAP = > at_hwcap = auxv [i ].a_un .a_val ,
530+ else = > continue ,
533531 }
534- break :init @as ([* ]elf .Phdr , @ptrFromInt (at_phdr ))[0.. at_phnum ];
535- };
536-
537- // Apply the initial relocations as early as possible in the startup process. We cannot
538- // make calls yet on some architectures (e.g. MIPS) *because* they haven't been applied yet,
539- // so this must be fully inlined.
540- if (builtin .position_independent_executable ) {
541- @call (.always_inline , std .os .linux .pie .relocate , .{phdrs });
542532 }
533+ break :init @as ([* ]elf .Phdr , @ptrFromInt (at_phdr ))[0.. at_phnum ];
534+ };
535+
536+ // Apply the initial relocations as early as possible in the startup process. We cannot
537+ // make calls yet on some architectures (e.g. MIPS) *because* they haven't been applied yet,
538+ // so this must be fully inlined.
539+ if (builtin .position_independent_executable ) {
540+ @call (.always_inline , std .pie .relocate , .{phdrs });
541+ }
543542
543+ if (native_os == .linux ) {
544544 // This must be done after PIE relocations have been applied or we may crash
545545 // while trying to access the global variable (happens on MIPS at least).
546546 std .os .linux .elf_aux_maybe = auxv ;
@@ -567,20 +567,20 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.c) noreturn {
567567 // Here we look for the stack size in our program headers and use setrlimit
568568 // to ask for more stack space.
569569 expandStackSize (phdrs );
570+ }
570571
571- const opt_init_array_start = @extern ([* ]* const fn () callconv (.c ) void , .{
572- .name = "__init_array_start" ,
573- .linkage = .weak ,
574- });
575- const opt_init_array_end = @extern ([* ]* const fn () callconv (.c ) void , .{
576- .name = "__init_array_end" ,
577- .linkage = .weak ,
578- });
579- if (opt_init_array_start ) | init_array_start | {
580- const init_array_end = opt_init_array_end .? ;
581- const slice = init_array_start [0 .. init_array_end - init_array_start ];
582- for (slice ) | func | func ();
583- }
572+ const opt_init_array_start = @extern ([* ]* const fn () callconv (.c ) void , .{
573+ .name = "__init_array_start" ,
574+ .linkage = .weak ,
575+ });
576+ const opt_init_array_end = @extern ([* ]* const fn () callconv (.c ) void , .{
577+ .name = "__init_array_end" ,
578+ .linkage = .weak ,
579+ });
580+ if (opt_init_array_start ) | init_array_start | {
581+ const init_array_end = opt_init_array_end .? ;
582+ const slice = init_array_start [0 .. init_array_end - init_array_start ];
583+ for (slice ) | func | func ();
584584 }
585585
586586 std .posix .exit (callMainWithArgs (argc , argv , envp ));
0 commit comments