Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Nov 2019 19:00:21 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354744 - head/sys/mips/mips
Message-ID:  <201911151900.xAFJ0Lrw001431@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Nov 15 19:00:20 2019
New Revision: 354744
URL: https://svnweb.freebsd.org/changeset/base/354744

Log:
  Combine ELF sysvecs for MIPS to reduce code duplication.
  
  Reviewed by:	brooks, kevans
  Tested on:	mips, mips64
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D22357

Modified:
  head/sys/mips/mips/elf_machdep.c

Modified: head/sys/mips/mips/elf_machdep.c
==============================================================================
--- head/sys/mips/mips/elf_machdep.c	Fri Nov 15 18:57:00 2019	(r354743)
+++ head/sys/mips/mips/elf_machdep.c	Fri Nov 15 19:00:20 2019	(r354744)
@@ -51,8 +51,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/md_var.h>
 #include <machine/cache.h>
 
-#ifdef __mips_n64
-struct sysentvec elf64_freebsd_sysvec = {
+static struct sysentvec elf_freebsd_sysvec = {
 	.sv_size	= SYS_MAXSYSCALL,
 	.sv_table	= sysent,
 	.sv_errsize	= 0,
@@ -62,62 +61,11 @@ struct sysentvec elf64_freebsd_sysvec = {
 	.sv_sendsig	= sendsig,
 	.sv_sigcode	= sigcode,
 	.sv_szsigcode	= &szsigcode,
+#ifdef __mips_n64
 	.sv_name	= "FreeBSD ELF64",
-	.sv_coredump	= __elfN(coredump),
-	.sv_imgact_try	= NULL,
-	.sv_minsigstksz	= MINSIGSTKSZ,
-	.sv_minuser	= VM_MIN_ADDRESS,
-	.sv_maxuser	= VM_MAXUSER_ADDRESS,
-	.sv_usrstack	= USRSTACK,
-	.sv_psstrings	= PS_STRINGS,
-	.sv_stackprot	= VM_PROT_ALL,
-	.sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs),
-	.sv_copyout_strings = exec_copyout_strings,
-	.sv_setregs	= exec_setregs,
-	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_FREEBSD | SV_LP64 | SV_ASLR,
-	.sv_set_syscall_retval = cpu_set_syscall_retval,
-	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
-	.sv_syscallnames = syscallnames,
-	.sv_schedtail	= NULL,
-	.sv_thread_detach = NULL,
-	.sv_trap	= NULL,
-};
-
-static Elf64_Brandinfo freebsd_brand_info = {
-	.brand		= ELFOSABI_FREEBSD,
-	.machine	= EM_MIPS,
-	.compat_3_brand	= "FreeBSD",
-	.emul_path	= NULL,
-	.interp_path	= "/libexec/ld-elf.so.1",
-	.sysvec		= &elf64_freebsd_sysvec,
-	.interp_newpath	= NULL,
-	.brand_note	= &elf64_freebsd_brandnote,
-	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
-};
-
-SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
-    (sysinit_cfunc_t) elf64_insert_brand_entry,
-    &freebsd_brand_info);
-
-void
-elf64_dump_thread(struct thread *td __unused, void *dst __unused,
-    size_t *off __unused)
-{
-}
 #else
-struct sysentvec elf32_freebsd_sysvec = {
-	.sv_size	= SYS_MAXSYSCALL,
-	.sv_table	= sysent,
-	.sv_errsize	= 0,
-	.sv_errtbl	= NULL,
-	.sv_transtrap	= NULL,
-	.sv_fixup	= __elfN(freebsd_fixup),
-	.sv_sendsig	= sendsig,
-	.sv_sigcode	= sigcode,
-	.sv_szsigcode	= &szsigcode,
 	.sv_name	= "FreeBSD ELF32",
+#endif
 	.sv_coredump	= __elfN(coredump),
 	.sv_imgact_try	= NULL,
 	.sv_minsigstksz	= MINSIGSTKSZ,
@@ -131,7 +79,11 @@ struct sysentvec elf32_freebsd_sysvec = {
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
+#ifdef __mips_n64
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64 | SV_ASLR,
+#else
 	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32 | SV_ASLR,
+#endif
 	.sv_set_syscall_retval = cpu_set_syscall_retval,
 	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
 	.sv_syscallnames = syscallnames,
@@ -140,28 +92,27 @@ struct sysentvec elf32_freebsd_sysvec = {
 	.sv_trap	= NULL,
 };
 
-static Elf32_Brandinfo freebsd_brand_info = {
+static __ElfN(Brandinfo) freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_MIPS,
 	.compat_3_brand	= "FreeBSD",
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
-	.sysvec		= &elf32_freebsd_sysvec,
+	.sysvec		= &elf_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.brand_note	= &elf32_freebsd_brandnote,
+	.brand_note	= &__elfN(freebsd_brandnote),
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
-SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
-    (sysinit_cfunc_t) elf32_insert_brand_entry,
+SYSINIT(elf, SI_SUB_EXEC, SI_ORDER_ANY,
+    (sysinit_cfunc_t) __elfN(insert_brand_entry),
     &freebsd_brand_info);
 
 void
-elf32_dump_thread(struct thread *td __unused, void *dst __unused,
+__elfN(dump_thread)(struct thread *td __unused, void *dst __unused,
     size_t *off __unused)
 {
 }
-#endif
 
 /*
  * The following MIPS relocation code for tracking multiple



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