| ... | @@ -229,6 +229,8 @@ comdat_groups_table: std.AutoHashMapUnmanaged(u32, ComdatGroupOwner.Index) = .{} | ... | @@ -229,6 +229,8 @@ comdat_groups_table: std.AutoHashMapUnmanaged(u32, ComdatGroupOwner.Index) = .{} |
| 229 | /// such as `resolver` and `comdat_groups_table`. | 229 | /// such as `resolver` and `comdat_groups_table`. |
| 230 | strings: StringTable = .{}, | 230 | strings: StringTable = .{}, |
| 231 | | 231 | |
| | 232 | first_eflags: ?elf.Elf64_Word = null, |
| | 233 | |
| 232 | /// When allocating, the ideal_capacity is calculated by | 234 | /// When allocating, the ideal_capacity is calculated by |
| 233 | /// actual_capacity + (actual_capacity / ideal_factor) | 235 | /// actual_capacity + (actual_capacity / ideal_factor) |
| 234 | const ideal_factor = 3; | 236 | const ideal_factor = 3; |
| ... | @@ -553,7 +555,7 @@ pub fn lowerAnonDecl( | ... | @@ -553,7 +555,7 @@ pub fn lowerAnonDecl( |
| 553 | pt: Zcu.PerThread, | 555 | pt: Zcu.PerThread, |
| 554 | decl_val: InternPool.Index, | 556 | decl_val: InternPool.Index, |
| 555 | explicit_alignment: InternPool.Alignment, | 557 | explicit_alignment: InternPool.Alignment, |
| 556 | src_loc: Module.LazySrcLoc, | 558 | src_loc: Zcu.LazySrcLoc, |
| 557 | ) !codegen.Result { | 559 | ) !codegen.Result { |
| 558 | return self.zigObjectPtr().?.lowerAnonDecl(self, pt, decl_val, explicit_alignment, src_loc); | 560 | return self.zigObjectPtr().?.lowerAnonDecl(self, pt, decl_val, explicit_alignment, src_loc); |
| 559 | } | 561 | } |
| ... | @@ -1158,7 +1160,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod | ... | @@ -1158,7 +1160,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 1158 | | 1160 | |
| 1159 | for (positionals.items) |obj| { | 1161 | for (positionals.items) |obj| { |
| 1160 | self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) { | 1162 | self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) { |
| 1161 | error.MalformedObject, error.MalformedArchive, error.InvalidCpuArch => continue, // already reported | 1163 | error.MalformedObject, |
| | 1164 | error.MalformedArchive, |
| | 1165 | error.MismatchedEflags, |
| | 1166 | error.InvalidCpuArch, |
| | 1167 | => continue, // already reported |
| 1162 | else => |e| try self.reportParseError( | 1168 | else => |e| try self.reportParseError( |
| 1163 | obj.path, | 1169 | obj.path, |
| 1164 | "unexpected error: parsing input file failed with error {s}", | 1170 | "unexpected error: parsing input file failed with error {s}", |
| ... | @@ -1267,7 +1273,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod | ... | @@ -1267,7 +1273,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 1267 | | 1273 | |
| 1268 | for (positionals.items) |obj| { | 1274 | for (positionals.items) |obj| { |
| 1269 | self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) { | 1275 | self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) { |
| 1270 | error.MalformedObject, error.MalformedArchive, error.InvalidCpuArch => continue, // already reported | 1276 | error.MalformedObject, |
| | 1277 | error.MalformedArchive, |
| | 1278 | error.MismatchedEflags, |
| | 1279 | error.InvalidCpuArch, |
| | 1280 | => continue, // already reported |
| 1271 | else => |e| try self.reportParseError( | 1281 | else => |e| try self.reportParseError( |
| 1272 | obj.path, | 1282 | obj.path, |
| 1273 | "unexpected error: parsing input file failed with error {s}", | 1283 | "unexpected error: parsing input file failed with error {s}", |
| ... | @@ -1693,6 +1703,7 @@ pub const ParseError = error{ | ... | @@ -1693,6 +1703,7 @@ pub const ParseError = error{ |
| 1693 | MalformedObject, | 1703 | MalformedObject, |
| 1694 | MalformedArchive, | 1704 | MalformedArchive, |
| 1695 | InvalidCpuArch, | 1705 | InvalidCpuArch, |
| | 1706 | MismatchedEflags, |
| 1696 | OutOfMemory, | 1707 | OutOfMemory, |
| 1697 | Overflow, | 1708 | Overflow, |
| 1698 | InputOutput, | 1709 | InputOutput, |
| ... | @@ -1872,6 +1883,48 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void { | ... | @@ -1872,6 +1883,48 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void { |
| 1872 | } | 1883 | } |
| 1873 | } | 1884 | } |
| 1874 | | 1885 | |
| | 1886 | pub fn validateEFlags(self: *Elf, file_index: File.Index, e_flags: elf.Elf64_Word) !void { |
| | 1887 | const target = self.base.comp.root_mod.resolved_target.result; |
| | 1888 | |
| | 1889 | if (self.first_eflags == null) { |
| | 1890 | self.first_eflags = e_flags; |
| | 1891 | return; // there isn't anything to conflict with yet |
| | 1892 | } |
| | 1893 | const self_eflags: *elf.Elf64_Word = &self.first_eflags.?; |
| | 1894 | |
| | 1895 | switch (target.cpu.arch) { |
| | 1896 | .riscv64 => { |
| | 1897 | if (e_flags != self_eflags.*) { |
| | 1898 | const riscv_eflags: riscv.RiscvEflags = @bitCast(e_flags); |
| | 1899 | const self_riscv_eflags: *riscv.RiscvEflags = @ptrCast(self_eflags); |
| | 1900 | |
| | 1901 | self_riscv_eflags.rvc = self_riscv_eflags.rvc or riscv_eflags.rvc; |
| | 1902 | self_riscv_eflags.tso = self_riscv_eflags.tso or riscv_eflags.tso; |
| | 1903 | |
| | 1904 | var is_error: bool = false; |
| | 1905 | if (self_riscv_eflags.fabi != riscv_eflags.fabi) { |
| | 1906 | is_error = true; |
| | 1907 | _ = try self.reportParseError2( |
| | 1908 | file_index, |
| | 1909 | "cannot link object files with different float-point ABIs", |
| | 1910 | .{}, |
| | 1911 | ); |
| | 1912 | } |
| | 1913 | if (self_riscv_eflags.rve != riscv_eflags.rve) { |
| | 1914 | is_error = true; |
| | 1915 | _ = try self.reportParseError2( |
| | 1916 | file_index, |
| | 1917 | "cannot link object files with different RVEs", |
| | 1918 | .{}, |
| | 1919 | ); |
| | 1920 | } |
| | 1921 | if (is_error) return error.MismatchedEflags; |
| | 1922 | } |
| | 1923 | }, |
| | 1924 | else => {}, |
| | 1925 | } |
| | 1926 | } |
| | 1927 | |
| 1875 | fn accessLibPath( | 1928 | fn accessLibPath( |
| 1876 | self: *Elf, | 1929 | self: *Elf, |
| 1877 | arena: Allocator, | 1930 | arena: Allocator, |
| ... | @@ -3013,7 +3066,7 @@ pub fn lowerUnnamedConst(self: *Elf, pt: Zcu.PerThread, val: Value, decl_index: | ... | @@ -3013,7 +3066,7 @@ pub fn lowerUnnamedConst(self: *Elf, pt: Zcu.PerThread, val: Value, decl_index: |
| 3013 | pub fn updateExports( | 3066 | pub fn updateExports( |
| 3014 | self: *Elf, | 3067 | self: *Elf, |
| 3015 | pt: Zcu.PerThread, | 3068 | pt: Zcu.PerThread, |
| 3016 | exported: Module.Exported, | 3069 | exported: Zcu.Exported, |
| 3017 | export_indices: []const u32, | 3070 | export_indices: []const u32, |
| 3018 | ) link.File.UpdateExportsError!void { | 3071 | ) link.File.UpdateExportsError!void { |
| 3019 | if (build_options.skip_non_native and builtin.object_format != .elf) { | 3072 | if (build_options.skip_non_native and builtin.object_format != .elf) { |
| ... | @@ -6471,8 +6524,6 @@ const LlvmObject = @import("../codegen/llvm.zig").Object; | ... | @@ -6471,8 +6524,6 @@ const LlvmObject = @import("../codegen/llvm.zig").Object; |
| 6471 | const MergeSection = merge_section.MergeSection; | 6524 | const MergeSection = merge_section.MergeSection; |
| 6472 | const MergeSubsection = merge_section.MergeSubsection; | 6525 | const MergeSubsection = merge_section.MergeSubsection; |
| 6473 | const Zcu = @import("../Zcu.zig"); | 6526 | const Zcu = @import("../Zcu.zig"); |
| 6474 | /// Deprecated. | | |
| 6475 | const Module = Zcu; | | |
| 6476 | const Object = @import("Elf/Object.zig"); | 6527 | const Object = @import("Elf/Object.zig"); |
| 6477 | const InternPool = @import("../InternPool.zig"); | 6528 | const InternPool = @import("../InternPool.zig"); |
| 6478 | const PltSection = synthetic_sections.PltSection; | 6529 | const PltSection = synthetic_sections.PltSection; |
| ... | @@ -6485,3 +6536,4 @@ const Value = @import("../Value.zig"); | ... | @@ -6485,3 +6536,4 @@ const Value = @import("../Value.zig"); |
| 6485 | const VerneedSection = synthetic_sections.VerneedSection; | 6536 | const VerneedSection = synthetic_sections.VerneedSection; |
| 6486 | const ZigGotSection = synthetic_sections.ZigGotSection; | 6537 | const ZigGotSection = synthetic_sections.ZigGotSection; |
| 6487 | const ZigObject = @import("Elf/ZigObject.zig"); | 6538 | const ZigObject = @import("Elf/ZigObject.zig"); |
| | 6539 | const riscv = @import("riscv.zig"); |