authorgravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-06-21 21:56:00+08:00
committergravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-06-25 22:12:56+08:00
logf1e3b67b1fae868fed3f13a18642607c777fc087
treec7467b90991d4ae1ac6a94840f0e7f9ba0f978ff
parent75b232ab2b47220d3ca01e66cfbf64ccb06cf101
signaturebadge-check Signed by SSH key SHA256:IEYEjkZlkUTr5U9GiDAmZU/4eZus2t2RsxusyhQqwao

link.Elf2: write LoongArch e_flags

The base ABI modifier is determined by the target features of the root module. However, ideally, it should be determined by the superset of the feature sets of all linked modules. Setting ABI version to v1. Both the LLVM backend and the self-hosted backend in my branch supports only ABI v1 ("new world").

1 files changed, 18 insertions(+), 1 deletions(-)

src/link/Elf2.zig+18-1
......@@ -2958,7 +2958,24 @@ fn initHeaders(
29582958 ehdr.entry = 0;
29592959 ehdr.phoff = 0;
29602960 ehdr.shoff = 0;
2961 ehdr.flags = 0;
2961 ehdr.flags = switch (machine) {
2962 .X86_64 => 0,
2963 .LOONGARCH => e_flags: {
2964 const target_cpu = &elf.base.comp.getTarget().cpu;
2965 const e_flags: std.elf.loongarch.EFlags = .{
2966 .base_abi_modifier = if (target_cpu.has(.loongarch, .d))
2967 .d
2968 else if (target_cpu.has(.loongarch, .f))
2969 .f
2970 else
2971 .s,
2972 .abi_extension = .base,
2973 .abi_version = 1,
2974 };
2975 break :e_flags @bitCast(e_flags);
2976 },
2977 else => @panic(@tagName(machine)),
2978 };
29622979 ehdr.ehsize = @sizeOf(ElfN.Ehdr);
29632980 ehdr.phentsize = @sizeOf(ElfN.Phdr);
29642981 ehdr.phnum = @min(phnum, std.elf.PN_XNUM);