From 10e4efbb8845215e6eb5f499b2893b31007691ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Sun, 10 Mar 2024 20:53:52 +0100 Subject: [PATCH] dso: use uname -p to set arch name on *BSD --- Makefile | 8 ++++---- dso.c | 14 ++------------ support/freebsd.mk | 10 +++++----- support/netbsd.mk | 10 +++++----- support/openbsd.mk | 2 +- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 73b0b20d..30d37d28 100644 --- a/Makefile +++ b/Makefile @@ -48,11 +48,11 @@ export IAMROOT_LIB_AARCH64_MUSL_AARCH64_1 IAMROOT_LIB_RISCV64_MUSL_RISCV64_1 ?= $(IAMROOT_LIB) export IAMROOT_LIB_RISCV64_MUSL_RISCV64_1 -IAMROOT_LIB_AMD64_ELF_1 ?= $(IAMROOT_LIB) -export IAMROOT_LIB_AMD64_ELF_1 +IAMROOT_LIB_X86_64_ELF_1 ?= $(IAMROOT_LIB) +export IAMROOT_LIB_X86_64_ELF_1 -IAMROOT_LIB_ARM64_ELF_1 ?= $(IAMROOT_LIB) -export IAMROOT_LIB_ARM64_ELF_1 +IAMROOT_LIB_AARCH64_ELF_1 ?= $(IAMROOT_LIB) +export IAMROOT_LIB_AARCH64_ELF_1 IAMROOT_EXEC ?= $(CURDIR)/exec.sh export IAMROOT_EXEC diff --git a/dso.c b/dso.c index 03ad3f48..c12847a2 100644 --- a/dso.c +++ b/dso.c @@ -1859,23 +1859,13 @@ static const char *__machine(Elf64_Ehdr *ehdr, const char *ldso, int abi) /* Assuming it is a *BSD */ return __set_errno(errno_save, "i386"); } else if (__is_x86_64(ehdr, ldso, abi)) { - if (__is_gnu_linux(ehdr, ldso, abi) || - __is_musl(ehdr, ldso, abi)) - return __set_errno(errno_save, "x86_64"); - - /* Assuming it is a *BSD */ - return __set_errno(errno_save, "amd64"); + return __set_errno(errno_save, "x86_64"); } else if (__is_arm(ehdr, ldso, abi)) { return __set_errno(errno_save, "arm"); } else if (__is_armhf(ehdr, ldso, abi)) { return __set_errno(errno_save, "armhf"); } else if (__is_aarch64(ehdr, ldso, abi)) { - if (__is_gnu_linux(ehdr, ldso, abi) || - __is_musl(ehdr, ldso, abi)) - return __set_errno(errno_save, "aarch64"); - - /* Assuming it is a *BSD */ - return __set_errno(errno_save, "arm64"); + return __set_errno(errno_save, "aarch64"); } else if (__is_aarch64_be(ehdr, ldso, abi)) { return __set_errno(errno_save, "aarch64_be"); } else if (__is_riscv(ehdr, ldso, abi)) { diff --git a/support/freebsd.mk b/support/freebsd.mk index 07bfed4e..62a7934b 100644 --- a/support/freebsd.mk +++ b/support/freebsd.mk @@ -5,16 +5,16 @@ # O ?= output -ARCH ?= $(shell uname -m 2>/dev/null) +ARCH ?= $(shell uname -p 2>/dev/null) IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1 export IAMROOT_LIB -IAMROOT_LIB_AMD64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1 -export IAMROOT_LIB_AMD64_ELF_1 +IAMROOT_LIB_X86_64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1 +export IAMROOT_LIB_X86_64_ELF_1 -IAMROOT_LIB_ARM64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1 -export IAMROOT_LIB_ARM64_ELF_1 +IAMROOT_LIB_AARCH64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1 +export IAMROOT_LIB_AARCH64_ELF_1 IAMROOT_PATH_RESOLUTION_IGNORE ?= ^/dev/|^/etc/resolv.conf export IAMROOT_PATH_RESOLUTION_IGNORE diff --git a/support/netbsd.mk b/support/netbsd.mk index 76068444..4ee1b307 100644 --- a/support/netbsd.mk +++ b/support/netbsd.mk @@ -8,16 +8,16 @@ PREFIX ?= /usr/pkg export PREFIX O ?= output -ARCH ?= $(shell uname -m 2>/dev/null) +ARCH ?= $(shell uname -p 2>/dev/null) IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so export IAMROOT_LIB -IAMROOT_LIB_AMD64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so -export IAMROOT_LIB_AMD64_ELF +IAMROOT_LIB_X86_64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so +export IAMROOT_LIB_X86_64_ELF -IAMROOT_LIB_ARM64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so -export IAMROOT_LIB_ARM64_ELF +IAMROOT_LIB_AARCH64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so +export IAMROOT_LIB_AARCH64_ELF IAMROOT_PATH_RESOLUTION_IGNORE ?= ^/dev/|^/proc/ export IAMROOT_PATH_RESOLUTION_IGNORE diff --git a/support/openbsd.mk b/support/openbsd.mk index bda32f45..c9bd8c90 100644 --- a/support/openbsd.mk +++ b/support/openbsd.mk @@ -5,7 +5,7 @@ # O ?= output -ARCH ?= $(shell uname -m 2>/dev/null) +ARCH ?= $(shell uname -p 2>/dev/null) IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot.so export IAMROOT_LIB