| author | |
| committer | |
| log | e25015bdce1e6ff4ab594a34fc7d1f0cd296dc25 |
| tree | ac067a7b4b5f9ad2a08db914246a6db3fa39f152 |
| parent | 767d2526918192da548d77970f97028dd62cf9d1 |
| signature |
Needed for linking the Linux kernel.4 files changed, 34 insertions(+), 1 deletions(-)
src/Compilation.zig+4| ... | @@ -1485,6 +1485,8 @@ pub const CreateOptions = struct { | ... | @@ -1485,6 +1485,8 @@ pub const CreateOptions = struct { |
| 1485 | linker_print_gc_sections: bool = false, | 1485 | linker_print_gc_sections: bool = false, |
| 1486 | linker_print_icf_sections: bool = false, | 1486 | linker_print_icf_sections: bool = false, |
| 1487 | linker_print_map: bool = false, | 1487 | linker_print_map: bool = false, |
| 1488 | linker_nmagic: bool = false, | ||
| 1489 | linker_fatal_warnings: bool = false, | ||
| 1488 | llvm_opt_bisect_limit: i32 = -1, | 1490 | llvm_opt_bisect_limit: i32 = -1, |
| 1489 | build_id: ?std.zig.BuildId = null, | 1491 | build_id: ?std.zig.BuildId = null, |
| 1490 | disable_c_depfile: bool = false, | 1492 | disable_c_depfile: bool = false, |
| ... | @@ -2188,6 +2190,8 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, | ... | @@ -2188,6 +2190,8 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2188 | .print_gc_sections = options.linker_print_gc_sections, | 2190 | .print_gc_sections = options.linker_print_gc_sections, |
| 2189 | .print_icf_sections = options.linker_print_icf_sections, | 2191 | .print_icf_sections = options.linker_print_icf_sections, |
| 2190 | .print_map = options.linker_print_map, | 2192 | .print_map = options.linker_print_map, |
| 2193 | .nmagic = options.linker_nmagic, | ||
| 2194 | .fatal_warnings = options.linker_fatal_warnings, | ||
| 2191 | .tsaware = options.linker_tsaware, | 2195 | .tsaware = options.linker_tsaware, |
| 2192 | .nxcompat = options.linker_nxcompat, | 2196 | .nxcompat = options.linker_nxcompat, |
| 2193 | .dynamicbase = options.linker_dynamicbase, | 2197 | .dynamicbase = options.linker_dynamicbase, |
src/link.zig+2| ... | @@ -466,6 +466,8 @@ pub const File = struct { | ... | @@ -466,6 +466,8 @@ pub const File = struct { |
| 466 | print_gc_sections: bool, | 466 | print_gc_sections: bool, |
| 467 | print_icf_sections: bool, | 467 | print_icf_sections: bool, |
| 468 | print_map: bool, | 468 | print_map: bool, |
| 469 | nmagic: bool, | ||
| 470 | fatal_warnings: bool, | ||
| 469 | 471 | ||
| 470 | /// Use a wrapper function for symbol. Any undefined reference to symbol | 472 | /// Use a wrapper function for symbol. Any undefined reference to symbol |
| 471 | /// will be resolved to __wrap_symbol. Any undefined reference to | 473 | /// will be resolved to __wrap_symbol. Any undefined reference to |
src/link/Lld.zig+12| ... | @@ -80,6 +80,8 @@ pub const Elf = struct { | ... | @@ -80,6 +80,8 @@ pub const Elf = struct { |
| 80 | sort_section: ?SortSection, | 80 | sort_section: ?SortSection, |
| 81 | print_icf_sections: bool, | 81 | print_icf_sections: bool, |
| 82 | print_map: bool, | 82 | print_map: bool, |
| 83 | nmagic: bool, | ||
| 84 | fatal_warnings: bool, | ||
| 83 | emit_relocs: bool, | 85 | emit_relocs: bool, |
| 84 | z_nodelete: bool, | 86 | z_nodelete: bool, |
| 85 | z_notext: bool, | 87 | z_notext: bool, |
| ... | @@ -135,6 +137,8 @@ pub const Elf = struct { | ... | @@ -135,6 +137,8 @@ pub const Elf = struct { |
| 135 | .sort_section = options.sort_section, | 137 | .sort_section = options.sort_section, |
| 136 | .print_icf_sections = options.print_icf_sections, | 138 | .print_icf_sections = options.print_icf_sections, |
| 137 | .print_map = options.print_map, | 139 | .print_map = options.print_map, |
| 140 | .nmagic = options.nmagic, | ||
| 141 | .fatal_warnings = options.fatal_warnings, | ||
| 138 | .emit_relocs = options.emit_relocs, | 142 | .emit_relocs = options.emit_relocs, |
| 139 | .z_nodelete = options.z_nodelete, | 143 | .z_nodelete = options.z_nodelete, |
| 140 | .z_notext = options.z_notext, | 144 | .z_notext = options.z_notext, |
| ... | @@ -947,6 +951,14 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -947,6 +951,14 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 947 | try argv.append("--print-map"); | 951 | try argv.append("--print-map"); |
| 948 | } | 952 | } |
| 949 | 953 | ||
| 954 | if (elf.nmagic) { | ||
| 955 | try argv.append("--nmagic"); | ||
| 956 | } | ||
| 957 | |||
| 958 | if (elf.fatal_warnings) { | ||
| 959 | try argv.append("--fatal-warnings"); | ||
| 960 | } | ||
| 961 | |||
| 950 | if (comp.link_eh_frame_hdr) { | 962 | if (comp.link_eh_frame_hdr) { |
| 951 | try argv.append("--eh-frame-hdr"); | 963 | try argv.append("--eh-frame-hdr"); |
| 952 | } | 964 | } |
src/main.zig+16-1| ... | @@ -991,6 +991,8 @@ fn buildOutputType( | ... | @@ -991,6 +991,8 @@ fn buildOutputType( |
| 991 | var linker_print_gc_sections: bool = false; | 991 | var linker_print_gc_sections: bool = false; |
| 992 | var linker_print_icf_sections: bool = false; | 992 | var linker_print_icf_sections: bool = false; |
| 993 | var linker_print_map: bool = false; | 993 | var linker_print_map: bool = false; |
| 994 | var linker_nmagic: bool = false; | ||
| 995 | var linker_fatal_warnings: bool = false; | ||
| 994 | var llvm_opt_bisect_limit: c_int = -1; | 996 | var llvm_opt_bisect_limit: c_int = -1; |
| 995 | var linker_z_nocopyreloc = false; | 997 | var linker_z_nocopyreloc = false; |
| 996 | var linker_z_nodelete = false; | 998 | var linker_z_nodelete = false; |
| ... | @@ -2676,6 +2678,15 @@ fn buildOutputType( | ... | @@ -2676,6 +2678,15 @@ fn buildOutputType( |
| 2676 | linker_print_icf_sections = true; | 2678 | linker_print_icf_sections = true; |
| 2677 | } else if (mem.eql(u8, arg, "--print-map")) { | 2679 | } else if (mem.eql(u8, arg, "--print-map")) { |
| 2678 | linker_print_map = true; | 2680 | linker_print_map = true; |
| 2681 | } else if (mem.eql(u8, arg, "-n") or mem.eql(u8, arg, "--nmagic")) { | ||
| 2682 | linker_nmagic = true; | ||
| 2683 | } else if (mem.eql(u8, arg, "--fatal-warnings")) { | ||
| 2684 | linker_fatal_warnings = true; | ||
| 2685 | } else if (mem.eql(u8, arg, "--no-fatal-warnings")) { | ||
| 2686 | linker_fatal_warnings = false; | ||
| 2687 | } else if (mem.eql(u8, arg, "-m")) { | ||
| 2688 | _ = linker_args_it.nextOrFatal(); | ||
| 2689 | warn("-m option is ignored; emulation is derived from target", .{}); | ||
| 2679 | } else if (mem.eql(u8, arg, "--sort-section")) { | 2690 | } else if (mem.eql(u8, arg, "--sort-section")) { |
| 2680 | const arg1 = linker_args_it.nextOrFatal(); | 2691 | const arg1 = linker_args_it.nextOrFatal(); |
| 2681 | linker_sort_section = stringToEnum(link.File.Lld.Elf.SortSection, arg1) orelse { | 2692 | linker_sort_section = stringToEnum(link.File.Lld.Elf.SortSection, arg1) orelse { |
| ... | @@ -2948,9 +2959,11 @@ fn buildOutputType( | ... | @@ -2948,9 +2959,11 @@ fn buildOutputType( |
| 2948 | hash_style = stringToEnum(link.File.Lld.Elf.HashStyle, next_arg) orelse { | 2959 | hash_style = stringToEnum(link.File.Lld.Elf.HashStyle, next_arg) orelse { |
| 2949 | fatal("expected [sysv|gnu|both] after --hash-style, found {q}", .{next_arg}); | 2960 | fatal("expected [sysv|gnu|both] after --hash-style, found {q}", .{next_arg}); |
| 2950 | }; | 2961 | }; |
| 2951 | } else if (mem.eql(u8, arg, "-wrap")) { | 2962 | } else if (mem.eql(u8, arg, "-wrap") or mem.eql(u8, arg, "--wrap")) { |
| 2952 | const next_arg = linker_args_it.nextOrFatal(); | 2963 | const next_arg = linker_args_it.nextOrFatal(); |
| 2953 | try symbol_wrap_set.put(arena, next_arg, {}); | 2964 | try symbol_wrap_set.put(arena, next_arg, {}); |
| 2965 | } else if (mem.cutPrefix(u8, arg, "--wrap=")) |symbol| { | ||
| 2966 | try symbol_wrap_set.put(arena, symbol, {}); | ||
| 2954 | } else if (mem.startsWith(u8, arg, "/subsystem:")) { | 2967 | } else if (mem.startsWith(u8, arg, "/subsystem:")) { |
| 2955 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); | 2968 | var split_it = mem.splitBackwardsScalar(u8, arg, ':'); |
| 2956 | subsystem = try parseSubsystem(split_it.first()); | 2969 | subsystem = try parseSubsystem(split_it.first()); |
| ... | @@ -3666,6 +3679,8 @@ fn buildOutputType( | ... | @@ -3666,6 +3679,8 @@ fn buildOutputType( |
| 3666 | .linker_print_gc_sections = linker_print_gc_sections, | 3679 | .linker_print_gc_sections = linker_print_gc_sections, |
| 3667 | .linker_print_icf_sections = linker_print_icf_sections, | 3680 | .linker_print_icf_sections = linker_print_icf_sections, |
| 3668 | .linker_print_map = linker_print_map, | 3681 | .linker_print_map = linker_print_map, |
| 3682 | .linker_nmagic = linker_nmagic, | ||
| 3683 | .linker_fatal_warnings = linker_fatal_warnings, | ||
| 3669 | .llvm_opt_bisect_limit = llvm_opt_bisect_limit, | 3684 | .llvm_opt_bisect_limit = llvm_opt_bisect_limit, |
| 3670 | .linker_global_base = linker_global_base, | 3685 | .linker_global_base = linker_global_base, |
| 3671 | .linker_export_symbol_names = linker_export_symbol_names.items, | 3686 | .linker_export_symbol_names = linker_export_symbol_names.items, |