@@ -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
}
@@ -1161,7 +1163,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod
1161
1163
1162
1164
for (positionals .items ) | obj | {
1163
1165
self .parsePositional (obj .path , obj .must_link ) catch | err | switch (err ) {
1164
- error .MalformedObject , error .MalformedArchive , error .InvalidCpuArch = > continue , // already reported
1166
+ error .MalformedObject ,
1167
+ error .MalformedArchive ,
1168
+ error .MismatchedEflags ,
1169
+ error .InvalidCpuArch ,
1170
+ = > continue , // already reported
1165
1171
else = > | e | try self .reportParseError (
1166
1172
obj .path ,
1167
1173
"unexpected error: parsing input file failed with error {s}" ,
@@ -1270,7 +1276,11 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod
1270
1276
1271
1277
for (positionals .items ) | obj | {
1272
1278
self .parsePositional (obj .path , obj .must_link ) catch | err | switch (err ) {
1273
- error .MalformedObject , error .MalformedArchive , error .InvalidCpuArch = > continue , // already reported
1279
+ error .MalformedObject ,
1280
+ error .MalformedArchive ,
1281
+ error .MismatchedEflags ,
1282
+ error .InvalidCpuArch ,
1283
+ = > continue , // already reported
1274
1284
else = > | e | try self .reportParseError (
1275
1285
obj .path ,
1276
1286
"unexpected error: parsing input file failed with error {s}" ,
@@ -1700,6 +1710,7 @@ pub const ParseError = error{
1700
1710
MalformedObject ,
1701
1711
MalformedArchive ,
1702
1712
InvalidCpuArch ,
1713
+ MismatchedEflags ,
1703
1714
OutOfMemory ,
1704
1715
Overflow ,
1705
1716
InputOutput ,
@@ -1879,6 +1890,48 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {
1879
1890
}
1880
1891
}
1881
1892
1893
+ pub fn validateEFlags (self : * Elf , file_index : File.Index , e_flags : elf.Elf64_Word ) ! void {
1894
+ const target = self .base .comp .root_mod .resolved_target .result ;
1895
+
1896
+ if (self .first_eflags == null ) {
1897
+ self .first_eflags = e_flags ;
1898
+ return ; // there isn't anything to conflict with yet
1899
+ }
1900
+ const self_eflags : * elf.Elf64_Word = & self .first_eflags .? ;
1901
+
1902
+ switch (target .cpu .arch ) {
1903
+ .riscv64 = > {
1904
+ if (e_flags != self_eflags .* ) {
1905
+ const riscv_eflags : riscv.RiscvEflags = @bitCast (e_flags );
1906
+ const self_riscv_eflags : * riscv.RiscvEflags = @ptrCast (self_eflags );
1907
+
1908
+ self_riscv_eflags .rvc = self_riscv_eflags .rvc or riscv_eflags .rvc ;
1909
+ self_riscv_eflags .tso = self_riscv_eflags .tso or riscv_eflags .tso ;
1910
+
1911
+ var is_error : bool = false ;
1912
+ if (self_riscv_eflags .fabi != riscv_eflags .fabi ) {
1913
+ is_error = true ;
1914
+ _ = try self .reportParseError2 (
1915
+ file_index ,
1916
+ "cannot link object files with different float-point ABIs" ,
1917
+ .{},
1918
+ );
1919
+ }
1920
+ if (self_riscv_eflags .rve != riscv_eflags .rve ) {
1921
+ is_error = true ;
1922
+ _ = try self .reportParseError2 (
1923
+ file_index ,
1924
+ "cannot link object files with different RVEs" ,
1925
+ .{},
1926
+ );
1927
+ }
1928
+ if (is_error ) return error .MismatchedEflags ;
1929
+ }
1930
+ },
1931
+ else = > {},
1932
+ }
1933
+ }
1934
+
1882
1935
fn accessLibPath (
1883
1936
self : * Elf ,
1884
1937
arena : Allocator ,
@@ -3025,7 +3078,7 @@ pub fn lowerUnnamedConst(self: *Elf, pt: Zcu.PerThread, val: Value, decl_index:
3025
3078
pub fn updateExports (
3026
3079
self : * Elf ,
3027
3080
pt : Zcu.PerThread ,
3028
- exported : Module .Exported ,
3081
+ exported : Zcu .Exported ,
3029
3082
export_indices : []const u32 ,
3030
3083
) link.File.UpdateExportsError ! void {
3031
3084
if (build_options .skip_non_native and builtin .object_format != .elf ) {
@@ -6432,8 +6485,6 @@ const LlvmObject = @import("../codegen/llvm.zig").Object;
6432
6485
const MergeSection = merge_section .MergeSection ;
6433
6486
const MergeSubsection = merge_section .MergeSubsection ;
6434
6487
const Zcu = @import ("../Zcu.zig" );
6435
- /// Deprecated.
6436
- const Module = Zcu ;
6437
6488
const Object = @import ("Elf/Object.zig" );
6438
6489
const InternPool = @import ("../InternPool.zig" );
6439
6490
const PltSection = synthetic_sections .PltSection ;
@@ -6446,3 +6497,4 @@ const Value = @import("../Value.zig");
6446
6497
const VerneedSection = synthetic_sections .VerneedSection ;
6447
6498
const ZigGotSection = synthetic_sections .ZigGotSection ;
6448
6499
const ZigObject = @import ("Elf/ZigObject.zig" );
6500
+ const riscv = @import ("riscv.zig" );
0 commit comments