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 {...@@ -1210,8 +1210,8 @@ pub const Cpu = struct {
1210 .spirv => .NONE,1210 .spirv => .NONE,
1211 .spirv32 => .NONE,1211 .spirv32 => .NONE,
1212 .spirv64 => .NONE,1212 .spirv64 => .NONE,
1213 .loongarch32 => .NONE,1213 .loongarch32 => .LOONGARCH,
1214 .loongarch64 => .NONE,1214 .loongarch64 => .LOONGARCH,
1215 };1215 };
1216 }1216 }
12171217
lib/std/elf.zig+11
...@@ -1626,6 +1626,9 @@ pub const EM = enum(u16) {...@@ -1626,6 +1626,9 @@ pub const EM = enum(u16) {
1626 /// C-SKY1626 /// C-SKY
1627 CSKY = 252,1627 CSKY = 252,
16281628
1629 /// LoongArch
1630 LOONGARCH = 258,
1631
1629 /// Fujitsu FR-V1632 /// Fujitsu FR-V
1630 FRV = 0x5441,1633 FRV = 0x5441,
16311634
...@@ -1655,6 +1658,14 @@ pub const EM = enum(u16) {...@@ -1655,6 +1658,14 @@ pub const EM = enum(u16) {
1655 .SPARCV9 => .sparc64,1658 .SPARCV9 => .sparc64,
1656 .S390 => .s390x,1659 .S390 => .s390x,
1657 .SPU_2 => .spu_2,1660 .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,
1658 // there's many cases we don't (yet) handle, or will never have a1669 // there's many cases we don't (yet) handle, or will never have a
1659 // zig target cpu arch equivalent (such as null).1670 // zig target cpu arch equivalent (such as null).
1660 else => null,1671 else => null,