From 37f9fc6b07d38fbb6986b91b9efaf485b34b99d4 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 14 Mar 2019 17:43:59 +0100
Subject: [PATCH] i386 removal, part 71/x: Remove legacy FreeBSD brand.

We had a compat layer in i386 that was intended to run old DragonFly
binaries from <1.2 times if my memory serves well. That also worked
with FreeBSD 4.x binaries. It was removed in part 7 and 8 of this
commit series.

This commit reverts cee191cabfed209fdad9972bd88be5b18e310361.

It also removes all references to ld-elf.so.1.

Reported-by: zrj
---
 Makefile_upgrade.inc              |  1 +
 libexec/rtld-elf/Makefile         |  3 +--
 libexec/rtld-elf/rtld.1           |  3 +--
 share/man/man5/libmap.conf.5      |  2 +-
 sys/cpu/x86_64/misc/elf_machdep.c | 16 ----------------
 sys/kern/imgact_elf.c             | 10 ----------
 sys/sys/imgact_elf.h              |  1 -
 7 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc
index 68720fec6f..7bcaf0ccdb 100644
--- a/Makefile_upgrade.inc
+++ b/Makefile_upgrade.inc
@@ -3500,6 +3500,7 @@ TO_REMOVE+=/usr/share/man/man8/mount_psshfs.8.gz
 TO_REMOVE+=/usr/share/man/man9/putter.9.gz
 TO_REMOVE+=/usr/include/sys/semaphore.h
 TO_REMOVE+=/usr/share/man/man2/brk.2.gz
+TO_REMOVE+=/usr/share/man/man1/ld-elf.so.1.1.gz
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index d13f95a2aa..2254e09e3f 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -29,8 +29,7 @@ INSTALLFLAGS=	-C -b
 .ifndef NOFSCHG
 INSTALLFLAGS+=	-fschg
 .endif
-MLINKS=		rtld.1 ld-elf.so.1.1
-MLINKS+=	rtld.1 ld-elf.so.2.1
+MLINKS=		rtld.1 ld-elf.so.2.1
 MLINKS+=	rtld.1 _rtld_functrace.3
 
 .if !defined(NO_SYMVER)
diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1
index 32f4d4cbde..401b529db7 100644
--- a/libexec/rtld-elf/rtld.1
+++ b/libexec/rtld-elf/rtld.1
@@ -32,9 +32,8 @@
 .Dt RTLD 1
 .Os
 .Sh NAME
-.Nm ld-elf.so.2 ,
-.Nm ld-elf.so.1 ,
 .Nm rtld ,
+.Nm ld-elf.so.2 ,
 .Nm _rtld_functrace
 .Nd run-time link-editor
 .Sh SYNOPSIS
diff --git a/share/man/man5/libmap.conf.5 b/share/man/man5/libmap.conf.5
index e6911ad5b0..93d6f9d2bd 100644
--- a/share/man/man5/libmap.conf.5
+++ b/share/man/man5/libmap.conf.5
@@ -35,7 +35,7 @@
 The
 .Nm libmap
 functionality of
-.Xr ld-elf.so.1 1
+.Xr ld-elf.so.2 1
 allows dynamic object dependencies to be mapped to arbitrary names.
 .Pp
 Each line in
diff --git a/sys/cpu/x86_64/misc/elf_machdep.c b/sys/cpu/x86_64/misc/elf_machdep.c
index eb659b18cc..ac1b250fa2 100644
--- a/sys/cpu/x86_64/misc/elf_machdep.c
+++ b/sys/cpu/x86_64/misc/elf_machdep.c
@@ -71,22 +71,6 @@ SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_FIRST,
         (sysinit_cfunc_t) elf64_insert_brand_entry,
         &dragonfly_brand_info);
 
-static Elf64_Brandinfo freebsd_brand_info = {
-        .brand		= ELFOSABI_FREEBSD,
-        .machine	= EM_X86_64,
-        .compat_3_brand	= "FreeBSD",
-        .emul_path	= NULL,
-        .interp_path	= "/usr/libexec/ld-elf.so.1",
-        .sysvec		= &elf64_dragonfly_sysvec,
-        .interp_newpath	= NULL,
-        .flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE,
-        .brand_note	= &elf64_freebsd_brandnote,
-};
-
-SYSINIT(elf64_fbsd, SI_SUB_EXEC, SI_ORDER_ANY,
-        (sysinit_cfunc_t) elf64_insert_brand_entry,
-        &freebsd_brand_info);
-
 /* Process one elf relocation with addend. */
 static int
 elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index e7534942ff..4be030463d 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -125,7 +125,6 @@ TUNABLE_INT("kern.elf32.pie_base_mmap", &elf_pie_base_mmap);
 static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
 
 static const char DRAGONFLY_ABI_VENDOR[] = "DragonFly";
-static const char FREEBSD_ABI_VENDOR[]   = "FreeBSD";
 
 Elf_Brandnote __elfN(dragonfly_brandnote) = {
 	.hdr.n_namesz	= sizeof(DRAGONFLY_ABI_VENDOR),
@@ -136,15 +135,6 @@ Elf_Brandnote __elfN(dragonfly_brandnote) = {
 	.trans_osrel	= __elfN(bsd_trans_osrel),
 };
 
-Elf_Brandnote __elfN(freebsd_brandnote) = {
-	.hdr.n_namesz	= sizeof(FREEBSD_ABI_VENDOR),
-	.hdr.n_descsz	= sizeof(int32_t),
-	.hdr.n_type	= 1,
-	.vendor		= FREEBSD_ABI_VENDOR,
-	.flags		= BN_TRANSLATE_OSREL,
-	.trans_osrel	= __elfN(bsd_trans_osrel),
-};
-
 int
 __elfN(insert_brand_entry)(Elf_Brandinfo *entry)
 {
diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h
index 0b65363a6b..abee19da26 100644
--- a/sys/sys/imgact_elf.h
+++ b/sys/sys/imgact_elf.h
@@ -95,7 +95,6 @@ int	__elfN(coredump)           (struct lwp *, int, struct vnode *, off_t);
 int     generic_elf_coredump       (struct lwp *lp, int sig, struct file *fp,
 				    off_t limit);
 extern Elf_Brandnote 	__elfN(dragonfly_brandnote);
-extern Elf_Brandnote	__elfN(freebsd_brandnote);
 
 #endif /* _KERNEL */
 
-- 
2.20.1

