authorgravatar for yangxudong@ymatrix.cnYANG Xudong <yangxudong@ymatrix.cn> 2024-07-20 07:32:20+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-07-19 16:32:20-07:00
logb7e48c6bcd99457f84f0043a3f4590a6ac1f4933
tree871de246636d7afbb67a78769fbcccecb8b59527
parent0d1db794d580eeeb39603613baf5123df15d731a
signaturebadge-check Signed by PGP key B5690EEEBB952194

std: Add loongarch support for elf. (#20678)


2 files changed, 13 insertions(+), 2 deletions(-)

lib/std/Target.zig+2-2
......@@ -1210,8 +1210,8 @@ pub const Cpu = struct {
12101210 .spirv => .NONE,
12111211 .spirv32 => .NONE,
12121212 .spirv64 => .NONE,
1213 .loongarch32 => .NONE,
1214 .loongarch64 => .NONE,
1213 .loongarch32 => .LOONGARCH,
1214 .loongarch64 => .LOONGARCH,
12151215 };
12161216 }
12171217
lib/std/elf.zig+11
......@@ -1626,6 +1626,9 @@ pub const EM = enum(u16) {
16261626 /// C-SKY
16271627 CSKY = 252,
16281628
1629 /// LoongArch
1630 LOONGARCH = 258,
1631
16291632 /// Fujitsu FR-V
16301633 FRV = 0x5441,
16311634
......@@ -1655,6 +1658,14 @@ pub const EM = enum(u16) {
16551658 .SPARCV9 => .sparc64,
16561659 .S390 => .s390x,
16571660 .SPU_2 => .spu_2,
1661 // FIXME:
1662 // No support for .loongarch32 yet so it is safe to assume we are on .loongarch64.
1663 //
1664 // However, when e_machine is .LOONGARCH, we should check
1665 // ei_class's value to decide the CPU architecture.
1666 // - ELFCLASS32 => .loongarch32
1667 // - ELFCLASS64 => .loongarch64
1668 .LOONGARCH => .loongarch64,
16581669 // there's many cases we don't (yet) handle, or will never have a
16591670 // zig target cpu arch equivalent (such as null).
16601671 else => null,