Use architecture name in ELF interpreter path.

diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/amd64/amd64/elf_machdep.c freebsd-10.4/sys/amd64/amd64/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/amd64/amd64/elf_machdep.c	2017-09-29 08:20:05.000000000 +0800
+++ freebsd-10.4/sys/amd64/amd64/elf_machdep.c	2024-08-05 03:38:44.100172000 +0800
@@ -87,6 +87,22 @@
 };
 INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
 
+static Elf64_Brandinfo freebsd_amd64_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_X86_64,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-amd64.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_FIRST,
+	(sysinit_cfunc_t) elf64_insert_brand_entry,
+	&freebsd_amd64_brand_info);
+
 static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_X86_64,
@@ -94,7 +110,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-amd64.so.1",
 	.brand_note	= &elf64_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/arm/arm/elf_machdep.c freebsd-10.4/sys/arm/arm/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/arm/arm/elf_machdep.c	2017-09-29 08:20:04.000000000 +0800
+++ freebsd-10.4/sys/arm/arm/elf_machdep.c	2024-08-05 03:43:06.405136000 +0800
@@ -83,6 +83,38 @@
 	.sv_trap	= NULL,
 };
 
+static Elf32_Brandinfo freebsd_armhf_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_ARM,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-armhf.so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_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,
+	&freebsd_armhf_brand_info);
+
+static Elf32_Brandinfo freebsd_arm_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_ARM,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-arm.so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_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,
+	&freebsd_arm_brand_info);
+
 static Elf32_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_ARM,
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/compat/ia32/ia32_sysvec.c freebsd-10.4/sys/compat/ia32/ia32_sysvec.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/compat/ia32/ia32_sysvec.c	2017-09-29 08:19:56.000000000 +0800
+++ freebsd-10.4/sys/compat/ia32/ia32_sysvec.c	2024-08-05 03:40:52.783719000 +0800
@@ -144,6 +144,22 @@
 };
 INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
 
+static Elf32_Brandinfo freebsd_ia32_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_386,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-i386.so.1",
+	.sysvec		= &ia32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
+SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_MIDDLE,
+	(sysinit_cfunc_t) elf32_insert_brand_entry,
+	&freebsd_ia32_brand_info);
+
 static Elf32_Brandinfo ia32_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_386,
@@ -151,7 +167,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &ia32_freebsd_sysvec,
-	.interp_newpath	= "/libexec/ld-elf32.so.1",
+	.interp_newpath	= "/libexec/ld-elf-i386.so.1",
 	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
@@ -167,7 +183,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &ia32_freebsd_sysvec,
-	.interp_newpath	= "/libexec/ld-elf32.so.1",
+	.interp_newpath	= "/libexec/ld-elf-i386.so.1",
 	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/i386/i386/elf_machdep.c freebsd-10.4/sys/i386/i386/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/i386/i386/elf_machdep.c	2017-09-29 08:20:02.000000000 +0800
+++ freebsd-10.4/sys/i386/i386/elf_machdep.c	2024-08-05 03:44:24.129762000 +0800
@@ -93,6 +93,22 @@
 };
 INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
 
+static Elf32_Brandinfo freebsd_i386_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_386,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-i386.so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_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,
+	&freebsd_i386_brand_info);
+
 static Elf32_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_386,
@@ -100,7 +116,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-i386.so.1",
 	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/ia64/ia64/elf_machdep.c freebsd-10.4/sys/ia64/ia64/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/ia64/ia64/elf_machdep.c	2017-09-29 08:20:09.000000000 +0800
+++ freebsd-10.4/sys/ia64/ia64/elf_machdep.c	2024-08-05 03:58:04.443302000 +0800
@@ -88,6 +88,20 @@
 	.sv_schedtail	= NULL,
 };
 
+static Elf64_Brandinfo freebsd_ia64_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_IA_64,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-ia64.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_FIRST,
+    (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_ia64_brand_info);
+
 static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_IA_64,
@@ -95,7 +109,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-ia64.so.1",
 	.brand_note	= &elf64_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/mips/mips/elf_machdep.c freebsd-10.4/sys/mips/mips/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/mips/mips/elf_machdep.c	2017-09-29 08:20:03.000000000 +0800
+++ freebsd-10.4/sys/mips/mips/elf_machdep.c	2024-08-05 03:59:44.715833000 +0800
@@ -87,6 +87,22 @@
 	.sv_trap	= NULL,
 };
 
