MFS: bring the consistent `compat_3_brand' support into -CURRENT

(the work was first done in the RELENG_4 branch near a release
	 during a MFC to make the code cleaner and more consistent)
This commit is contained in:
obrien 2001-02-24 22:20:11 +00:00
parent de4709b849
commit 16ff3c2b54
4 changed files with 19 additions and 10 deletions

View File

@ -184,6 +184,7 @@ struct sysentvec svr4_sysvec = {
Elf32_Brandinfo svr4_brand = {
ELFOSABI_SOLARIS, /* XXX Or should we use ELFOSABI_SYSV here? */
"SVR4",
svr4_emul_path,
"/lib/libc.so.1",
&svr4_sysvec

View File

@ -780,6 +780,7 @@ struct sysentvec elf_linux_sysvec = {
static Elf32_Brandinfo linux_brand = {
ELFOSABI_LINUX,
"Linux",
"/compat/linux",
"/lib/ld-linux.so.1",
&elf_linux_sysvec
@ -787,6 +788,7 @@ static Elf32_Brandinfo linux_brand = {
static Elf32_Brandinfo linux_glibc2brand = {
ELFOSABI_LINUX,
"Linux",
"/compat/linux",
"/lib/ld-linux.so.2",
&elf_linux_sysvec

View File

@ -1,4 +1,5 @@
/*-
* Copyright (c) 2000 David O'Brien
* Copyright (c) 1995-1996 Søren Schmidt
* Copyright (c) 1996 Peter Wemm
* All rights reserved.
@ -106,6 +107,7 @@ struct sysentvec elf_freebsd_sysvec = {
static Elf_Brandinfo freebsd_brand_info = {
ELFOSABI_FREEBSD,
"FreeBSD",
"",
"/usr/libexec/ld-elf.so.1",
&elf_freebsd_sysvec
@ -562,21 +564,23 @@ exec_elf_imgact(struct image_params *imgp)
brand_info = NULL;
/* XXX For now we look for the magic "FreeBSD" that we used to put
* into the ELF header at the EI_ABIVERSION location. If found use
* that information rather than figuring out the ABI from proper
* branding. This should be removed for 5.0-RELEASE. The Linux caes
* can be figured out from the `interp_path' field.
/* We support three types of branding -- (1) the ELF EI_OSABI field
* that SCO added to the ELF spec, (2) FreeBSD 3.x's traditional string
* branding w/in the ELF header, and (3) path of the `interp_path'
* field. We should also look for an ".note.ABI-tag" ELF section now
* in all Linux ELF binaries, FreeBSD 4.1+, and some NetBSD ones.
*/
if (strcmp("FreeBSD", (const char *)&hdr->e_ident[OLD_EI_BRAND]) == 0)
brand_info = &freebsd_brand_info;
/* If the executable has a brand, search for it in the brand list. */
if (brand_info == NULL) {
for (i = 0; i < MAX_BRANDS; i++) {
Elf_Brandinfo *bi = elf_brand_list[i];
if (bi != NULL && hdr->e_ident[EI_OSABI] == bi->brand) {
if (bi != NULL &&
(hdr->e_ident[EI_OSABI] == bi->brand
|| 0 ==
strncmp((const char *)&hdr->e_ident[OLD_EI_BRAND],
bi->compat_3_brand, strlen(bi->compat_3_brand)))) {
brand_info = bi;
break;
}

View File

@ -57,6 +57,7 @@ typedef struct {
typedef struct {
int brand;
const char *compat_3_brand; /* pre Binutils 2.10 method (FBSD 3) */
const char *emul_path;
const char *interp_path;
struct sysentvec *sysvec;
@ -88,8 +89,9 @@ typedef struct {
typedef struct {
int brand;
char *emul_path;
char *interp_path;
const char *compat_3_brand; /* pre Binutils 2.10 method (FBSD 3) */
const char *emul_path;
const char *interp_path;
struct sysentvec *sysvec;
} Elf64_Brandinfo;