Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 2023 16:59:21 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 248fe3d3483c - main - libprocstat: improve conditional for 32-bit compat
Message-ID:  <202310161659.39GGxLAY028960@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=248fe3d3483cb3ec2c78dd31dc02a467060a6577

commit 248fe3d3483cb3ec2c78dd31dc02a467060a6577
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-10-16 16:53:29 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-10-16 16:58:49 +0000

    libprocstat: improve conditional for 32-bit compat
    
    Include support for translating 32-bit auxv vectors on non-64-bit
    platforms that aren't riscv (which has no 32-bit ABI support and
    probably never will).
    
    Reviewed by:    markj
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D42201
---
 lib/libprocstat/libprocstat.c | 6 +++---
 lib/libprocstat/libprocstat.h | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index 031294387ca7..c6a225a021a7 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -2381,7 +2381,7 @@ procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp, int *osrelp)
 
 #define PROC_AUXV_MAX	256
 
-#if __ELF_WORD_SIZE == 64
+#ifdef PS_ARCH_HAS_FREEBSD32
 static const char *elf32_sv_names[] = {
 	"Linux ELF32",
 	"FreeBSD ELF32",
@@ -2464,7 +2464,7 @@ out:
 	free(auxv32);
 	return (auxv);
 }
-#endif /* __ELF_WORD_SIZE == 64 */
+#endif /* PS_ARCH_HAS_FREEBSD32 */
 
 static Elf_Auxinfo *
 procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
@@ -2473,7 +2473,7 @@ procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
 	int name[4];
 	size_t len;
 
-#if __ELF_WORD_SIZE == 64
+#ifdef PS_ARCH_HAS_FREEBSD32
 	if (is_elf32_sysctl(pid))
 		return (procstat_getauxv32_sysctl(pid, cntp));
 #endif
diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h
index 0df01817663e..3d30b4db4018 100644
--- a/lib/libprocstat/libprocstat.h
+++ b/lib/libprocstat/libprocstat.h
@@ -102,6 +102,11 @@
 #define	PS_FST_FFLAG_EXEC	0x2000
 #define	PS_FST_FFLAG_HASLOCK	0x4000
 
+#if !defined(__ILP32__) && !defined(__riscv)
+/* Target architecture supports 32-bit compat */
+#define	PS_ARCH_HAS_FREEBSD32	1
+#endif
+
 struct kinfo_kstack;
 struct kinfo_proc;
 struct kinfo_vmentry;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310161659.39GGxLAY028960>