| ... | ... | @@ -229,6 +229,8 @@ comdat_groups_table: std.AutoHashMapUnmanaged(u32, ComdatGroupOwner.Index) = .{} |
| 229 | 229 | /// such as `resolver` and `comdat_groups_table`. |
| 230 | 230 | strings: StringTable = .{}, |
| 231 | 231 | |
| 232 | first_eflags: ?elf.Elf64_Word = null, |
| 233 | |
| 232 | 234 | /// When allocating, the ideal_capacity is calculated by |
| 233 | 235 | /// actual_capacity + (actual_capacity / ideal_factor) |
| 234 | 236 | const ideal_factor = 3; |
| ... | ... | @@ -553,7 +555,7 @@ pub fn lowerAnonDecl( |
| 553 | 555 | pt: Zcu.PerThread, |
| 554 | 556 | decl_val: InternPool.Index, |
| 555 | 557 | explicit_alignment: InternPool.Alignment, |
| 556 | | src_loc: Module.LazySrcLoc, |
| 558 | src_loc: Zcu.LazySrcLoc, |
| 557 | 559 | ) !codegen.Result { |
| 558 | 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 | 1160 | |
| 1159 | 1161 | for (positionals.items) |obj| { |
| 1160 | 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 | 1168 | else => |e| try self.reportParseError( |
| 1163 | 1169 | obj.path, |
| 1164 | 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 | 1273 | |
| 1268 | 1274 | for (positionals.items) |obj| { |
| 1269 | 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 | 1281 | else => |e| try self.reportParseError( |
| 1272 | 1282 | obj.path, |
| 1273 | 1283 | "unexpected error: parsing input file failed with error {s}", |
| ... | ... | @@ -1693,6 +1703,7 @@ pub const ParseError = error{ |
| 1693 | 1703 | MalformedObject, |
| 1694 | 1704 | MalformedArchive, |
| 1695 | 1705 | InvalidCpuArch, |
| 1706 | MismatchedEflags, |
| 1696 | 1707 | OutOfMemory, |
| 1697 | 1708 | Overflow, |
| 1698 | 1709 | InputOutput, |
| ... | ... | @@ -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 | 1928 | fn accessLibPath( |
| 1876 | 1929 | self: *Elf, |
| 1877 | 1930 | arena: Allocator, |
| ... | ... | @@ -3013,7 +3066,7 @@ pub fn lowerUnnamedConst(self: *Elf, pt: Zcu.PerThread, val: Value, decl_index: |
| 3013 | 3066 | pub fn updateExports( |
| 3014 | 3067 | self: *Elf, |
| 3015 | 3068 | pt: Zcu.PerThread, |
| 3016 | | exported: Module.Exported, |
| 3069 | exported: Zcu.Exported, |
| 3017 | 3070 | export_indices: []const u32, |
| 3018 | 3071 | ) link.File.UpdateExportsError!void { |
| 3019 | 3072 | if (build_options.skip_non_native and builtin.object_format != .elf) { |
| ... | ... | @@ -6471,8 +6524,6 @@ const LlvmObject = @import("../codegen/llvm.zig").Object; |
| 6471 | 6524 | const MergeSection = merge_section.MergeSection; |
| 6472 | 6525 | const MergeSubsection = merge_section.MergeSubsection; |
| 6473 | 6526 | const Zcu = @import("../Zcu.zig"); |
| 6474 | | /// Deprecated. |
| 6475 | | const Module = Zcu; |
| 6476 | 6527 | const Object = @import("Elf/Object.zig"); |
| 6477 | 6528 | const InternPool = @import("../InternPool.zig"); |
| 6478 | 6529 | const PltSection = synthetic_sections.PltSection; |
| ... | ... | @@ -6485,3 +6536,4 @@ const Value = @import("../Value.zig"); |
| 6485 | 6536 | const VerneedSection = synthetic_sections.VerneedSection; |
| 6486 | 6537 | const ZigGotSection = synthetic_sections.ZigGotSection; |
| 6487 | 6538 | const ZigObject = @import("Elf/ZigObject.zig"); |
| 6539 | const riscv = @import("riscv.zig"); |