public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/elf/, lib/portage/dep/soname/
@ 2019-05-18 19:15 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2019-05-18 19:15 UTC (permalink / raw
  To: gentoo-commits

commit:     40d51b2548dd74641aa6db619446a8d9473394a3
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri May 17 22:45:30 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 18 18:42:33 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=40d51b25

Recognize riscv ABIs (bug 686194)

In order to avoid possibe misidentification, only the following ABIs
are recognized:

 * lp64
 * lp64d

The compute_multilib_category function correctly identifies both
riscv_lp64 and riscv_lp64d files found in the experimental stages
from https://dev.gentoo.org/~dilfridge/stages/rv64gc-multilib/.

Bug: https://bugs.gentoo.org/686194
Reviewed-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/soname/multilib_category.py | 51 ++++++++++++++++++++++++++---
 lib/portage/util/elf/constants.py           | 10 +++++-
 2 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/lib/portage/dep/soname/multilib_category.py b/lib/portage/dep/soname/multilib_category.py
index 84e018fb0..37af98705 100644
--- a/lib/portage/dep/soname/multilib_category.py
+++ b/lib/portage/dep/soname/multilib_category.py
@@ -1,4 +1,4 @@
-# Copyright 2015 Gentoo Foundation
+# Copyright 2015-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # Compute a multilib category, as discussed here:
@@ -14,6 +14,7 @@
 #	m68k_{32,64}
 #	mips_{eabi32,eabi64,n32,n64,o32,o64}
 #	ppc_{32,64}
+#	riscv_{lp64,lp64d}
 #	s390_{32,64}
 #	sh_{32,64}
 #	sparc_{32,64}
@@ -34,10 +35,21 @@
 from __future__ import unicode_literals
 
 from portage.util.elf.constants import (
-	EF_MIPS_ABI, EF_MIPS_ABI2, ELFCLASS32, ELFCLASS64,
+	EF_MIPS_ABI,
+	EF_MIPS_ABI2,
+	EF_RISCV_FLOAT_ABI_DOUBLE,
+	EF_RISCV_RVC,
+	ELFCLASS32,
+	ELFCLASS64,
 	EM_386, EM_68K, EM_AARCH64, EM_ALPHA, EM_ARM, EM_ALTERA_NIOS2,
 	EM_IA_64, EM_MIPS,
-	EM_PARISC, EM_PPC, EM_PPC64, EM_S390, EM_SH, EM_SPARC,
+	EM_PARISC,
+	EM_PPC,
+	EM_PPC64,
+	EM_RISCV,
+	EM_S390,
+	EM_SH,
+	EM_SPARC,
 	EM_SPARC32PLUS, EM_SPARCV9, EM_X86_64, E_MIPS_ABI_EABI32,
 	E_MIPS_ABI_EABI64, E_MIPS_ABI_O32, E_MIPS_ABI_O64)
 
@@ -53,6 +65,7 @@ _machine_prefix_map = {
 	EM_PARISC:          "hppa",
 	EM_PPC:             "ppc",
 	EM_PPC64:           "ppc",
+	EM_RISCV:           "riscv",
 	EM_S390:            "s390",
 	EM_SH:              "sh",
 	EM_SPARC:           "sparc",
@@ -82,6 +95,33 @@ def _compute_suffix_mips(elf_header):
 
 	return name
 
+
+def _compute_suffix_riscv(elf_header):
+	"""
+	Compute riscv multilib suffix. In order to avoid possible
+	misidentification, only the following ABIs are recognized:
+
+		* lp64
+		* lp64d
+	"""
+
+	name = None
+
+	if elf_header.ei_class == ELFCLASS64:
+		if elf_header.e_flags == EF_RISCV_RVC:
+			name = "lp64"
+		elif elf_header.e_flags == EF_RISCV_RVC | EF_RISCV_FLOAT_ABI_DOUBLE:
+			name = "lp64d"
+
+	return name
+
+
+_specialized_funcs = {
+	"mips": _compute_suffix_mips,
+	"riscv": _compute_suffix_riscv,
+}
+
+
 def compute_multilib_category(elf_header):
 	"""
 	Compute a multilib category from an ELF header.
@@ -96,10 +136,11 @@ def compute_multilib_category(elf_header):
 	if elf_header.e_machine is not None:
 
 		prefix = _machine_prefix_map.get(elf_header.e_machine)
+		specialized_func = _specialized_funcs.get(prefix)
 		suffix = None
 
-		if prefix == "mips":
-			suffix = _compute_suffix_mips(elf_header)
+		if specialized_func is not None:
+			suffix = specialized_func(elf_header)
 		elif elf_header.ei_class == ELFCLASS64:
 			suffix = "64"
 		elif elf_header.ei_class == ELFCLASS32:

diff --git a/lib/portage/util/elf/constants.py b/lib/portage/util/elf/constants.py
index 2704e85c3..9ab0ba8ce 100644
--- a/lib/portage/util/elf/constants.py
+++ b/lib/portage/util/elf/constants.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2018 Gentoo Foundation
+# Copyright 2015-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # These constants are available from elfutils:
@@ -35,6 +35,7 @@ EM_IA_64           = 50
 EM_X86_64          = 62
 EM_ALTERA_NIOS2    = 113
 EM_AARCH64         = 183
+EM_RISCV           = 243
 EM_ALPHA           = 0x9026
 
 E_ENTRY            = 24
@@ -44,3 +45,10 @@ E_MIPS_ABI_O32     = 0x00001000
 E_MIPS_ABI_O64     = 0x00002000
 E_MIPS_ABI_EABI32  = 0x00003000
 E_MIPS_ABI_EABI64  = 0x00004000
+
+EF_RISCV_RVC              = 0x0001
+EF_RISCV_FLOAT_ABI        = 0x0006
+EF_RISCV_FLOAT_ABI_SOFT   = 0x0000
+EF_RISCV_FLOAT_ABI_SINGLE = 0x0002
+EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004
+EF_RISCV_FLOAT_ABI_QUAD   = 0x0006


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/util/elf/, lib/portage/dep/soname/
@ 2024-08-07 12:26 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2024-08-07 12:26 UTC (permalink / raw
  To: gentoo-commits

commit:     1ea8bb30da1ca9a47fd795d2fa1c829fda95bfec
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  7 11:56:17 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug  7 11:56:17 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1ea8bb30

ELF: add entries for BPF

Bug: https://bugs.gentoo.org/937485
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dep/soname/multilib_category.py | 4 +++-
 lib/portage/util/elf/constants.py           | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/portage/dep/soname/multilib_category.py b/lib/portage/dep/soname/multilib_category.py
index baca439fd2..e85191968d 100644
--- a/lib/portage/dep/soname/multilib_category.py
+++ b/lib/portage/dep/soname/multilib_category.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2019 Gentoo Authors
+# Copyright 2015-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # Compute a multilib category, as discussed here:
@@ -59,6 +59,7 @@ from portage.util.elf.constants import (
     EM_ARC_COMPACT3_64,
     EM_ARM,
     EM_ALTERA_NIOS2,
+    EM_BPF,
     EM_IA_64,
     EM_LOONGARCH,
     EM_MIPS,
@@ -91,6 +92,7 @@ _machine_prefix_map = {
     EM_ARC_COMPACT3: "arc",
     EM_ARC_COMPACT3_64: "arc",
     EM_ARM: "arm",
+    EM_BPF: "bpf",
     EM_IA_64: "ia64",
     EM_LOONGARCH: "loong",
     EM_MIPS: "mips",

diff --git a/lib/portage/util/elf/constants.py b/lib/portage/util/elf/constants.py
index 9216a35353..e389d1292a 100644
--- a/lib/portage/util/elf/constants.py
+++ b/lib/portage/util/elf/constants.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2019 Gentoo Authors
+# Copyright 2015-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # These constants are available from elfutils:
@@ -40,6 +40,7 @@ EM_AARCH64 = 183
 EM_ARC_COMPACT2 = 195
 EM_AMDGPU = 224
 EM_RISCV = 243
+EM_BPF = 247
 EM_ARC_COMPACT3_64 = 253
 EM_ARC_COMPACT3 = 255
 EM_LOONGARCH = 258


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-07 12:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 12:26 [gentoo-commits] proj/portage:master commit in: lib/portage/util/elf/, lib/portage/dep/soname/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2019-05-18 19:15 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox