From ce00e91aa51f05925a297c7d6dc16c37a41fc151 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Jan 2025 17:02:39 -0800 Subject: [PATCH 1/7] Compilation pipeline: do musl jobs earlier This means doing more work in parallel which is already good, but it's also a correctnes fix because we need link_task_wait_group.wait() to ensure that no more linker inputs will be generated. --- src/Compilation.zig | 102 +++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 1260bc028f..e96f7d2286 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -122,6 +122,10 @@ link_task_queue_postponed: std.ArrayListUnmanaged(link.Task) = .empty, /// the linker task thread. remaining_prelink_tasks: u32, +/// Set of work that can be represented by only flags to determine whether the +/// work is queued or not. +queued_jobs: QueuedJobs, + work_queues: [ len: { var len: usize = 0; @@ -193,10 +197,6 @@ stack_report: bool, debug_compiler_runtime_libs: bool, debug_compile_errors: bool, incremental: bool, -job_queued_compiler_rt_lib: bool = false, -job_queued_compiler_rt_obj: bool = false, -job_queued_fuzzer_lib: bool = false, -job_queued_update_builtin_zig: bool, alloc_failure_occurred: bool = false, last_update_was_cache_hit: bool = false, @@ -234,13 +234,13 @@ tsan_lib: ?CrtFile = null, /// and resolved before calling linker.flush(). libc_static_lib: ?CrtFile = null, /// Populated when we build the libcompiler_rt static library. A Job to build this is indicated -/// by setting `job_queued_compiler_rt_lib` and resolved before calling linker.flush(). +/// by setting `queued_jobs.compiler_rt_lib` and resolved before calling linker.flush(). compiler_rt_lib: ?CrtFile = null, /// Populated when we build the compiler_rt_obj object. A Job to build this is indicated -/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush(). +/// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush(). compiler_rt_obj: ?CrtFile = null, /// Populated when we build the libfuzzer static library. A Job to build this -/// is indicated by setting `job_queued_fuzzer_lib` and resolved before +/// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before /// calling linker.flush(). fuzzer_lib: ?CrtFile = null, @@ -284,6 +284,14 @@ file_system_inputs: ?*std.ArrayListUnmanaged(u8), /// This digest will be known after update() is called. digest: ?[Cache.bin_digest_len]u8 = null, +const QueuedJobs = struct { + compiler_rt_lib: bool = false, + compiler_rt_obj: bool = false, + fuzzer_lib: bool = false, + update_builtin_zig: bool, + musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, +}; + pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; pub const SemaError = Zcu.SemaError; @@ -381,8 +389,6 @@ const Job = union(enum) { glibc_crt_file: glibc.CrtFile, /// all of the glibc shared objects glibc_shared_objects, - /// one of the musl static objects - musl_crt_file: musl.CrtFile, /// one of the mingw-w64 static objects mingw_crt_file: mingw.CrtFile, @@ -1512,7 +1518,9 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .framework_dirs = options.framework_dirs, .llvm_opt_bisect_limit = options.llvm_opt_bisect_limit, .skip_linker_dependencies = options.skip_linker_dependencies, - .job_queued_update_builtin_zig = have_zcu, + .queued_jobs = .{ + .update_builtin_zig = have_zcu, + }, .function_sections = options.function_sections, .data_sections = options.data_sections, .native_system_include_paths = options.native_system_include_paths, @@ -1805,20 +1813,18 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; if (musl.needsCrtiCrtn(target)) { - try comp.queueJobs(&[_]Job{ - .{ .musl_crt_file = .crti_o }, - .{ .musl_crt_file = .crtn_o }, - }); + comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crti_o)] = true; + comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crtn_o)] = true; comp.remaining_prelink_tasks += 2; } if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| { - try comp.queueJobs(&.{.{ .musl_crt_file = f }}); + comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; } - try comp.queueJobs(&.{.{ .musl_crt_file = switch (comp.config.link_mode) { - .static => .libc_a, - .dynamic => .libc_so, - } }}); + switch (comp.config.link_mode) { + .static => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_a)] = true, + .dynamic => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_so)] = true, + } comp.remaining_prelink_tasks += 1; } else if (target.isGnuLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; @@ -1916,20 +1922,20 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (comp.include_compiler_rt and capable_of_building_compiler_rt) { if (is_exe_or_dyn_lib) { log.debug("queuing a job to build compiler_rt_lib", .{}); - comp.job_queued_compiler_rt_lib = true; + comp.queued_jobs.compiler_rt_lib = true; comp.remaining_prelink_tasks += 1; } else if (output_mode != .Obj) { log.debug("queuing a job to build compiler_rt_obj", .{}); // In this case we are making a static library, so we ask // for a compiler-rt object to put in it. - comp.job_queued_compiler_rt_obj = true; + comp.queued_jobs.compiler_rt_obj = true; comp.remaining_prelink_tasks += 1; } } if (is_exe_or_dyn_lib and comp.config.any_fuzz and capable_of_building_compiler_rt) { log.debug("queuing a job to build libfuzzer", .{}); - comp.job_queued_fuzzer_lib = true; + comp.queued_jobs.fuzzer_lib = true; comp.remaining_prelink_tasks += 1; } } @@ -3712,21 +3718,24 @@ fn performAllTheWorkInner( work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node }); } - if (comp.job_queued_compiler_rt_lib) { - comp.job_queued_compiler_rt_lib = false; + if (testAndClear(&comp.queued_jobs.compiler_rt_lib)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node }); } - if (comp.job_queued_compiler_rt_obj) { - comp.job_queued_compiler_rt_obj = false; + if (testAndClear(&comp.queued_jobs.compiler_rt_obj)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node }); } - if (comp.job_queued_fuzzer_lib) { - comp.job_queued_fuzzer_lib = false; + if (testAndClear(&comp.queued_jobs.fuzzer_lib)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); } + inline for (@typeInfo(musl.CrtFile).@"enum".fields) |field| { + const tag = @field(musl.CrtFile, field.name); + if (testAndClear(&comp.queued_jobs.musl_crt_file[@intFromEnum(tag)])) + comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); + } + { const astgen_frame = tracy.namedFrame("astgen"); defer astgen_frame.end(); @@ -3741,8 +3750,8 @@ fn performAllTheWorkInner( // 1. to avoid race condition of zig processes truncating each other's builtin.zig files // 2. optimization; in the hot path it only incurs a stat() syscall, which happens // in the `astgen_wait_group`. - if (comp.job_queued_update_builtin_zig) b: { - comp.job_queued_update_builtin_zig = false; + if (comp.queued_jobs.update_builtin_zig) b: { + comp.queued_jobs.update_builtin_zig = false; if (comp.zcu == null) break :b; // TODO put all the modules in a flat array to make them easy to iterate. var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .empty; @@ -3821,6 +3830,7 @@ fn performAllTheWorkInner( comp.link_task_wait_group.wait(); comp.link_task_wait_group.reset(); std.log.scoped(.link).debug("finished waiting for link_task_wait_group", .{}); + assert(comp.remaining_prelink_tasks == 0); } work: while (true) { @@ -3980,19 +3990,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre ); }; }, - .musl_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("musl_crt_file"); - defer named_frame.end(); - - musl.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .musl_crt_file, - "unable to build musl CRT file: {s}", - .{@errorName(err)}, - ); - }; - }, .mingw_crt_file => |crt_file| { const named_frame = tracy.namedFrame("mingw_crt_file"); defer named_frame.end(); @@ -4761,6 +4758,19 @@ fn buildRt( }; } +fn buildMuslCrtFile( + comp: *Compilation, + crt_file: musl.CrtFile, + prog_node: std.Progress.Node, +) void { + musl.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.musl_crt_file, "unable to build musl {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + fn reportRetryableCObjectError( comp: *Compilation, c_object: *CObject, @@ -6805,3 +6815,9 @@ pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode { pub fn compilerRtStrip(comp: Compilation) bool { return comp.root_mod.strip; } + +fn testAndClear(b: *bool) bool { + const result = b.*; + b.* = false; + return result; +} From 966169fa6829eb3e3c8324e06740e257deedc436 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Jan 2025 17:24:21 -0800 Subject: [PATCH 2/7] compilation pipeline: do glibc jobs earlier --- src/Compilation.zig | 88 ++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index e96f7d2286..9543e5ac7d 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -290,6 +290,9 @@ const QueuedJobs = struct { fuzzer_lib: bool = false, update_builtin_zig: bool, musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, + glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(glibc.CrtFile).@"enum".fields.len, + /// all of the glibc shared objects + glibc_shared_objects: bool = false, }; pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; @@ -385,10 +388,6 @@ const Job = union(enum) { /// Fully resolve the given `struct` or `union` type. resolve_type_fully: InternPool.Index, - /// one of the glibc static objects - glibc_crt_file: glibc.CrtFile, - /// all of the glibc shared objects - glibc_shared_objects, /// one of the mingw-w64 static objects mingw_crt_file: mingw.CrtFile, @@ -1830,22 +1829,19 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; if (glibc.needsCrtiCrtn(target)) { - try comp.queueJobs(&[_]Job{ - .{ .glibc_crt_file = .crti_o }, - .{ .glibc_crt_file = .crtn_o }, - }); + comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crti_o)] = true; + comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crtn_o)] = true; comp.remaining_prelink_tasks += 2; } if (glibc.needsCrt0(comp.config.output_mode)) |f| { - try comp.queueJobs(&.{.{ .glibc_crt_file = f }}); + comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; } - try comp.queueJobs(&[_]Job{ - .{ .glibc_shared_objects = {} }, - .{ .glibc_crt_file = .libc_nonshared_a }, - }); - comp.remaining_prelink_tasks += 1; + comp.queued_jobs.glibc_shared_objects = true; comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target); + + comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true; + comp.remaining_prelink_tasks += 1; } else if (target.isWasm() and target.os.tag == .wasi) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; @@ -3730,10 +3726,22 @@ fn performAllTheWorkInner( comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); } - inline for (@typeInfo(musl.CrtFile).@"enum".fields) |field| { - const tag = @field(musl.CrtFile, field.name); - if (testAndClear(&comp.queued_jobs.musl_crt_file[@intFromEnum(tag)])) + for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.musl_crt_file[i])) { + const tag: musl.CrtFile = @enumFromInt(i); comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); + } + } + + for (0..@typeInfo(glibc.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.glibc_crt_file[i])) { + const tag: glibc.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildGlibcCrtFile, .{ comp, tag, main_progress_node }); + } + } + + if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) { + comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); } { @@ -3966,30 +3974,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre error.AnalysisFail => return, }; }, - .glibc_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("glibc_crt_file"); - defer named_frame.end(); - - glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{ - @errorName(err), - }); - }; - }, - .glibc_shared_objects => { - const named_frame = tracy.namedFrame("glibc_shared_objects"); - defer named_frame.end(); - - glibc.buildSharedObjects(comp, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .glibc_shared_objects, - "unable to build glibc shared objects: {s}", - .{@errorName(err)}, - ); - }; - }, .mingw_crt_file => |crt_file| { const named_frame = tracy.namedFrame("mingw_crt_file"); defer named_frame.end(); @@ -4771,6 +4755,28 @@ fn buildMuslCrtFile( }; } +fn buildGlibcCrtFile( + comp: *Compilation, + crt_file: glibc.CrtFile, + prog_node: std.Progress.Node, +) void { + glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { + glibc.buildSharedObjects(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.glibc_shared_objects, "unable to build glibc shared objects: {s}", .{ + @errorName(err), + }), + }; +} + fn reportRetryableCObjectError( comp: *Compilation, c_object: *CObject, From 28da5302714734ba48c44f2a0e88cf4229bcd9f7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Jan 2025 18:39:40 -0800 Subject: [PATCH 3/7] Compilation pipeline: linker input producing Job representation Move all the remaining Jobs that produce linker inputs to be spawned earlier in the pipeline and registered with link_task_wait_group. --- src/Compilation.zig | 274 ++++++++++++++++++++------------------------ src/libcxx.zig | 4 +- 2 files changed, 128 insertions(+), 150 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 9543e5ac7d..30a7331186 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -291,8 +291,18 @@ const QueuedJobs = struct { update_builtin_zig: bool, musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(glibc.CrtFile).@"enum".fields.len, + /// one of WASI libc static objects + wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(wasi_libc.CrtFile).@"enum".fields.len, + /// one of the mingw-w64 static objects + mingw_crt_file: [@typeInfo(mingw.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(mingw.CrtFile).@"enum".fields.len, /// all of the glibc shared objects glibc_shared_objects: bool = false, + /// libunwind.a, usually needed when linking libc + libunwind: bool = false, + libcxx: bool = false, + libcxxabi: bool = false, + libtsan: bool = false, + zig_libc: bool = false, }; pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; @@ -388,20 +398,6 @@ const Job = union(enum) { /// Fully resolve the given `struct` or `union` type. resolve_type_fully: InternPool.Index, - /// one of the mingw-w64 static objects - mingw_crt_file: mingw.CrtFile, - - /// libunwind.a, usually needed when linking libc - libunwind: void, - libcxx: void, - libcxxabi: void, - libtsan: void, - /// needed when not linking libc and using LLVM for code generation because it generates - /// calls to, for example, memcpy and memset. - zig_libc: void, - /// one of WASI libc static objects - wasi_libc_crt_file: wasi_libc.CrtFile, - /// The value is the index into `windows_libs`. windows_import_lib: usize, @@ -1846,24 +1842,19 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; for (comp.wasi_emulated_libs) |crt_file| { - try comp.queueJob(.{ - .wasi_libc_crt_file = crt_file, - }); - comp.remaining_prelink_tasks += 1; + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(crt_file)] = true; } - try comp.queueJobs(&[_]Job{ - .{ .wasi_libc_crt_file = wasi_libc.execModelCrtFile(comp.config.wasi_exec_model) }, - .{ .wasi_libc_crt_file = .libc_a }, - }); + comp.remaining_prelink_tasks += @intCast(comp.wasi_emulated_libs.len); + + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.execModelCrtFile(comp.config.wasi_exec_model))] = true; + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.CrtFile.libc_a)] = true; comp.remaining_prelink_tasks += 2; } else if (target.isMinGW()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; - const crt_job: Job = .{ .mingw_crt_file = if (is_dyn_lib) .dllcrt2_o else .crt2_o }; - try comp.queueJobs(&.{ - .{ .mingw_crt_file = .mingw32_lib }, - crt_job, - }); + const main_crt_file: mingw.CrtFile = if (is_dyn_lib) .dllcrt2_o else .crt2_o; + comp.queued_jobs.mingw_crt_file[@intFromEnum(main_crt_file)] = true; + comp.queued_jobs.mingw_crt_file[@intFromEnum(mingw.CrtFile.mingw32_lib)] = true; comp.remaining_prelink_tasks += 2; // When linking mingw-w64 there are some import libs we always need. @@ -1875,7 +1866,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil else => return error.LibCUnavailable, } } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) { - try comp.queueJob(.{ .zig_libc = {} }); + comp.queued_jobs.zig_libc = true; comp.remaining_prelink_tasks += 1; } else { return error.LibCUnavailable; @@ -1888,18 +1879,22 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil for (0..count) |i| { try comp.queueJob(.{ .windows_import_lib = i }); } + // when integrating coff linker with prelink, the above + // queueJob will need to change into something else since those + // jobs are dispatched *after* the link_task_wait_group.wait() + // that happens when separateCodegenThreadOk() is false. } if (comp.wantBuildLibUnwindFromSource()) { - try comp.queueJob(.{ .libunwind = {} }); + comp.queued_jobs.libunwind = true; comp.remaining_prelink_tasks += 1; } if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.link_libcpp) { - try comp.queueJob(.libcxx); - try comp.queueJob(.libcxxabi); + comp.queued_jobs.libcxx = true; + comp.queued_jobs.libcxxabi = true; comp.remaining_prelink_tasks += 2; } if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.any_sanitize_thread) { - try comp.queueJob(.libtsan); + comp.queued_jobs.libtsan = true; comp.remaining_prelink_tasks += 1; } @@ -3726,6 +3721,30 @@ fn performAllTheWorkInner( comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); } + if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) { + comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libunwind)) { + comp.link_task_wait_group.spawnManager(buildLibUnwind, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libcxx)) { + comp.link_task_wait_group.spawnManager(buildLibCxx, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libcxxabi)) { + comp.link_task_wait_group.spawnManager(buildLibCxxAbi, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libtsan)) { + comp.link_task_wait_group.spawnManager(buildLibTsan, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.zig_libc)) { + comp.link_task_wait_group.spawnManager(buildZigLibc, .{ comp, main_progress_node }); + } + for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| { if (testAndClear(&comp.queued_jobs.musl_crt_file[i])) { const tag: musl.CrtFile = @enumFromInt(i); @@ -3740,8 +3759,18 @@ fn performAllTheWorkInner( } } - if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) { - comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); + for (0..@typeInfo(wasi_libc.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.wasi_libc_crt_file[i])) { + const tag: wasi_libc.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildWasiLibcCrtFile, .{ comp, tag, main_progress_node }); + } + } + + for (0..@typeInfo(mingw.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.mingw_crt_file[i])) { + const tag: mingw.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildMingwCrtFile, .{ comp, tag, main_progress_node }); + } } { @@ -3843,7 +3872,7 @@ fn performAllTheWorkInner( work: while (true) { for (&comp.work_queues) |*work_queue| if (work_queue.readItem()) |job| { - try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job, main_progress_node); + try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job); continue :work; }; if (comp.zcu) |zcu| { @@ -3878,7 +3907,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void { for (jobs) |job| try comp.queueJob(job); } -fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progress.Node) JobError!void { +fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void { switch (job) { .codegen_nav => |nav_index| { const zcu = comp.zcu.?; @@ -3974,19 +4003,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre error.AnalysisFail => return, }; }, - .mingw_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("mingw_crt_file"); - defer named_frame.end(); - - mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .mingw_crt_file, - "unable to build mingw-w64 CRT file {s}: {s}", - .{ @tagName(crt_file), @errorName(err) }, - ); - }; - }, .windows_import_lib => |index| { const named_frame = tracy.namedFrame("windows_import_lib"); defer named_frame.end(); @@ -4001,95 +4017,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre ); }; }, - .libunwind => { - const named_frame = tracy.namedFrame("libunwind"); - defer named_frame.end(); - - libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libunwind, - "unable to build libunwind: {s}", - .{@errorName(err)}, - ), - }; - }, - .libcxx => { - const named_frame = tracy.namedFrame("libcxx"); - defer named_frame.end(); - - libcxx.buildLibCXX(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libcxx, - "unable to build libcxx: {s}", - .{@errorName(err)}, - ), - }; - }, - .libcxxabi => { - const named_frame = tracy.namedFrame("libcxxabi"); - defer named_frame.end(); - - libcxx.buildLibCXXABI(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libcxxabi, - "unable to build libcxxabi: {s}", - .{@errorName(err)}, - ), - }; - }, - .libtsan => { - const named_frame = tracy.namedFrame("libtsan"); - defer named_frame.end(); - - libtsan.buildTsan(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libtsan, - "unable to build TSAN library: {s}", - .{@errorName(err)}, - ), - }; - }, - .wasi_libc_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("wasi_libc_crt_file"); - defer named_frame.end(); - - wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .wasi_libc_crt_file, - "unable to build WASI libc CRT file: {s}", - .{@errorName(err)}, - ); - }; - }, - .zig_libc => { - const named_frame = tracy.namedFrame("zig_libc"); - defer named_frame.end(); - - comp.buildOutputFromZig( - "c.zig", - .Lib, - &comp.libc_static_lib, - .zig_libc, - prog_node, - ) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .zig_libc, - "unable to build zig's multitarget libc: {s}", - .{@errorName(err)}, - ), - }; - }, } } @@ -4742,11 +4669,7 @@ fn buildRt( }; } -fn buildMuslCrtFile( - comp: *Compilation, - crt_file: musl.CrtFile, - prog_node: std.Progress.Node, -) void { +fn buildMuslCrtFile(comp: *Compilation, crt_file: musl.CrtFile, prog_node: std.Progress.Node) void { musl.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { error.SubCompilationFailed => return, // error reported already else => comp.lockAndSetMiscFailure(.musl_crt_file, "unable to build musl {s}: {s}", .{ @@ -4755,11 +4678,7 @@ fn buildMuslCrtFile( }; } -fn buildGlibcCrtFile( - comp: *Compilation, - crt_file: glibc.CrtFile, - prog_node: std.Progress.Node, -) void { +fn buildGlibcCrtFile(comp: *Compilation, crt_file: glibc.CrtFile, prog_node: std.Progress.Node) void { glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { error.SubCompilationFailed => return, // error reported already else => comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc {s}: {s}", .{ @@ -4777,6 +4696,65 @@ fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) voi }; } +fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std.Progress.Node) void { + mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.mingw_crt_file, "unable to build mingw-w64 {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildWasiLibcCrtFile(comp: *Compilation, crt_file: wasi_libc.CrtFile, prog_node: std.Progress.Node) void { + wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.wasi_libc_crt_file, "unable to build WASI libc {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildLibUnwind(comp: *Compilation, prog_node: std.Progress.Node) void { + libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libunwind, "unable to build libunwind: {s}", .{@errorName(err)}), + }; +} + +fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) void { + libcxx.buildLibCxx(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libcxx, "unable to build libcxx: {s}", .{@errorName(err)}), + }; +} + +fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) void { + libcxx.buildLibCxxAbi(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libcxxabi, "unable to build libcxxabi: {s}", .{@errorName(err)}), + }; +} + +fn buildLibTsan(comp: *Compilation, prog_node: std.Progress.Node) void { + libtsan.buildTsan(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libtsan, "unable to build TSAN library: {s}", .{@errorName(err)}), + }; +} + +fn buildZigLibc(comp: *Compilation, prog_node: std.Progress.Node) void { + comp.buildOutputFromZig( + "c.zig", + .Lib, + &comp.libc_static_lib, + .zig_libc, + prog_node, + ) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.zig_libc, "unable to build zig's multitarget libc: {s}", .{@errorName(err)}), + }; +} + fn reportRetryableCObjectError( comp: *Compilation, c_object: *CObject, diff --git a/src/libcxx.zig b/src/libcxx.zig index 6386d493a6..8b9ce044a4 100644 --- a/src/libcxx.zig +++ b/src/libcxx.zig @@ -114,7 +114,7 @@ pub const BuildError = error{ ZigCompilerNotBuiltWithLLVMExtensions, }; -pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { +pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } @@ -357,7 +357,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError! comp.queueLinkTaskMode(crt_file.full_object_path, output_mode); } -pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { +pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } From 77af309cb6e731a1f30967acc9e1204955c7d242 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Jan 2025 19:16:47 -0800 Subject: [PATCH 4/7] Compilation: take advantage of `@splat` --- src/Compilation.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 30a7331186..dd91974a9c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -289,12 +289,12 @@ const QueuedJobs = struct { compiler_rt_obj: bool = false, fuzzer_lib: bool = false, update_builtin_zig: bool, - musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, - glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(glibc.CrtFile).@"enum".fields.len, + musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = @splat(false), + glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = @splat(false), /// one of WASI libc static objects - wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(wasi_libc.CrtFile).@"enum".fields.len, + wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = @splat(false), /// one of the mingw-w64 static objects - mingw_crt_file: [@typeInfo(mingw.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(mingw.CrtFile).@"enum".fields.len, + mingw_crt_file: [@typeInfo(mingw.CrtFile).@"enum".fields.len]bool = @splat(false), /// all of the glibc shared objects glibc_shared_objects: bool = false, /// libunwind.a, usually needed when linking libc From 2391c460b1c137e44c8e0c092a2401b2676e2629 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Jan 2025 19:32:07 -0800 Subject: [PATCH 5/7] fix build failure when llvm not available --- src/glibc.zig | 8 ++++++-- src/mingw.zig | 4 +++- src/musl.zig | 4 +++- src/wasi_libc.zig | 4 +++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/glibc.zig b/src/glibc.zig index 744e4d1766..ef0acff6ad 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -178,7 +178,9 @@ pub const CrtFile = enum { libc_nonshared_a, }; -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } @@ -735,7 +737,9 @@ fn wordDirective(target: std.Target) []const u8 { return if (target.ptrBitWidth() == 64) ".quad" else ".long"; } -pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void { const tracy = trace(@src()); defer tracy.end(); diff --git a/src/mingw.zig b/src/mingw.zig index 1e20d32770..eeed1e6f06 100644 --- a/src/mingw.zig +++ b/src/mingw.zig @@ -17,7 +17,9 @@ pub const CrtFile = enum { mingw32_lib, }; -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } diff --git a/src/musl.zig b/src/musl.zig index 989fe461f5..e16b5601ab 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -18,7 +18,9 @@ pub const CrtFile = enum { libc_so, }; -pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } diff --git a/src/wasi_libc.zig b/src/wasi_libc.zig index 34d194a302..a44a187e8f 100644 --- a/src/wasi_libc.zig +++ b/src/wasi_libc.zig @@ -57,7 +57,9 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co }; } -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } From f5485a52bcd7495fb2be234695b4cea809f60581 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 20 Jan 2025 17:16:36 -0800 Subject: [PATCH 6/7] reject crti.o/crtn.o, embrace the future crti.o/crtn.o is a legacy strategy for calling constructor functions upon object loading that has been superseded by the init_array/fini_array mechanism. Zig code depends on neither, since the language intentionally has no way to initialize data at runtime, but alas the Zig linker still must support this feature since popular languages depend on it. Anyway, the way it works is that crti.o has the machine code prelude of two functions called _init and _fini, each in their own section with the respective name. crtn.o has the machine code instructions comprising the exitlude for each function. In between, objects use the .init and .fini link section to populate the function body. This function is then expected to be called upon object initialization and deinitialization. This mechanism is depended on by libc, for example musl and glibc, but only for older ISAs. By the time the libcs gained support for newer ISAs, they had moved on to the init_array/fini_array mechanism instead. For the Zig linker, we are trying to move the linker towards order-independent objects which is incompatible with the legacy crti/crtn mechanism. Therefore, this commit drops support entirely for crti/crtn mechanism, which is necessary since the other commits in this branch make it nondeterministic in which order the libc objects and the other link inputs are sent to the linker. The linker is still expected to produce a deterministic output, however, by ignoring object input order for the purposes of symbol resolution. --- lib/libc/glibc/sysdeps/aarch64/crti.S | 103 ----------- lib/libc/glibc/sysdeps/aarch64/crtn.S | 54 ------ lib/libc/glibc/sysdeps/alpha/crti.S | 101 ----------- lib/libc/glibc/sysdeps/alpha/crtn.S | 49 ------ lib/libc/glibc/sysdeps/arm/crti.S | 97 ----------- lib/libc/glibc/sysdeps/arm/crtn.S | 57 ------ lib/libc/glibc/sysdeps/hppa/crti.S | 162 ------------------ lib/libc/glibc/sysdeps/hppa/crtn.S | 66 ------- lib/libc/glibc/sysdeps/i386/crti.S | 86 ---------- lib/libc/glibc/sysdeps/i386/crtn.S | 47 ----- lib/libc/glibc/sysdeps/m68k/crti.S | 84 --------- lib/libc/glibc/sysdeps/m68k/crtn.S | 47 ----- lib/libc/glibc/sysdeps/microblaze/crti.S | 90 ---------- lib/libc/glibc/sysdeps/microblaze/crtn.S | 51 ------ lib/libc/glibc/sysdeps/mips/mips32/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips32/crtn.S | 59 ------- lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S | 61 ------- lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S | 61 ------- .../glibc/sysdeps/powerpc/powerpc32/crti.S | 91 ---------- .../glibc/sysdeps/powerpc/powerpc32/crtn.S | 53 ------ .../glibc/sysdeps/powerpc/powerpc64/crti.S | 90 ---------- .../glibc/sysdeps/powerpc/powerpc64/crtn.S | 51 ------ lib/libc/glibc/sysdeps/s390/s390-32/crti.S | 104 ----------- lib/libc/glibc/sysdeps/s390/s390-32/crtn.S | 47 ----- lib/libc/glibc/sysdeps/s390/s390-64/crti.S | 93 ---------- lib/libc/glibc/sysdeps/s390/s390-64/crtn.S | 47 ----- lib/libc/glibc/sysdeps/sh/crti.S | 122 ------------- lib/libc/glibc/sysdeps/sh/crtn.S | 53 ------ lib/libc/glibc/sysdeps/sparc/crti.S | 95 ---------- lib/libc/glibc/sysdeps/sparc/crtn.S | 45 ----- lib/libc/glibc/sysdeps/x86_64/crti.S | 84 --------- lib/libc/glibc/sysdeps/x86_64/crtn.S | 45 ----- lib/libc/musl/crt/aarch64/crti.s | 13 -- lib/libc/musl/crt/aarch64/crtn.s | 7 - lib/libc/musl/crt/arm/crti.s | 15 -- lib/libc/musl/crt/arm/crtn.s | 9 - lib/libc/musl/crt/crti.c | 0 lib/libc/musl/crt/crtn.c | 0 lib/libc/musl/crt/i386/crti.s | 9 - lib/libc/musl/crt/i386/crtn.s | 7 - lib/libc/musl/crt/microblaze/crti.s | 13 -- lib/libc/musl/crt/microblaze/crtn.s | 9 - lib/libc/musl/crt/mips/crti.s | 19 -- lib/libc/musl/crt/mips/crtn.s | 15 -- lib/libc/musl/crt/mips64/crti.s | 17 -- lib/libc/musl/crt/mips64/crtn.s | 15 -- lib/libc/musl/crt/mipsn32/crti.s | 18 -- lib/libc/musl/crt/mipsn32/crtn.s | 14 -- lib/libc/musl/crt/or1k/crti.s | 11 -- lib/libc/musl/crt/or1k/crtn.s | 9 - lib/libc/musl/crt/powerpc/crti.s | 15 -- lib/libc/musl/crt/powerpc/crtn.s | 13 -- lib/libc/musl/crt/powerpc64/crti.s | 21 --- lib/libc/musl/crt/powerpc64/crtn.s | 13 -- lib/libc/musl/crt/s390x/crti.s | 17 -- lib/libc/musl/crt/s390x/crtn.s | 9 - lib/libc/musl/crt/sh/crti.s | 21 --- lib/libc/musl/crt/sh/crtn.s | 13 -- lib/libc/musl/crt/x32/crti.s | 9 - lib/libc/musl/crt/x32/crtn.s | 7 - lib/libc/musl/crt/x86_64/crti.s | 9 - lib/libc/musl/crt/x86_64/crtn.s | 7 - lib/std/zig/LibCInstallation.zig | 70 +------- src/Compilation.zig | 16 -- src/glibc.zig | 100 +---------- src/link/Elf.zig | 2 - src/musl.zig | 51 ------ test/link/elf.zig | 4 - 70 files changed, 7 insertions(+), 3191 deletions(-) delete mode 100644 lib/libc/glibc/sysdeps/aarch64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/aarch64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/alpha/crti.S delete mode 100644 lib/libc/glibc/sysdeps/alpha/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/arm/crti.S delete mode 100644 lib/libc/glibc/sysdeps/arm/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/hppa/crti.S delete mode 100644 lib/libc/glibc/sysdeps/hppa/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/i386/crti.S delete mode 100644 lib/libc/glibc/sysdeps/i386/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/m68k/crti.S delete mode 100644 lib/libc/glibc/sysdeps/m68k/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/microblaze/crti.S delete mode 100644 lib/libc/glibc/sysdeps/microblaze/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/sh/crti.S delete mode 100644 lib/libc/glibc/sysdeps/sh/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/sparc/crti.S delete mode 100644 lib/libc/glibc/sysdeps/sparc/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/x86_64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/x86_64/crtn.S delete mode 100644 lib/libc/musl/crt/aarch64/crti.s delete mode 100644 lib/libc/musl/crt/aarch64/crtn.s delete mode 100644 lib/libc/musl/crt/arm/crti.s delete mode 100644 lib/libc/musl/crt/arm/crtn.s delete mode 100644 lib/libc/musl/crt/crti.c delete mode 100644 lib/libc/musl/crt/crtn.c delete mode 100644 lib/libc/musl/crt/i386/crti.s delete mode 100644 lib/libc/musl/crt/i386/crtn.s delete mode 100644 lib/libc/musl/crt/microblaze/crti.s delete mode 100644 lib/libc/musl/crt/microblaze/crtn.s delete mode 100644 lib/libc/musl/crt/mips/crti.s delete mode 100644 lib/libc/musl/crt/mips/crtn.s delete mode 100644 lib/libc/musl/crt/mips64/crti.s delete mode 100644 lib/libc/musl/crt/mips64/crtn.s delete mode 100644 lib/libc/musl/crt/mipsn32/crti.s delete mode 100644 lib/libc/musl/crt/mipsn32/crtn.s delete mode 100644 lib/libc/musl/crt/or1k/crti.s delete mode 100644 lib/libc/musl/crt/or1k/crtn.s delete mode 100644 lib/libc/musl/crt/powerpc/crti.s delete mode 100644 lib/libc/musl/crt/powerpc/crtn.s delete mode 100644 lib/libc/musl/crt/powerpc64/crti.s delete mode 100644 lib/libc/musl/crt/powerpc64/crtn.s delete mode 100644 lib/libc/musl/crt/s390x/crti.s delete mode 100644 lib/libc/musl/crt/s390x/crtn.s delete mode 100644 lib/libc/musl/crt/sh/crti.s delete mode 100644 lib/libc/musl/crt/sh/crtn.s delete mode 100644 lib/libc/musl/crt/x32/crti.s delete mode 100644 lib/libc/musl/crt/x32/crtn.s delete mode 100644 lib/libc/musl/crt/x86_64/crti.s delete mode 100644 lib/libc/musl/crt/x86_64/crtn.s diff --git a/lib/libc/glibc/sysdeps/aarch64/crti.S b/lib/libc/glibc/sysdeps/aarch64/crti.S deleted file mode 100644 index e54cb02123..0000000000 --- a/lib/libc/glibc/sysdeps/aarch64/crti.S +++ /dev/null @@ -1,103 +0,0 @@ -/* Special .init and .fini section support for AArch64. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - -#if PREINIT_FUNCTION_WEAK - .align 2 - .type call_weak_fn, %function -call_weak_fn: - adrp x0, :got:PREINIT_FUNCTION - ldr PTR_REG (0), [x0, #:got_lo12:PREINIT_FUNCTION] - cbz x0, 1f - b PREINIT_FUNCTION -1: - RET - .size call_weak_fn, .-call_weak_fn -#endif - - .section .init,"ax",%progbits - .align 2 - .global _init - .hidden _init - .type _init, %function -_init: -#if HAVE_AARCH64_PAC_RET - PACIASP -#else - BTI_C -#endif - stp x29, x30, [sp, -16]! - mov x29, sp -#if PREINIT_FUNCTION_WEAK - bl call_weak_fn -#else - bl PREINIT_FUNCTION -#endif - - .section .fini,"ax",%progbits - .align 2 - .global _fini - .hidden _fini - .type _fini, %function -_fini: -#if HAVE_AARCH64_PAC_RET - PACIASP -#else - BTI_C -#endif - stp x29, x30, [sp, -16]! - mov x29, sp diff --git a/lib/libc/glibc/sysdeps/aarch64/crtn.S b/lib/libc/glibc/sysdeps/aarch64/crtn.S deleted file mode 100644 index 3220e453ff..0000000000 --- a/lib/libc/glibc/sysdeps/aarch64/crtn.S +++ /dev/null @@ -1,54 +0,0 @@ -/* Special .init and .fini section support for AArch64. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .section .init,"ax",%progbits - ldp x29, x30, [sp], 16 -#if HAVE_AARCH64_PAC_RET - AUTIASP -#endif - RET - - .section .fini,"ax",%progbits - ldp x29, x30, [sp], 16 -#if HAVE_AARCH64_PAC_RET - AUTIASP -#endif - RET diff --git a/lib/libc/glibc/sysdeps/alpha/crti.S b/lib/libc/glibc/sysdeps/alpha/crti.S deleted file mode 100644 index 776c847ee1..0000000000 --- a/lib/libc/glibc/sysdeps/alpha/crti.S +++ /dev/null @@ -1,101 +0,0 @@ -/* Special .init and .fini section support for Alpha. - Copyright (C) 2001-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. - - This differs from what would be generated for ordinary code in that - we save and restore the GP within the function. In order for linker - relaxation to work, the value in the GP register on exit from a function - must be valid for the function entry point. Normally, a function is - contained within one object file and this is not an issue, provided - that the function reloads the gp after making any function calls. - However, _init and _fini are constructed from pieces of many object - files, all of which may have different GP values. So we must reload - the GP value from crti.o in crtn.o. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init, "ax", @progbits - .globl _init - .hidden _init - .type _init, @function - .usepv _init, std -_init: - ldgp $29, 0($27) - subq $30, 16, $30 -#if PREINIT_FUNCTION_WEAK - lda $27, PREINIT_FUNCTION -#endif - stq $26, 0($30) - stq $29, 8($30) -#if PREINIT_FUNCTION_WEAK - beq $27, 1f - jsr $26, ($27), PREINIT_FUNCTION - ldq $29, 8($30) -1: -#else - bsr $26, PREINIT_FUNCTION !samegp -#endif - .p2align 3 - - .section .fini, "ax", @progbits - .globl _fini - .hidden _fini - .type _fini,@function - .usepv _fini,std -_fini: - ldgp $29, 0($27) - subq $30, 16, $30 - stq $26, 0($30) - stq $29, 8($30) - .p2align 3 diff --git a/lib/libc/glibc/sysdeps/alpha/crtn.S b/lib/libc/glibc/sysdeps/alpha/crtn.S deleted file mode 100644 index a14b52f6c1..0000000000 --- a/lib/libc/glibc/sysdeps/alpha/crtn.S +++ /dev/null @@ -1,49 +0,0 @@ -/* Special .init and .fini section support for Alpha. - Copyright (C) 2001-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init, "ax", @progbits - ldq $26, 0($30) - ldq $29, 8($30) - addq $30, 16, $30 - ret - - .section .fini, "ax", @progbits - ldq $26, 0($30) - ldq $29, 8($30) - addq $30, 16, $30 - ret diff --git a/lib/libc/glibc/sysdeps/arm/crti.S b/lib/libc/glibc/sysdeps/arm/crti.S deleted file mode 100644 index 9d6bbe977d..0000000000 --- a/lib/libc/glibc/sysdeps/arm/crti.S +++ /dev/null @@ -1,97 +0,0 @@ -/* Special .init and .fini section support for ARM. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -/* Always build .init and .fini sections in ARM mode. */ -#define NO_THUMB -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - -#if PREINIT_FUNCTION_WEAK - .p2align 2 - .type call_weak_fn, %function -call_weak_fn: - ldr r3, .LGOT - ldr r2, .LGOT+4 -.LPIC: - add r3, pc, r3 - ldr r2, [r3, r2] - cmp r2, #0 - bxeq lr - b PREINIT_FUNCTION - .p2align 2 -.LGOT: - .word _GLOBAL_OFFSET_TABLE_-(.LPIC+8) - .word PREINIT_FUNCTION(GOT) -#endif - - .section .init,"ax",%progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, %function -_init: - push {r3, lr} -#if PREINIT_FUNCTION_WEAK - bl call_weak_fn -#else - bl PREINIT_FUNCTION -#endif - - .section .fini,"ax",%progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, %function -_fini: - push {r3, lr} diff --git a/lib/libc/glibc/sysdeps/arm/crtn.S b/lib/libc/glibc/sysdeps/arm/crtn.S deleted file mode 100644 index 0839e8713d..0000000000 --- a/lib/libc/glibc/sysdeps/arm/crtn.S +++ /dev/null @@ -1,57 +0,0 @@ -/* Special .init and .fini section support for ARM. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* Always build .init and .fini sections in ARM mode. */ -#define NO_THUMB -#include - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",%progbits -#ifdef __ARM_ARCH_4T__ - pop {r3, lr} - bx lr -#else - pop {r3, pc} -#endif - - .section .fini,"ax",%progbits -#ifdef __ARM_ARCH_4T__ - pop {r3, lr} - bx lr -#else - pop {r3, pc} -#endif diff --git a/lib/libc/glibc/sysdeps/hppa/crti.S b/lib/libc/glibc/sysdeps/hppa/crti.S deleted file mode 100644 index 46482224f4..0000000000 --- a/lib/libc/glibc/sysdeps/hppa/crti.S +++ /dev/null @@ -1,162 +0,0 @@ -/* Special .init and .fini section support for HPPA - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - -/* If we have working .init_array support, we want to keep the .init - section empty (apart from the mandatory prologue/epilogue. This - ensures that the default unwind conventions (return-pointer in b0, - frame state in ar.pfs, etc.) will do the Right Thing. To ensure - an empty .init section, we register gmon_initializer() via the - .init_array. - - --davidm 02/10/29 */ - -#if PREINIT_FUNCTION_WEAK -/* This blob of assembly code is one simple C function: - -static void -__attribute__ ((used)) -gmon_initializer (void) -{ - extern void weak_function __gmon_start__ (void); - - if (__gmon_start__) - (*__gmon_start__)(); -} - -In a final executable, PLABEL32 relocations for function pointers are -resolved at link time. Typically, binutils/ld resolves __gmon_start__ -using an external shared library. __gmon_start__ is always called if -it is found at link time. If __gmon_start__ is not found at runtime -due to a library update, then the function pointer will point at a null -function descriptor and calling it will cause a segmentation fault. -So, we call __canonicalize_funcptr_for_compare to obtain the canonicalized -address of __gmon_start__ and skip calling __gmon_start__ if it is zero. - - */ - .type __canonicalize_funcptr_for_compare,@function - .type $$dyncall,@function - - .section .data.rel.ro,"aw",@progbits - .align 4 -.LC0: - .type __gmon_start__,@function - .word P%__gmon_start__ - - .text - .align 4 - .type gmon_initializer,@function -gmon_initializer: - .PROC - .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=4 - .ENTRY - stw %r2,-20(%r30) - stwm %r4,64(%r30) - stw %r3,-60(%r30) - addil LT'.LC0,%r19 - ldw RT'.LC0(%r1),%r28 - ldw 0(%r28),%r3 - comib,= 0,%r3,1f - copy %r19,%r4 - stw %r19,-32(%r30) - bl __canonicalize_funcptr_for_compare,%r2 - copy %r3,%r26 - comib,= 0,%r28,1f - copy %r4,%r19 - copy %r3,%r22 - .CALL ARGW0=GR - bl $$dyncall,%r31 - copy %r31,%r2 -1: - ldw -84(%r30),%r2 - ldw -60(%r30),%r3 - bv %r0(%r2) - ldwm -64(%r30),%r4 - .EXIT - .PROCEND - .size gmon_initializer, .-gmon_initializer - -# undef PREINIT_FUNCTION -# define PREINIT_FUNCTION gmon_initializer -#endif - - .section .init_array, "aw" - .word P% PREINIT_FUNCTION - - -/* _init prologue. */ - .section .init, "ax", %progbits - .align 4 - .globl _init - .hidden _init - .type _init,@function -_init: - stw %rp,-20(%sp) - stwm %r4,64(%sp) - stw %r19,-32(%sp) - -/* _fini prologue. */ - .section .fini,"ax",%progbits - .align 4 - .globl _fini - .hidden _fini - .type _fini,@function -_fini: - stw %rp,-20(%sp) - stwm %r4,64(%sp) - stw %r19,-32(%sp) - copy %r19,%r4 diff --git a/lib/libc/glibc/sysdeps/hppa/crtn.S b/lib/libc/glibc/sysdeps/hppa/crtn.S deleted file mode 100644 index bf5d8009b9..0000000000 --- a/lib/libc/glibc/sysdeps/hppa/crtn.S +++ /dev/null @@ -1,66 +0,0 @@ -/* Special .init and .fini section support for HPPA - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init, "ax", @progbits - ldw -84(%sp),%rp - copy %r4,%r19 - bv %r0(%rp) -_end_init: - ldwm -64(%sp),%r4 - -/* Our very own unwind info, because the assembler can't handle - functions split into two or more pieces. */ - .section .PARISC.unwind - .extern _init - .word _init, _end_init - .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08 - -/* Here is the tail end of _fini. */ - .section .fini, "ax", @progbits - ldw -84(%sp),%rp - copy %r4,%r19 - bv %r0(%rp) -_end_fini: - ldwm -64(%sp),%r4 - - .section .PARISC.unwind - .extern _fini - .word _fini, _end_fini - .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08 diff --git a/lib/libc/glibc/sysdeps/i386/crti.S b/lib/libc/glibc/sysdeps/i386/crti.S deleted file mode 100644 index f9662eeb5a..0000000000 --- a/lib/libc/glibc/sysdeps/i386/crti.S +++ /dev/null @@ -1,86 +0,0 @@ -/* Special .init and .fini section support for x86. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - pushl %ebx - /* Maintain 16-byte stack alignment for called functions. */ - subl $8, %esp - LOAD_PIC_REG (bx) -#if PREINIT_FUNCTION_WEAK - movl PREINIT_FUNCTION@GOT(%ebx), %eax - testl %eax, %eax - je .Lno_weak_fn - call *%eax -.Lno_weak_fn: -#else - call PREINIT_FUNCTION -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - pushl %ebx - subl $8, %esp - LOAD_PIC_REG (bx) diff --git a/lib/libc/glibc/sysdeps/i386/crtn.S b/lib/libc/glibc/sysdeps/i386/crtn.S deleted file mode 100644 index 46f40ab554..0000000000 --- a/lib/libc/glibc/sysdeps/i386/crtn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* Special .init and .fini section support for x86. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - addl $8, %esp - popl %ebx - ret - - .section .fini,"ax",@progbits - addl $8, %esp - popl %ebx - ret diff --git a/lib/libc/glibc/sysdeps/m68k/crti.S b/lib/libc/glibc/sysdeps/m68k/crti.S deleted file mode 100644 index e52088799a..0000000000 --- a/lib/libc/glibc/sysdeps/m68k/crti.S +++ /dev/null @@ -1,84 +0,0 @@ -/* Special .init and .fini section support for m68k. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - link.w %fp, #0 - move.l %a5, -(%sp) - LOAD_GOT (%a5) -#if PREINIT_FUNCTION_WEAK - tst.l PREINIT_FUNCTION@GOT(%a5) - jeq 1f - jbsr PREINIT_FUNCTION@PLTPC -1: -#else - jbsr PREINIT_FUNCTION -#endif - - .section .fini,"ax",@progbits - .align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - link.w %fp, #0 - move.l %a5, -(%sp) - LOAD_GOT (%a5) diff --git a/lib/libc/glibc/sysdeps/m68k/crtn.S b/lib/libc/glibc/sysdeps/m68k/crtn.S deleted file mode 100644 index 58e640e2c4..0000000000 --- a/lib/libc/glibc/sysdeps/m68k/crtn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* Special .init and .fini section support for m68k. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - move.l -4(%fp), %a5 - unlk %fp - rts - - .section .fini,"ax",@progbits - move.l -4(%fp), %a5 - unlk %fp - rts diff --git a/lib/libc/glibc/sysdeps/microblaze/crti.S b/lib/libc/glibc/sysdeps/microblaze/crti.S deleted file mode 100644 index 58097a1b72..0000000000 --- a/lib/libc/glibc/sysdeps/microblaze/crti.S +++ /dev/null @@ -1,90 +0,0 @@ -/* Special .init and .fini section support for MicroBlaze. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - addik r1,r1,-32 - swi r20,r1,28 - mfs r20,rpc - addik r20,r20,_GLOBAL_OFFSET_TABLE_+8 - lwi r3,r20,PREINIT_FUNCTION@GOT -#if PREINIT_FUNCTION_WEAK - beqid r3,$Lno_weak_fn: - swi r15,r1,0 - brlid r15,PREINIT_FUNCTION@PLT -$Lno_weak_fn: -#else - swi r15,r1,0 - brald r15,r3 -#endif - nop # Unfilled delay slot - - .section .fini,"ax",@progbits - .align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - addik r1,r1,-32 - swi r20,r1,28 - swi r15,r1,0 - mfs r20,rpc - addik r20,r20,_GLOBAL_OFFSET_TABLE_+8 diff --git a/lib/libc/glibc/sysdeps/microblaze/crtn.S b/lib/libc/glibc/sysdeps/microblaze/crtn.S deleted file mode 100644 index 90b1aba1bd..0000000000 --- a/lib/libc/glibc/sysdeps/microblaze/crtn.S +++ /dev/null @@ -1,51 +0,0 @@ -/* Special .init and .fini section support for MicroBlaze. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .section .init,"ax",@progbits - lwi r15,r1,0 - lwi r20,r1,28 - rtsd r15,8 - addik r1,r1,32 - - .section .fini,"ax",@progbits - lwi r15,r1,0 - lwi r20,r1,28 - rtsd r15,8 - addik r1,r1,32 diff --git a/lib/libc/glibc/sysdeps/mips/mips32/crti.S b/lib/libc/glibc/sysdeps/mips/mips32/crti.S deleted file mode 100644 index df1d91cf90..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips32/crti.S +++ /dev/null @@ -1,102 +0,0 @@ -/* Special .init and .fini section support for MIPS (o32). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include - -#ifdef __mips_micromips -# define JALR_RELOC R_MICROMIPS_JALR -#else -# define JALR_RELOC R_MIPS_JALR -#endif - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .set nomips16 - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - .set noreorder - .cpload $25 - .set reorder - addiu $sp,$sp,-32 - .cprestore 16 - sw $31,28($sp) -#if PREINIT_FUNCTION_WEAK - lw $2,%got(PREINIT_FUNCTION)($28) - beq $2,$0,.Lno_weak_fn - lw $25,%call16(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -.Lno_weak_fn: - .insn -#else - lw $25,%got(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - .set noreorder - .cpload $25 - .set reorder - addiu $sp,$sp,-32 - .cprestore 16 - sw $31,28($sp) diff --git a/lib/libc/glibc/sysdeps/mips/mips32/crtn.S b/lib/libc/glibc/sysdeps/mips/mips32/crtn.S deleted file mode 100644 index 4fd4c745d9..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips32/crtn.S +++ /dev/null @@ -1,59 +0,0 @@ -/* Special .init and .fini section support for MIPS (o32). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .set nomips16 - - .section .init,"ax",@progbits - lw $31,28($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,32 - .set macro - .set reorder - - .section .fini,"ax",@progbits - lw $31,28($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,32 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S b/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S deleted file mode 100644 index 351655d08a..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S +++ /dev/null @@ -1,102 +0,0 @@ -/* Special .init and .fini section support for MIPS (n32). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include - -#ifdef __mips_micromips -# define JALR_RELOC R_MICROMIPS_JALR -#else -# define JALR_RELOC R_MIPS_JALR -#endif - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .set nomips16 - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - addiu $sp,$sp,-16 - sd $28,0($sp) - lui $28,%hi(%neg(%gp_rel(_init))) - addu $28,$28,$25 - sd $31,8($sp) - addiu $28,$28,%lo(%neg(%gp_rel(_init))) -#if PREINIT_FUNCTION_WEAK - lw $2,%got_disp(PREINIT_FUNCTION)($28) - beq $2,$0,.Lno_weak_fn - lw $25,%call16(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -.Lno_weak_fn: - .insn -#else - lw $25,%got_disp(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - addiu $sp,$sp,-16 - sd $28,0($sp) - lui $28,%hi(%neg(%gp_rel(_fini))) - addu $28,$28,$25 - sd $31,8($sp) - addiu $28,$28,%lo(%neg(%gp_rel(_fini))) diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S b/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S deleted file mode 100644 index f9a6c7ee4c..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S +++ /dev/null @@ -1,61 +0,0 @@ -/* Special .init and .fini section support for MIPS (n32). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .set nomips16 - - .section .init,"ax",@progbits - ld $31,8($sp) - ld $28,0($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,16 - .set macro - .set reorder - - .section .fini,"ax",@progbits - ld $31,8($sp) - ld $28,0($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,16 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S b/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S deleted file mode 100644 index 9726eb326a..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S +++ /dev/null @@ -1,102 +0,0 @@ -/* Special .init and .fini section support for MIPS (n64). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include - -#ifdef __mips_micromips -# define JALR_RELOC R_MICROMIPS_JALR -#else -# define JALR_RELOC R_MIPS_JALR -#endif - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .set nomips16 - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - daddiu $sp,$sp,-16 - sd $28,0($sp) - lui $28,%hi(%neg(%gp_rel(_init))) - daddu $28,$28,$25 - sd $31,8($sp) - daddiu $28,$28,%lo(%neg(%gp_rel(_init))) -#if PREINIT_FUNCTION_WEAK - ld $2,%got_disp(PREINIT_FUNCTION)($28) - beq $2,$0,.Lno_weak_fn - ld $25,%call16(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -.Lno_weak_fn: - .insn -#else - ld $25,%got_disp(PREINIT_FUNCTION)($28) - .reloc 1f,JALR_RELOC,PREINIT_FUNCTION -1: jalr $25 -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - daddiu $sp,$sp,-16 - sd $28,0($sp) - lui $28,%hi(%neg(%gp_rel(_fini))) - daddu $28,$28,$25 - sd $31,8($sp) - daddiu $28,$28,%lo(%neg(%gp_rel(_fini))) diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S b/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S deleted file mode 100644 index 2722b2812c..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S +++ /dev/null @@ -1,61 +0,0 @@ -/* Special .init and .fini section support for MIPS (n64). - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .set nomips16 - - .section .init,"ax",@progbits - ld $31,8($sp) - ld $28,0($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - daddiu $sp,$sp,16 - .set macro - .set reorder - - .section .fini,"ax",@progbits - ld $31,8($sp) - ld $28,0($sp) - .set noreorder - .set nomacro - /* zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - daddiu $sp,$sp,16 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S b/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S deleted file mode 100644 index 6d0e17aa65..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S +++ /dev/null @@ -1,91 +0,0 @@ -/* Special .init and .fini section support for PowerPC. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - stwu r1, -16(r1) - mflr r0 - stw r0, 20(r1) - stw r30, 8(r1) - SETUP_GOT_ACCESS (r30, .Lgot_label_i) - addis r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@ha - addi r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@l -#if PREINIT_FUNCTION_WEAK - lwz r0, PREINIT_FUNCTION@got(r30) - cmpwi cr7, r0, 0 - beq+ cr7, 1f - bl PREINIT_FUNCTION@plt -1: -#else - bl PREINIT_FUNCTION@local -#endif - - .section .fini,"ax",@progbits - .align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - stwu r1, -16(r1) - mflr r0 - stw r0, 20(r1) - stw r30, 8(r1) - SETUP_GOT_ACCESS (r30, .Lgot_label_f) diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S b/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S deleted file mode 100644 index 2a59a6cebc..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S +++ /dev/null @@ -1,53 +0,0 @@ -/* Special .init and .fini section support for PowerPC. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .section .init,"ax",@progbits - lwz r0, 20(r1) - mtlr r0 - lwz r30, 8(r1) - addi r1, r1, 16 - blr - - .section .fini,"ax",@progbits - lwz r0, 20(r1) - mtlr r0 - lwz r30, 8(r1) - addi r1, r1, 16 - blr diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S b/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S deleted file mode 100644 index 71bdddfb3b..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S +++ /dev/null @@ -1,90 +0,0 @@ -/* Special .init and .fini section support for PowerPC64. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - -#if PREINIT_FUNCTION_WEAK - .section ".toc", "aw" -.LC0: - .tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION -#endif - .section ".init", "ax", @progbits - ENTRY_2(_init) - .hidden _init - .align ALIGNARG (2) -BODY_LABEL (_init): - LOCALENTRY(_init) - mflr 0 - std 0, FRAME_LR_SAVE(r1) - stdu r1, -FRAME_MIN_SIZE_PARM(r1) -#if PREINIT_FUNCTION_WEAK - addis r9, r2, .LC0@toc@ha - ld r0, .LC0@toc@l(r9) - cmpdi cr7, r0, 0 - beq+ cr7, 1f -#endif - bl JUMPTARGET (PREINIT_FUNCTION) - nop -1: - - .section ".fini", "ax", @progbits - ENTRY_2(_fini) - .hidden _fini - .align ALIGNARG (2) -BODY_LABEL (_fini): - LOCALENTRY(_fini) - mflr 0 - std 0, FRAME_LR_SAVE(r1) - stdu r1, -FRAME_MIN_SIZE_PARM(r1) diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S b/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S deleted file mode 100644 index 4e91231f2c..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S +++ /dev/null @@ -1,51 +0,0 @@ -/* Special .init and .fini section support for PowerPC64. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .section .init,"ax",@progbits - addi r1, r1, FRAME_MIN_SIZE_PARM - ld r0, FRAME_LR_SAVE(r1) - mtlr r0 - blr - - .section .fini,"ax",@progbits - addi r1, r1, FRAME_MIN_SIZE_PARM - ld r0, FRAME_LR_SAVE(r1) - mtlr r0 - blr diff --git a/lib/libc/glibc/sysdeps/s390/s390-32/crti.S b/lib/libc/glibc/sysdeps/s390/s390-32/crti.S deleted file mode 100644 index 47c5cb8781..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-32/crti.S +++ /dev/null @@ -1,104 +0,0 @@ -/* Special .init and .fini section support for S/390. - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .globl _init - .hidden _init - .type _init,@function - .align 4 -_init: - stm %r6,%r15,24(%r15) - bras %r13,1f -0: -#if PREINIT_FUNCTION_WEAK - .long PREINIT_FUNCTION@GOT -#else - .long PREINIT_FUNCTION-0b -#endif - .long _GLOBAL_OFFSET_TABLE_-0b -1: lr %r1,%r15 - ahi %r15,-96 - st %r1,0(%r15) - l %r12,4(%r13) - ar %r12,%r13 - l %r1,0(%r13) -#if PREINIT_FUNCTION_WEAK - l %r1,0(%r1,%r12) - ltr %r1,%r1 - je 2f -#else - la %r1,0(%r1,%r13) -#endif - basr %r14,%r1 - .align 4,0x07 -2: - - .section .fini,"ax",@progbits - .globl _fini - .hidden _fini - .type _fini,@function - .align 4 -_fini: - stm %r6,%r15,24(%r15) - bras %r13,1f -0: .long _GLOBAL_OFFSET_TABLE_-0b -1: lr %r1,%r15 - ahi %r15,-96 - st %r1,0(%r15) - l %r12,0(%r13) - ar %r12,%r13 - .align 4,0x07 diff --git a/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S b/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S deleted file mode 100644 index 911f35b586..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* Special .init and .fini section support for S/390. - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - l %r4,152(%r15) - lm %r6,%r15,120(%r15) - br %r4 - - .section .fini,"ax",@progbits - l %r4,152(%r15) - lm %r6,%r15,120(%r15) - br %r4 diff --git a/lib/libc/glibc/sysdeps/s390/s390-64/crti.S b/lib/libc/glibc/sysdeps/s390/s390-64/crti.S deleted file mode 100644 index 6323b753be..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-64/crti.S +++ /dev/null @@ -1,93 +0,0 @@ -/* Special .init and .fini section support for 64 bit S/390. - Copyright (C) 2001-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .align 4 - .globl _init - .hidden _init - .type _init,@function -_init: - stmg %r6,%r15,48(%r15) - lgr %r1,%r15 - aghi %r15,-160 - stg %r1,0(%r15) - larl %r12,_GLOBAL_OFFSET_TABLE_ -#if PREINIT_FUNCTION_WEAK - /* zig patch: GOTENT -> GOT. revert with llvm 20. */ - larl %r1,PREINIT_FUNCTION@GOT - lg %r1,0(%r1) - ltgr %r1,%r1 - je 1f - basr %r14,%r1 -#else - brasl %r14,PREINIT_FUNCTION -#endif - .align 4,0x07 -1: - - .section .fini,"ax",@progbits - .align 4 - .globl _fini - .hidden _fini - .type _fini,@function -_fini: - stmg %r6,%r15,48(%r15) - lg %r1,120(%r15) - aghi %r15,-160 - stg %r1,0(%r15) - larl %r12,_GLOBAL_OFFSET_TABLE_ - .align 4,0x07 diff --git a/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S b/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S deleted file mode 100644 index 9598f9e875..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* Special .init and .fini section support for 64 bit S/390. - Copyright (C) 2001-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init - lg %r4,272(%r15) - lmg %r6,%r15,208(%r15) - br %r4 - - .section .fini - lg %r4,272(%r15) - lmg %r6,%r15,208(%r15) - br %r4 diff --git a/lib/libc/glibc/sysdeps/sh/crti.S b/lib/libc/glibc/sysdeps/sh/crti.S deleted file mode 100644 index 9d6f77afa9..0000000000 --- a/lib/libc/glibc/sysdeps/sh/crti.S +++ /dev/null @@ -1,122 +0,0 @@ -/* Special .init and .fini section support for SH. - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .align 5 - .global _init - .hidden _init - .type _init, @function -_init: - mov.l r12,@-r15 - mova .L12,r0 - mov.l .L12,r12 - mov.l r14,@-r15 - add r0,r12 - sts.l pr,@-r15 -#if PREINIT_FUNCTION_WEAK - mov.l .L13,r0 - mov.l @(r0,r12),r1 - tst r1,r1 - bt/s .L8 - mov r15,r14 - mov.l .L14,r1 - bsrf r1 -.LPCS0: - nop -.L8: -#else - mova .L13,r0 - mov.l .L13,r1 - add r0,r1 - jsr @r1 - mov r15,r14 -#endif - bra 1f - nop - .align 2 -.L12: - .long _GLOBAL_OFFSET_TABLE_ -#if PREINIT_FUNCTION_WEAK -.L13: - .long PREINIT_FUNCTION@GOT -.L14: - .long PREINIT_FUNCTION@PLT-(.LPCS0+2-(.)) -#else -.L13: - .long PREINIT_FUNCTION@PLT -#endif -1: - - .section .fini,"ax",@progbits - .align 5 - .global _fini - .hidden _fini - .type _fini, @function -_fini: - mov.l r12,@-r15 - mova .L19,r0 - mov.l r14,@-r15 - sts.l pr,@-r15 - mov.l .L19,r12 - mov r15,r14 - add r0,r12 - bra 0f - nop - .align 2 -.L19: - .long _GLOBAL_OFFSET_TABLE_ -0: diff --git a/lib/libc/glibc/sysdeps/sh/crtn.S b/lib/libc/glibc/sysdeps/sh/crtn.S deleted file mode 100644 index 55ad6f7864..0000000000 --- a/lib/libc/glibc/sysdeps/sh/crtn.S +++ /dev/null @@ -1,53 +0,0 @@ -/* Special .init and .fini section support for SH. - Copyright (C) 2000-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - mov r14,r15 - lds.l @r15+,pr - mov.l @r15+,r14 - mov.l @r15+,r12 - rts - nop - - .section .fini,"ax",@progbits - mov r14,r15 - lds.l @r15+,pr - mov.l @r15+,r14 - mov.l @r15+,r12 - rts - nop diff --git a/lib/libc/glibc/sysdeps/sparc/crti.S b/lib/libc/glibc/sysdeps/sparc/crti.S deleted file mode 100644 index b3e73102f4..0000000000 --- a/lib/libc/glibc/sysdeps/sparc/crti.S +++ /dev/null @@ -1,95 +0,0 @@ -/* Special .init and .fini section support for sparc. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - -#ifdef __arch64__ -#define STACKFRAME_SIZE 176 -#define GOT_LOAD ldx -#else -#define STACKFRAME_SIZE 96 -#define GOT_LOAD ld -#endif - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - save %sp, -STACKFRAME_SIZE, %sp -#if PREINIT_FUNCTION_WEAK - SETUP_PIC_REG(l7) - sethi %gdop_hix22(PREINIT_FUNCTION), %g1 - xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1 - GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION) - cmp %g1, 0 - be 1f - nop - call PREINIT_FUNCTION - nop -1: -#else - call PREINIT_FUNCTION - nop -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - save %sp, -STACKFRAME_SIZE, %sp diff --git a/lib/libc/glibc/sysdeps/sparc/crtn.S b/lib/libc/glibc/sysdeps/sparc/crtn.S deleted file mode 100644 index ea86c50f1b..0000000000 --- a/lib/libc/glibc/sysdeps/sparc/crtn.S +++ /dev/null @@ -1,45 +0,0 @@ -/* Special .init and .fini section support for sparc. - Copyright (C) 1995-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - jmp %i7 + 8 - restore - - .section .fini,"ax",@progbits - jmp %i7 + 8 - restore diff --git a/lib/libc/glibc/sysdeps/x86_64/crti.S b/lib/libc/glibc/sysdeps/x86_64/crti.S deleted file mode 100644 index 4d3f6767d4..0000000000 --- a/lib/libc/glibc/sysdeps/x86_64/crti.S +++ /dev/null @@ -1,84 +0,0 @@ -/* Special .init and .fini section support for x86-64. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crti.S puts a function prologue at the beginning of the .init and - .fini sections and defines global symbols for those addresses, so - they can be called as functions. The symbols _init and _fini are - magic and cause the linker to emit DT_INIT and DT_FINI. */ - -#include -#include - -#ifndef PREINIT_FUNCTION -# define PREINIT_FUNCTION __gmon_start__ -#endif - -#ifndef PREINIT_FUNCTION_WEAK -# define PREINIT_FUNCTION_WEAK 1 -#endif - -#if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) -#else - .hidden PREINIT_FUNCTION -#endif - - .section .init,"ax",@progbits - .p2align 2 - .globl _init - .hidden _init - .type _init, @function -_init: - _CET_ENDBR - /* Maintain 16-byte stack alignment for called functions. */ - subq $8, %rsp -#if PREINIT_FUNCTION_WEAK - movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax - testq %rax, %rax - je .Lno_weak_fn - call *%rax -.Lno_weak_fn: -#else - call PREINIT_FUNCTION -#endif - - .section .fini,"ax",@progbits - .p2align 2 - .globl _fini - .hidden _fini - .type _fini, @function -_fini: - _CET_ENDBR - subq $8, %rsp diff --git a/lib/libc/glibc/sysdeps/x86_64/crtn.S b/lib/libc/glibc/sysdeps/x86_64/crtn.S deleted file mode 100644 index 614f22e7f1..0000000000 --- a/lib/libc/glibc/sysdeps/x86_64/crtn.S +++ /dev/null @@ -1,45 +0,0 @@ -/* Special .init and .fini section support for x86-64. - Copyright (C) 2012-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - - .section .init,"ax",@progbits - addq $8, %rsp - ret - - .section .fini,"ax",@progbits - addq $8, %rsp - ret diff --git a/lib/libc/musl/crt/aarch64/crti.s b/lib/libc/musl/crt/aarch64/crti.s deleted file mode 100644 index 775df0ac04..0000000000 --- a/lib/libc/musl/crt/aarch64/crti.s +++ /dev/null @@ -1,13 +0,0 @@ -.section .init -.global _init -.type _init,%function -_init: - stp x29,x30,[sp,-16]! - mov x29,sp - -.section .fini -.global _fini -.type _fini,%function -_fini: - stp x29,x30,[sp,-16]! - mov x29,sp diff --git a/lib/libc/musl/crt/aarch64/crtn.s b/lib/libc/musl/crt/aarch64/crtn.s deleted file mode 100644 index 73cab6926b..0000000000 --- a/lib/libc/musl/crt/aarch64/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - ldp x29,x30,[sp],#16 - ret - -.section .fini - ldp x29,x30,[sp],#16 - ret diff --git a/lib/libc/musl/crt/arm/crti.s b/lib/libc/musl/crt/arm/crti.s deleted file mode 100644 index cccda3eaef..0000000000 --- a/lib/libc/musl/crt/arm/crti.s +++ /dev/null @@ -1,15 +0,0 @@ -.syntax unified - -.section .init -.global _init -.type _init,%function -.align 2 -_init: - push {r0,lr} - -.section .fini -.global _fini -.type _fini,%function -.align 2 -_fini: - push {r0,lr} diff --git a/lib/libc/musl/crt/arm/crtn.s b/lib/libc/musl/crt/arm/crtn.s deleted file mode 100644 index dc020f92ef..0000000000 --- a/lib/libc/musl/crt/arm/crtn.s +++ /dev/null @@ -1,9 +0,0 @@ -.syntax unified - -.section .init - pop {r0,lr} - bx lr - -.section .fini - pop {r0,lr} - bx lr diff --git a/lib/libc/musl/crt/crti.c b/lib/libc/musl/crt/crti.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/libc/musl/crt/crtn.c b/lib/libc/musl/crt/crtn.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/libc/musl/crt/i386/crti.s b/lib/libc/musl/crt/i386/crti.s deleted file mode 100644 index d2682a20b0..0000000000 --- a/lib/libc/musl/crt/i386/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - sub $12,%esp - -.section .fini -.global _fini -_fini: - sub $12,%esp diff --git a/lib/libc/musl/crt/i386/crtn.s b/lib/libc/musl/crt/i386/crtn.s deleted file mode 100644 index f3b61e01bb..0000000000 --- a/lib/libc/musl/crt/i386/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - add $12,%esp - ret - -.section .fini - add $12,%esp - ret diff --git a/lib/libc/musl/crt/microblaze/crti.s b/lib/libc/musl/crt/microblaze/crti.s deleted file mode 100644 index ed1c2fa43a..0000000000 --- a/lib/libc/musl/crt/microblaze/crti.s +++ /dev/null @@ -1,13 +0,0 @@ -.section .init -.global _init -.align 2 -_init: - addi r1, r1, -32 - swi r15, r1, 0 - -.section .fini -.global _fini -.align 2 -_fini: - addi r1, r1, -32 - swi r15, r1, 0 diff --git a/lib/libc/musl/crt/microblaze/crtn.s b/lib/libc/musl/crt/microblaze/crtn.s deleted file mode 100644 index 1e02c984e8..0000000000 --- a/lib/libc/musl/crt/microblaze/crtn.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init - lwi r15, r1, 0 - rtsd r15, 8 - addi r1, r1, 32 - -.section .fini - lwi r15, r1, 0 - rtsd r15, 8 - addi r1, r1, 32 diff --git a/lib/libc/musl/crt/mips/crti.s b/lib/libc/musl/crt/mips/crti.s deleted file mode 100644 index 39dee38004..0000000000 --- a/lib/libc/musl/crt/mips/crti.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noreorder - -.section .init -.global _init -.type _init,@function -.align 2 -_init: - subu $sp,$sp,32 - sw $gp,24($sp) - sw $ra,28($sp) - -.section .fini -.global _fini -.type _fini,@function -.align 2 -_fini: - subu $sp,$sp,32 - sw $gp,24($sp) - sw $ra,28($sp) diff --git a/lib/libc/musl/crt/mips/crtn.s b/lib/libc/musl/crt/mips/crtn.s deleted file mode 100644 index 5146d83a0e..0000000000 --- a/lib/libc/musl/crt/mips/crtn.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder - -.section .init - lw $gp,24($sp) - lw $ra,28($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp,$sp,32 - -.section .fini - lw $gp,24($sp) - lw $ra,28($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp,$sp,32 diff --git a/lib/libc/musl/crt/mips64/crti.s b/lib/libc/musl/crt/mips64/crti.s deleted file mode 100644 index c962dd099b..0000000000 --- a/lib/libc/musl/crt/mips64/crti.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noreorder - -.section .init -.global _init -.align 3 -_init: - dsubu $sp, $sp, 32 - sd $gp, 16($sp) - sd $ra, 24($sp) - -.section .fini -.global _fini -.align 3 -_fini: - dsubu $sp, $sp, 32 - sd $gp, 16($sp) - sd $ra, 24($sp) diff --git a/lib/libc/musl/crt/mips64/crtn.s b/lib/libc/musl/crt/mips64/crtn.s deleted file mode 100644 index dc4dbb03ad..0000000000 --- a/lib/libc/musl/crt/mips64/crtn.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder - -.section .init - ld $gp,16($sp) - ld $ra,24($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - daddu $sp,$sp,32 - -.section .fini - ld $gp,16($sp) - ld $ra,24($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - daddu $sp,$sp,32 diff --git a/lib/libc/musl/crt/mipsn32/crti.s b/lib/libc/musl/crt/mipsn32/crti.s deleted file mode 100644 index 14fa28d99d..0000000000 --- a/lib/libc/musl/crt/mipsn32/crti.s +++ /dev/null @@ -1,18 +0,0 @@ -.set noreorder -.section .init -.global _init -.type _init,@function -.align 2 -_init: - subu $sp, $sp, 32 - sd $gp, 16($sp) - sd $ra, 24($sp) - -.section .fini -.global _fini -.type _fini,@function -.align 2 -_fini: - subu $sp, $sp, 32 - sd $gp, 16($sp) - sd $ra, 24($sp) diff --git a/lib/libc/musl/crt/mipsn32/crtn.s b/lib/libc/musl/crt/mipsn32/crtn.s deleted file mode 100644 index 66f0c7a680..0000000000 --- a/lib/libc/musl/crt/mipsn32/crtn.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noreorder -.section .init - ld $gp, 16($sp) - ld $ra, 24($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp, $sp, 32 - -.section .fini - ld $gp, 16($sp) - ld $ra, 24($sp) - # zig patch: j -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp, $sp, 32 diff --git a/lib/libc/musl/crt/or1k/crti.s b/lib/libc/musl/crt/or1k/crti.s deleted file mode 100644 index 7e7414596a..0000000000 --- a/lib/libc/musl/crt/or1k/crti.s +++ /dev/null @@ -1,11 +0,0 @@ -.section .init -.global _init -_init: - l.addi r1,r1,-4 - l.sw 0(r1),r9 - -.section .fini -.global _fini -_fini: - l.addi r1,r1,-4 - l.sw 0(r1),r9 diff --git a/lib/libc/musl/crt/or1k/crtn.s b/lib/libc/musl/crt/or1k/crtn.s deleted file mode 100644 index 4185a02771..0000000000 --- a/lib/libc/musl/crt/or1k/crtn.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init - l.lwz r9,0(r1) - l.jr r9 - l.addi r1,r1,4 - -.section .fini - l.lwz r9,0(r1) - l.jr r9 - l.addi r1,r1,4 diff --git a/lib/libc/musl/crt/powerpc/crti.s b/lib/libc/musl/crt/powerpc/crti.s deleted file mode 100644 index 60461ca4c2..0000000000 --- a/lib/libc/musl/crt/powerpc/crti.s +++ /dev/null @@ -1,15 +0,0 @@ -.section .init -.align 2 -.global _init -_init: - stwu 1,-32(1) - mflr 0 - stw 0,36(1) - -.section .fini -.align 2 -.global _fini -_fini: - stwu 1,-32(1) - mflr 0 - stw 0,36(1) diff --git a/lib/libc/musl/crt/powerpc/crtn.s b/lib/libc/musl/crt/powerpc/crtn.s deleted file mode 100644 index 2d14a6f0b7..0000000000 --- a/lib/libc/musl/crt/powerpc/crtn.s +++ /dev/null @@ -1,13 +0,0 @@ -.section .init -.align 2 - lwz 0,36(1) - addi 1,1,32 - mtlr 0 - blr - -.section .fini -.align 2 - lwz 0,36(1) - addi 1,1,32 - mtlr 0 - blr diff --git a/lib/libc/musl/crt/powerpc64/crti.s b/lib/libc/musl/crt/powerpc64/crti.s deleted file mode 100644 index 9f712f0e07..0000000000 --- a/lib/libc/musl/crt/powerpc64/crti.s +++ /dev/null @@ -1,21 +0,0 @@ -.section .init -.align 2 -.global _init -_init: - addis 2, 12, .TOC.-_init@ha - addi 2, 2, .TOC.-_init@l - .localentry _init,.-_init - mflr 0 - std 0, 16(1) - stdu 1,-32(1) - -.section .fini -.align 2 -.global _fini -_fini: - addis 2, 12, .TOC.-_fini@ha - addi 2, 2, .TOC.-_fini@l - .localentry _fini,.-_fini - mflr 0 - std 0, 16(1) - stdu 1,-32(1) diff --git a/lib/libc/musl/crt/powerpc64/crtn.s b/lib/libc/musl/crt/powerpc64/crtn.s deleted file mode 100644 index a7a9f4a07d..0000000000 --- a/lib/libc/musl/crt/powerpc64/crtn.s +++ /dev/null @@ -1,13 +0,0 @@ -.section .init -.align 2 - addi 1, 1, 32 - ld 0, 16(1) - mtlr 0 - blr - -.section .fini -.align 2 - addi 1, 1, 32 - ld 0, 16(1) - mtlr 0 - blr diff --git a/lib/libc/musl/crt/s390x/crti.s b/lib/libc/musl/crt/s390x/crti.s deleted file mode 100644 index f453205bd0..0000000000 --- a/lib/libc/musl/crt/s390x/crti.s +++ /dev/null @@ -1,17 +0,0 @@ -.section .init -.align 2 -.global _init -_init: - stmg %r14, %r15, 112(%r15) - lgr %r0, %r15 - aghi %r15, -160 - stg %r0, 0(%r15) - -.section .fini -.align 2 -.global _fini -_fini: - stmg %r14, %r15, 112(%r15) - lgr %r0, %r15 - aghi %r15, -160 - stg %r0, 0(%r15) diff --git a/lib/libc/musl/crt/s390x/crtn.s b/lib/libc/musl/crt/s390x/crtn.s deleted file mode 100644 index 06066dc994..0000000000 --- a/lib/libc/musl/crt/s390x/crtn.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.align 2 - lmg %r14, %r15, 272(%r15) - br %r14 - -.section .fini -.align 2 - lmg %r14, %r15, 272(%r15) - br %r14 diff --git a/lib/libc/musl/crt/sh/crti.s b/lib/libc/musl/crt/sh/crti.s deleted file mode 100644 index d99bfd5c82..0000000000 --- a/lib/libc/musl/crt/sh/crti.s +++ /dev/null @@ -1,21 +0,0 @@ -.section .init -.global _init -.type _init, @function -_init: - add #-4, r15 - mov.l r12, @-r15 - mov.l r14, @-r15 - sts.l pr, @-r15 - mov r15, r14 - nop - -.section .fini -.global _fini -.type _fini, @function -_fini: - add #-4, r15 - mov.l r12, @-r15 - mov.l r14, @-r15 - sts.l pr, @-r15 - mov r15, r14 - nop diff --git a/lib/libc/musl/crt/sh/crtn.s b/lib/libc/musl/crt/sh/crtn.s deleted file mode 100644 index 958ce951b6..0000000000 --- a/lib/libc/musl/crt/sh/crtn.s +++ /dev/null @@ -1,13 +0,0 @@ -.section .init - lds.l @r15+, pr - mov.l @r15+, r14 - mov.l @r15+, r12 - rts - add #4, r15 - -.section .fini - lds.l @r15+, pr - mov.l @r15+, r14 - mov.l @r15+, r12 - rts - add #4, r15 diff --git a/lib/libc/musl/crt/x32/crti.s b/lib/libc/musl/crt/x32/crti.s deleted file mode 100644 index 4788968b22..0000000000 --- a/lib/libc/musl/crt/x32/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - push %rax - -.section .fini -.global _fini -_fini: - push %rax diff --git a/lib/libc/musl/crt/x32/crtn.s b/lib/libc/musl/crt/x32/crtn.s deleted file mode 100644 index 29198b7751..0000000000 --- a/lib/libc/musl/crt/x32/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - pop %rax - ret - -.section .fini - pop %rax - ret diff --git a/lib/libc/musl/crt/x86_64/crti.s b/lib/libc/musl/crt/x86_64/crti.s deleted file mode 100644 index 4788968b22..0000000000 --- a/lib/libc/musl/crt/x86_64/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - push %rax - -.section .fini -.global _fini -_fini: - push %rax diff --git a/lib/libc/musl/crt/x86_64/crtn.s b/lib/libc/musl/crt/x86_64/crtn.s deleted file mode 100644 index 29198b7751..0000000000 --- a/lib/libc/musl/crt/x86_64/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - pop %rax - ret - -.section .fini - pop %rax - ret diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 56bc388f5d..8a7c6a15e1 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -694,10 +694,8 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void { /// `CsuPaths`. pub const CrtBasenames = struct { crt0: ?[]const u8 = null, - crti: ?[]const u8 = null, crtbegin: ?[]const u8 = null, crtend: ?[]const u8 = null, - crtn: ?[]const u8 = null, pub const GetArgs = struct { target: std.Target, @@ -751,137 +749,96 @@ pub const CrtBasenames = struct { return switch (target.os.tag) { .linux => switch (mode) { - .dynamic_lib => .{ - .crti = "crti.o", - .crtn = "crtn.o", - }, + .dynamic_lib => .{}, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "rcrt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, }, .dragonfly => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .freebsd => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .netbsd => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .openbsd => switch (mode) { @@ -902,49 +859,34 @@ pub const CrtBasenames = struct { }, .haiku => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .solaris, .illumos => switch (mode) { - .dynamic_lib => .{ - .crti = "crti.o", - .crtn = "crtn.o", - }, + .dynamic_lib => .{}, .dynamic_exe, .dynamic_pie => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_exe, .static_pie => .{}, }, @@ -955,10 +897,8 @@ pub const CrtBasenames = struct { pub const CrtPaths = struct { crt0: ?Path = null, - crti: ?Path = null, crtbegin: ?Path = null, crtend: ?Path = null, - crtn: ?Path = null, }; pub fn resolveCrtPaths( @@ -980,7 +920,6 @@ pub fn resolveCrtPaths( }) orelse true) "gcc80" else "gcc54"; return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, - .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| .{ .root_dir = crt_dir_path.root_dir, .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), @@ -989,7 +928,6 @@ pub fn resolveCrtPaths( .root_dir = crt_dir_path.root_dir, .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), } else null, - .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, .haiku => { @@ -999,19 +937,15 @@ pub fn resolveCrtPaths( }; return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, - .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null, - .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, else => { return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, - .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null, - .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, } diff --git a/src/Compilation.zig b/src/Compilation.zig index dd91974a9c..a1fdc4fd1a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -801,8 +801,6 @@ pub const MiscTask = enum { docs_copy, docs_wasm, - @"musl crti.o", - @"musl crtn.o", @"musl crt1.o", @"musl rcrt1.o", @"musl Scrt1.o", @@ -817,8 +815,6 @@ pub const MiscTask = enum { @"libwasi-emulated-mman.a", @"libwasi-emulated-signal.a", - @"glibc crti.o", - @"glibc crtn.o", @"glibc Scrt1.o", @"glibc libc_nonshared.a", @"glibc shared object", @@ -1807,11 +1803,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil } else if (target.isMusl() and !target.isWasm()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; - if (musl.needsCrtiCrtn(target)) { - comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crti_o)] = true; - comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crtn_o)] = true; - comp.remaining_prelink_tasks += 2; - } if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| { comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; @@ -1824,11 +1815,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil } else if (target.isGnuLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; - if (glibc.needsCrtiCrtn(target)) { - comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crti_o)] = true; - comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crtn_o)] = true; - comp.remaining_prelink_tasks += 2; - } if (glibc.needsCrt0(comp.config.output_mode)) |f| { comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; @@ -6757,10 +6743,8 @@ fn getCrtPathsInner( return .{ .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null, - .crti = if (basenames.crti) |basename| try crtFilePath(crt_files, basename) else null, .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null, .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null, - .crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null, }; } diff --git a/src/glibc.zig b/src/glibc.zig index ef0acff6ad..83d4439dcd 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -156,24 +156,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI return abi; } -fn useElfInitFini(target: std.Target) bool { - // Legacy architectures use _init/_fini. - return switch (target.cpu.arch) { - .arm, .armeb => true, - .aarch64, .aarch64_be => true, - .m68k => true, - .mips, .mipsel, .mips64, .mips64el => true, - .powerpc, .powerpcle, .powerpc64, .powerpc64le => true, - .s390x => true, - .sparc, .sparc64 => true, - .x86, .x86_64 => true, - else => false, - }; -} - pub const CrtFile = enum { - crti_o, - crtn_o, scrt1_o, libc_nonshared_a, }; @@ -201,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre // waste computation and create false negatives. switch (crt_file) { - .crti_o => { - var args = std.ArrayList([]const u8).init(arena); - try add_include_dirs(comp, arena, &args); - try args.appendSlice(&[_][]const u8{ - "-D_LIBC_REENTRANT", - "-include", - try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"), - "-DMODULE_NAME=libc", - "-Wno-nonportable-include-path", - "-include", - try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), - "-DTOP_NAMESPACE=glibc", - "-DASSEMBLER", - "-Wa,--noexecstack", - }); - var files = [_]Compilation.CSourceFile{ - .{ - .src_path = try start_asm_path(comp, arena, "crti.S"), - .cache_exempt_flags = args.items, - .owner = comp.root_mod, - }, - }; - return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files, .{}); - }, - .crtn_o => { - var args = std.ArrayList([]const u8).init(arena); - try add_include_dirs(comp, arena, &args); - try args.appendSlice(&[_][]const u8{ - "-D_LIBC_REENTRANT", - "-DMODULE_NAME=libc", - "-include", - try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), - "-DTOP_NAMESPACE=glibc", - "-DASSEMBLER", - "-Wa,--noexecstack", - }); - var files = [_]Compilation.CSourceFile{ - .{ - .src_path = try start_asm_path(comp, arena, "crtn.S"), - .cache_exempt_flags = args.items, - .owner = undefined, - }, - }; - return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files, .{}); - }, .scrt1_o => { const start_o: Compilation.CSourceFile = blk: { var args = std.ArrayList([]const u8).init(arena); @@ -383,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre }); try add_include_dirs(comp, arena, &args); - if (!useElfInitFini(target)) { - try args.append("-DNO_INITFINI"); - } + try args.append("-DNO_INITFINI"); if (target.cpu.arch == .x86) { // This prevents i386/sysdep.h from trying to do some @@ -432,32 +368,15 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![ try result.appendSlice(comp.zig_lib_directory.path.?); try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s); if (is_sparc) { - if (mem.eql(u8, basename, "crti.S") or mem.eql(u8, basename, "crtn.S")) { - try result.appendSlice("sparc"); + if (is_64) { + try result.appendSlice("sparc" ++ s ++ "sparc64"); } else { - if (is_64) { - try result.appendSlice("sparc" ++ s ++ "sparc64"); - } else { - try result.appendSlice("sparc" ++ s ++ "sparc32"); - } + try result.appendSlice("sparc" ++ s ++ "sparc32"); } } else if (arch.isArm()) { try result.appendSlice("arm"); } else if (arch.isMIPS()) { - if (!mem.eql(u8, basename, "crti.S") and !mem.eql(u8, basename, "crtn.S")) { - try result.appendSlice("mips"); - } else { - if (is_64) { - const abi_dir = if (comp.getTarget().abi == .gnuabin32) - "n32" - else - "n64"; - try result.appendSlice("mips" ++ s ++ "mips64" ++ s); - try result.appendSlice(abi_dir); - } else { - try result.appendSlice("mips" ++ s ++ "mips32"); - } - } + try result.appendSlice("mips"); } else if (arch == .x86_64) { try result.appendSlice("x86_64"); } else if (arch == .x86) { @@ -1366,15 +1285,6 @@ fn buildSharedLib( try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node); } -// Return true if glibc has crti/crtn sources for that architecture. -pub fn needsCrtiCrtn(target: std.Target) bool { - return switch (target.cpu.arch) { - .riscv32, .riscv64 => false, - .loongarch64 => false, - else => true, - }; -} - pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile { return switch (output_mode) { .Obj, .Lib => null, diff --git a/src/link/Elf.zig b/src/link/Elf.zig index ea2fa56a5d..957675fb0e 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1869,7 +1869,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s // csu prelude const csu = try comp.getCrtPaths(arena); if (csu.crt0) |p| try argv.append(try p.toString(arena)); - if (csu.crti) |p| try argv.append(try p.toString(arena)); if (csu.crtbegin) |p| try argv.append(try p.toString(arena)); for (self.rpath_table.keys()) |rpath| { @@ -2061,7 +2060,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s // crt postlude if (csu.crtend) |p| try argv.append(try p.toString(arena)); - if (csu.crtn) |p| try argv.append(try p.toString(arena)); if (self.base.allow_shlib_undefined) { try argv.append("--allow-shlib-undefined"); diff --git a/src/musl.zig b/src/musl.zig index e16b5601ab..511d55e08d 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig"); const build_options = @import("build_options"); pub const CrtFile = enum { - crti_o, - crtn_o, crt1_o, rcrt1_o, scrt1_o, @@ -30,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro const arena = arena_allocator.allocator(); switch (in_crt_file) { - .crti_o => { - var args = std.ArrayList([]const u8).init(arena); - try addCcArgs(comp, arena, &args, false); - var files = [_]Compilation.CSourceFile{ - .{ - .src_path = try start_asm_path(comp, arena, "crti.s"), - .extra_flags = args.items, - .owner = undefined, - }, - }; - return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{ - .function_sections = true, - .data_sections = true, - .omit_frame_pointer = true, - .no_builtin = true, - }); - }, - .crtn_o => { - var args = std.ArrayList([]const u8).init(arena); - try addCcArgs(comp, arena, &args, false); - var files = [_]Compilation.CSourceFile{ - .{ - .src_path = try start_asm_path(comp, arena, "crtn.s"), - .extra_flags = args.items, - .owner = undefined, - }, - }; - return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{ - .function_sections = true, - .data_sections = true, - .omit_frame_pointer = true, - .no_builtin = true, - }); - }, .crt1_o => { var args = std.ArrayList([]const u8).init(arena); try addCcArgs(comp, arena, &args, false); @@ -329,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro } } -/// Return true if musl has arch-specific crti/crtn sources. -/// See lib/libc/musl/crt/ARCH/crt?.s . -pub fn needsCrtiCrtn(target: std.Target) bool { - return switch (target.cpu.arch) { - .loongarch64, - .m68k, - .riscv32, - .riscv64, - .wasm32, - .wasm64, - => false, - else => true, - }; -} - pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile { return switch (output_mode) { .Obj, .Lib => null, diff --git a/test/link/elf.zig b/test/link/elf.zig index 5014d20c98..a64da3ad20 100644 --- a/test/link/elf.zig +++ b/test/link/elf.zig @@ -1,7 +1,3 @@ -//! Here we test our ELF linker for correctness and functionality. -//! Currently, we support linking x86_64 Linux, but in the future we -//! will progressively relax those to exercise more combinations. - pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { _ = build_opts; const elf_step = b.step("test-elf", "Run ELF tests"); From 874e17fe608a7b8d4324dada32664fcfe44978cd Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 20 Jan 2025 20:06:25 -0800 Subject: [PATCH 7/7] embrace the future slightly less Turns out that even modern Debian aarch64 glibc libc_nonshared.a has references to _init, meaning that the previous commit caused a regression when trying to build any -lc executable on that target. This commit backs out the changes to LibCInstallation. There is still a fork in the road coming up when the self-hosted ELF linker becomes load bearing on that target. --- lib/std/zig/LibCInstallation.zig | 70 +++++++++++++++++++++++++++++++- src/Compilation.zig | 2 + src/link/Elf.zig | 2 + 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 8a7c6a15e1..56bc388f5d 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -694,8 +694,10 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void { /// `CsuPaths`. pub const CrtBasenames = struct { crt0: ?[]const u8 = null, + crti: ?[]const u8 = null, crtbegin: ?[]const u8 = null, crtend: ?[]const u8 = null, + crtn: ?[]const u8 = null, pub const GetArgs = struct { target: std.Target, @@ -749,96 +751,137 @@ pub const CrtBasenames = struct { return switch (target.os.tag) { .linux => switch (mode) { - .dynamic_lib => .{}, + .dynamic_lib => .{ + .crti = "crti.o", + .crtn = "crtn.o", + }, .dynamic_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", + .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", + .crti = "crti.o", + .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", + .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "rcrt1.o", + .crti = "crti.o", + .crtn = "crtn.o", }, }, .dragonfly => switch (mode) { .dynamic_lib => .{ + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, }, .freebsd => switch (mode) { .dynamic_lib => .{ + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", + .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, }, .netbsd => switch (mode) { .dynamic_lib => .{ + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt0.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "crt0.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt0.o", + .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "crt0.o", + .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, }, .openbsd => switch (mode) { @@ -859,34 +902,49 @@ pub const CrtBasenames = struct { }, .haiku => switch (mode) { .dynamic_lib => .{ + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "start_dyn.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "start_dyn.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "start_dyn.o", + .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", + .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "start_dyn.o", + .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", + .crtn = "crtn.o", }, }, .solaris, .illumos => switch (mode) { - .dynamic_lib => .{}, + .dynamic_lib => .{ + .crti = "crti.o", + .crtn = "crtn.o", + }, .dynamic_exe, .dynamic_pie => .{ .crt0 = "crt1.o", + .crti = "crti.o", + .crtn = "crtn.o", }, .static_exe, .static_pie => .{}, }, @@ -897,8 +955,10 @@ pub const CrtBasenames = struct { pub const CrtPaths = struct { crt0: ?Path = null, + crti: ?Path = null, crtbegin: ?Path = null, crtend: ?Path = null, + crtn: ?Path = null, }; pub fn resolveCrtPaths( @@ -920,6 +980,7 @@ pub fn resolveCrtPaths( }) orelse true) "gcc80" else "gcc54"; return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, + .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| .{ .root_dir = crt_dir_path.root_dir, .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), @@ -928,6 +989,7 @@ pub fn resolveCrtPaths( .root_dir = crt_dir_path.root_dir, .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), } else null, + .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, .haiku => { @@ -937,15 +999,19 @@ pub fn resolveCrtPaths( }; return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, + .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null, + .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, else => { return .{ .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, + .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null, + .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, } diff --git a/src/Compilation.zig b/src/Compilation.zig index a1fdc4fd1a..b85033264a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6743,8 +6743,10 @@ fn getCrtPathsInner( return .{ .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null, + .crti = if (basenames.crti) |basename| try crtFilePath(crt_files, basename) else null, .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null, .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null, + .crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null, }; } diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 957675fb0e..ea2fa56a5d 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1869,6 +1869,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s // csu prelude const csu = try comp.getCrtPaths(arena); if (csu.crt0) |p| try argv.append(try p.toString(arena)); + if (csu.crti) |p| try argv.append(try p.toString(arena)); if (csu.crtbegin) |p| try argv.append(try p.toString(arena)); for (self.rpath_table.keys()) |rpath| { @@ -2060,6 +2061,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s // crt postlude if (csu.crtend) |p| try argv.append(try p.toString(arena)); + if (csu.crtn) |p| try argv.append(try p.toString(arena)); if (self.base.allow_shlib_undefined) { try argv.append("--allow-shlib-undefined");