+static Elf64_Brandinfo freebsd_mips64_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_MIPS,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-" MACHINE_ARCH ".so.1",
+	.sysvec		= &elf64_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.flags		= 0
+};
+
+SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
+    (sysinit_cfunc_t) elf64_insert_brand_entry,
+    &freebsd_mips64_brand_info);
+
+void
 static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_MIPS,
@@ -94,7 +110,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-" MACHINE_ARCH ".so.1",
 	.flags		= 0
 };
 
@@ -145,6 +161,22 @@
 	.sv_trap	= NULL,
 };
 
+static Elf32_Brandinfo freebsd_mips_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_MIPS,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-" MACHINE_ARCH ".so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.flags		= 0
+};
+
+SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
+    (sysinit_cfunc_t) elf32_insert_brand_entry,
+    &freebsd_mips_brand_info);
+
+void
 static Elf32_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_MIPS,
@@ -152,7 +184,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-" MACHINE_ARCH ".so.1",
 	.flags		= 0
 };
 
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/mips/mips/freebsd32_machdep.c freebsd-10.4/sys/mips/mips/freebsd32_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/mips/mips/freebsd32_machdep.c	2017-09-29 08:20:03.000000000 +0800
+++ freebsd-10.4/sys/mips/mips/freebsd32_machdep.c	2024-08-05 04:00:07.652889000 +0800
@@ -111,6 +111,22 @@
 };
 INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
 
+static Elf32_Brandinfo freebsd_mips_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_MIPS,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-" MACHINE_ARCH32 ".so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.flags		= 0
+};
+
+SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
+    (sysinit_cfunc_t) elf32_insert_brand_entry,
+    &freebsd_brand_info);
+
+static void
 static Elf32_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_MIPS,
@@ -118,7 +134,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
-	.interp_newpath	= "/libexec/ld-elf32.so.1",
+	.interp_newpath	= "/libexec/ld-elf-" MACHINE_ARCH32 ".so.1",
 	.flags		= 0
 };
 
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/powerpc/powerpc/elf32_machdep.c freebsd-10.4/sys/powerpc/powerpc/elf32_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/powerpc/powerpc/elf32_machdep.c	2017-09-29 08:20:07.000000000 +0800
+++ freebsd-10.4/sys/powerpc/powerpc/elf32_machdep.c	2024-08-05 04:10:04.627737000 +0800
@@ -112,6 +112,22 @@
 };
 INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
 
+static Elf32_Brandinfo freebsd_powerpc_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_PPC,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-powerpc.so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_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,
+    &freebsd_powerpc_brand_info);
+
 static Elf32_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_PPC,
@@ -119,11 +135,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
-#ifdef __powerpc64__
-	.interp_newpath	= "/libexec/ld-elf32.so.1",
-#else
-	.interp_newpath	= NULL,
-#endif
+	.interp_newpath	= "/libexec/ld-elf-powerpc.so.1",
 	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
@@ -139,7 +151,11 @@
 	.emul_path	= NULL,
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
+#ifdef __powerpc64__
+	.interp_newpath	= "/libexec/ld-elf-powerpc.so.1",
+#else
 	.interp_newpath	= NULL,
+#endif
 	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/powerpc/powerpc/elf64_machdep.c freebsd-10.4/sys/powerpc/powerpc/elf64_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/powerpc/powerpc/elf64_machdep.c	2017-09-29 08:20:07.000000000 +0800
+++ freebsd-10.4/sys/powerpc/powerpc/elf64_machdep.c	2024-08-05 04:04:04.398339000 +0800
@@ -88,6 +88,22 @@
 };
 INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
 
+static Elf64_Brandinfo freebsd_powerpc64_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_PPC64,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-powerpc64.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_powerpc64_brand_info);
+
 static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_PPC64,
@@ -95,7 +111,7 @@
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
-	.interp_newpath	= NULL,
+	.interp_newpath	= "/libexec/ld-elf-powerpc64.so.1",
 	.brand_note	= &elf64_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/sparc64/sparc64/elf_machdep.c freebsd-10.4/sys/sparc64/sparc64/elf_machdep.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/sparc64/sparc64/elf_machdep.c	2017-09-29 08:20:08.000000000 +0800
+++ freebsd-10.4/sys/sparc64/sparc64/elf_machdep.c	2024-08-05 04:05:01.048651000 +0800
@@ -91,6 +91,21 @@
 	.sv_trap	= NULL,
 };
 
+static Elf64_Brandinfo freebsd_sparc64_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_SPARCV9,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/libexec/ld-elf-sparc64.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_FIRST,
+    (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_sparc64_brand_info);
+
 static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
 	.machine	= EM_SPARCV9,
