* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/soname/, lib/portage/util/elf/
@ 2021-12-14 3:37 Sam James
0 siblings, 0 replies; only message in thread
From: Sam James @ 2021-12-14 3:37 UTC (permalink / raw
To: gentoo-commits
commit: f6cdba7689ea423245a232cc13103dd988363845
Author: WANG Xuerui <git <AT> xen0n <DOT> name>
AuthorDate: Mon Aug 9 07:31:25 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 14 03:37:13 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f6cdba76
multilib_category.py: recognize LoongArch ABIs
Add its ELF machine number constant as well. The Gentoo ARCH is "loong";
all six ABIs defined in the LoongArch ELF psABI spec [1] are supported.
The upstream binutils port currently implements an earlier version of the
spec [2]; the ILP32 ABIs are never fully implemented so far, and the
value for LP64D is coincidentally the same, so the code here stays
compatible.
This is preparatory work towards a port to the LoongArch architecture,
which is the new RISC architecture from Loongson Corporation after
switching away from MIPS.
[1]: https://github.com/loongson/LoongArch-Documentation/blob/23d53fe146a4/docs/LoongArch-ELF-ABI-EN.adoc
[2]: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=include/elf/loongarch.h;h=b4d801ae9bd5a6c4562ca6b1cbae6e6d45d6c704;hb=HEAD
Signed-off-by: WANG Xuerui <git <AT> xen0n.name>
Closes: https://github.com/gentoo/portage/pull/740
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/dep/soname/multilib_category.py | 26 ++++++++++++++++++++++++++
lib/portage/util/elf/constants.py | 9 +++++++++
2 files changed, 35 insertions(+)
diff --git a/lib/portage/dep/soname/multilib_category.py b/lib/portage/dep/soname/multilib_category.py
index ab855d339..567b1d32e 100644
--- a/lib/portage/dep/soname/multilib_category.py
+++ b/lib/portage/dep/soname/multilib_category.py
@@ -11,6 +11,7 @@
# arm_{32,64}
# hppa_{32,64}
# ia_{32,64}
+# loong_{ilp32s,ilp32f,ilp32d,lp64s,lp64f,lp64d}
# m68k_{32,64}
# mips_{eabi32,eabi64,n32,n64,o32,o64}
# ppc_{32,64}
@@ -37,6 +38,13 @@ from portage.util.elf.constants import (
EF_MIPS_ABI2,
EF_RISCV_FLOAT_ABI_DOUBLE,
EF_RISCV_RVC,
+ EF_LOONGARCH_ABI_LP64_SOFT_FLOAT,
+ EF_LOONGARCH_ABI_LP64_SINGLE_FLOAT,
+ EF_LOONGARCH_ABI_LP64_DOUBLE_FLOAT,
+ EF_LOONGARCH_ABI_ILP32_SOFT_FLOAT,
+ EF_LOONGARCH_ABI_ILP32_SINGLE_FLOAT,
+ EF_LOONGARCH_ABI_ILP32_DOUBLE_FLOAT,
+ EF_LOONGARCH_ABI_MASK,
ELFCLASS32,
ELFCLASS64,
EM_386,
@@ -46,6 +54,7 @@ from portage.util.elf.constants import (
EM_ARM,
EM_ALTERA_NIOS2,
EM_IA_64,
+ EM_LOONGARCH,
EM_MIPS,
EM_PARISC,
EM_PPC,
@@ -71,6 +80,7 @@ _machine_prefix_map = {
EM_ALTERA_NIOS2: "nios2",
EM_ARM: "arm",
EM_IA_64: "ia64",
+ EM_LOONGARCH: "loong",
EM_MIPS: "mips",
EM_PARISC: "hppa",
EM_PPC: "ppc",
@@ -84,6 +94,15 @@ _machine_prefix_map = {
EM_X86_64: "x86",
}
+_loong_abi_map = {
+ EF_LOONGARCH_ABI_LP64_SOFT_FLOAT: "lp64s",
+ EF_LOONGARCH_ABI_LP64_SINGLE_FLOAT: "lp64f",
+ EF_LOONGARCH_ABI_LP64_DOUBLE_FLOAT: "lp64d",
+ EF_LOONGARCH_ABI_ILP32_SOFT_FLOAT: "ilp32s",
+ EF_LOONGARCH_ABI_ILP32_SINGLE_FLOAT: "ilp32f",
+ EF_LOONGARCH_ABI_ILP32_DOUBLE_FLOAT: "ilp32d",
+}
+
_mips_abi_map = {
E_MIPS_ABI_EABI32: "eabi32",
E_MIPS_ABI_EABI64: "eabi64",
@@ -92,6 +111,12 @@ _mips_abi_map = {
}
+def _compute_suffix_loong(elf_header):
+
+ loong_abi = elf_header.e_flags & EF_LOONGARCH_ABI_MASK
+ return _loong_abi_map.get(loong_abi)
+
+
def _compute_suffix_mips(elf_header):
name = None
@@ -136,6 +161,7 @@ def _compute_suffix_riscv(elf_header):
_specialized_funcs = {
+ "loong": _compute_suffix_loong,
"mips": _compute_suffix_mips,
"riscv": _compute_suffix_riscv,
}
diff --git a/lib/portage/util/elf/constants.py b/lib/portage/util/elf/constants.py
index d86b39483..19b72cfa1 100644
--- a/lib/portage/util/elf/constants.py
+++ b/lib/portage/util/elf/constants.py
@@ -36,6 +36,7 @@ EM_X86_64 = 62
EM_ALTERA_NIOS2 = 113
EM_AARCH64 = 183
EM_RISCV = 243
+EM_LOONGARCH = 258
EM_ALPHA = 0x9026
E_ENTRY = 24
@@ -52,3 +53,11 @@ EF_RISCV_FLOAT_ABI_SOFT = 0x0000
EF_RISCV_FLOAT_ABI_SINGLE = 0x0002
EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004
EF_RISCV_FLOAT_ABI_QUAD = 0x0006
+
+EF_LOONGARCH_ABI_LP64_SOFT_FLOAT = 0b001
+EF_LOONGARCH_ABI_LP64_SINGLE_FLOAT = 0b010
+EF_LOONGARCH_ABI_LP64_DOUBLE_FLOAT = 0b011
+EF_LOONGARCH_ABI_ILP32_SOFT_FLOAT = 0b101
+EF_LOONGARCH_ABI_ILP32_SINGLE_FLOAT = 0b110
+EF_LOONGARCH_ABI_ILP32_DOUBLE_FLOAT = 0b111
+EF_LOONGARCH_ABI_MASK = 0x07
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-14 3:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-14 3:37 [gentoo-commits] proj/portage:master commit in: lib/portage/dep/soname/, lib/portage/util/elf/ Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox