diff --git a/lkm/linux/linux.c b/lkm/linux/linux.c index dc0d522cc54d..23787758efa7 100644 --- a/lkm/linux/linux.c +++ b/lkm/linux/linux.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux.c,v 1.6 1996/03/10 22:43:37 peter Exp $ + * $Id: linux.c,v 1.7 1996/09/03 22:52:07 bde Exp $ */ #include @@ -41,12 +41,12 @@ extern const struct execsw linux_execsw; MOD_EXEC(linux, -1, &linux_execsw); -extern Elf32_Interp_info linux_interp; +extern Elf32_Brandinfo linux_brand; static int linux_load(struct lkm_table *lkmtp, int cmd) { - if (elf_insert_interp(&linux_interp)) + if (elf_insert_brand_entry(&linux_brand)) uprintf("Could not install ELF interpreter entry\n"); uprintf("Linux emulator installed\n"); return 0; @@ -55,7 +55,7 @@ linux_load(struct lkm_table *lkmtp, int cmd) static int linux_unload(struct lkm_table *lkmtp, int cmd) { - if (elf_remove_interp(&linux_interp)) + if (elf_remove_brand_entry(&linux_brand)) uprintf("Could not deinstall ELF interpreter entry\n"); uprintf("Linux emulator removed\n"); return 0; diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c index aa9c2d68bae8..c70daf63d500 100644 --- a/sys/alpha/linux/linux_sysvec.c +++ b/sys/alpha/linux/linux_sysvec.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_sysvec.c,v 1.7 1996/06/18 05:15:53 dyson Exp $ + * $Id: linux_sysvec.c,v 1.8 1996/10/15 18:24:34 bde Exp $ */ /* XXX we use functions that might not exist. */ @@ -405,10 +405,11 @@ struct sysentvec elf_linux_sysvec = { /* * Installed either via SYSINIT() or via LKM stubs. */ -Elf32_Interp_info linux_interp = { - &elf_linux_sysvec, +Elf32_Brandinfo linux_brand = { + "Linux", + "/compat/linux", "/lib/ld-linux.so.1", - "/compat/linux" + &elf_linux_sysvec }; #ifndef LKM @@ -416,5 +417,5 @@ Elf32_Interp_info linux_interp = { * XXX: this is WRONG, it needs to be SI_SUB_EXEC, but this is just at the * "proof of concept" stage and will be fixed shortly */ -SYSINIT(linuxelf, SI_SUB_VFS, SI_ORDER_ANY, elf_insert_interp, &linux_interp); +SYSINIT(linuxelf, SI_SUB_VFS, SI_ORDER_ANY, elf_insert_brand_entry, &linux_brand); #endif diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index aa9c2d68bae8..c70daf63d500 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_sysvec.c,v 1.7 1996/06/18 05:15:53 dyson Exp $ + * $Id: linux_sysvec.c,v 1.8 1996/10/15 18:24:34 bde Exp $ */ /* XXX we use functions that might not exist. */ @@ -405,10 +405,11 @@ struct sysentvec elf_linux_sysvec = { /* * Installed either via SYSINIT() or via LKM stubs. */ -Elf32_Interp_info linux_interp = { - &elf_linux_sysvec, +Elf32_Brandinfo linux_brand = { + "Linux", + "/compat/linux", "/lib/ld-linux.so.1", - "/compat/linux" + &elf_linux_sysvec }; #ifndef LKM @@ -416,5 +417,5 @@ Elf32_Interp_info linux_interp = { * XXX: this is WRONG, it needs to be SI_SUB_EXEC, but this is just at the * "proof of concept" stage and will be fixed shortly */ -SYSINIT(linuxelf, SI_SUB_VFS, SI_ORDER_ANY, elf_insert_interp, &linux_interp); +SYSINIT(linuxelf, SI_SUB_VFS, SI_ORDER_ANY, elf_insert_brand_entry, &linux_brand); #endif diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index b646bb14a0ff..5815dd1b81a4 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: imgact_elf.c,v 1.8 1996/08/31 16:52:23 bde Exp $ + * $Id: imgact_elf.c,v 1.9 1996/10/03 06:14:48 peter Exp $ */ #include @@ -93,45 +93,46 @@ static struct sysentvec elf_freebsd_sysvec = { "FreeBSD ELF" }; -static Elf32_Interp_info freebsd_interp = { - &elf_freebsd_sysvec, +static Elf32_Brandinfo freebsd_brand_info = { + "FreeBSD", + "", "/usr/libexec/ld-elf.so.1", - "" + &elf_freebsd_sysvec }; -static Elf32_Interp_info *interp_list[MAX_INTERP] = { - &freebsd_interp, +static Elf32_Brandinfo *elf_brand_list[MAX_BRANDS] = { + &freebsd_brand_info, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; int -elf_insert_interp(Elf32_Interp_info *entry) +elf_insert_brand_entry(Elf32_Brandinfo *entry) { int i; - for (i=1; ipath)) { - imgp->proc->p_sysent = - interp_list[i]->sysvec; - strcpy(path, interp_list[i]->emul_path); - strcat(path, interp_list[i]->path); - UPRINTF("interpreter=<%s> %s\n", - interp_list[i]->path, - interp_list[i]->emul_path); - break; + imgp->entry_addr = entry; + + /* + * So which kind (brand) of ELF binary do we have at hand + * FreeBSD, Linux, SVR4 or something else ?? + * If its has a interpreter section try that first + */ + if (interp) { + for (i=0; iinterp_path)) { + imgp->proc->p_sysent = + elf_brand_list[i]->sysvec; + strcpy(path, elf_brand_list[i]->emul_path); + strcat(path, elf_brand_list[i]->interp_path); + UPRINTF("interpreter=<%s> %s\n", + elf_brand_list[i]->interp_path, + elf_brand_list[i]->emul_path); + break; + } + } + } + } + + /* + * If there is no interpreter, or recognition of it + * failed, se if the binary is branded. + */ + if (!interp || i == MAX_BRANDS) { + brand = (char *)&(hdr->e_ident[EI_BRAND]); + for (i=0; ibrand)) { + imgp->proc->p_sysent = elf_brand_list[i]->sysvec; + if (interp) { + strcpy(path, elf_brand_list[i]->emul_path); + strcat(path, elf_brand_list[i]->interp_path); + UPRINTF("interpreter=<%s> %s\n", + elf_brand_list[i]->interp_path, + elf_brand_list[i]->emul_path); + } } } } - if (i == MAX_INTERP) { - uprintf("ELF interpreter %s not known\n", interp); - error = ENOEXEC; - goto fail; - } - if (error = elf_load_file(imgp->proc, - path, - &addr, /* XXX */ - &imgp->entry_addr)) { - uprintf("ELF interpreter %s not found\n", path); - goto fail; - } } - else - imgp->entry_addr = entry; + if (i == MAX_BRANDS) { + uprintf("ELF binary type not known\n"); + error = ENOEXEC; + goto fail; + } + if (interp) { + if (error = elf_load_file(imgp->proc, + path, + &addr, /* XXX */ + &imgp->entry_addr)) { + uprintf("ELF interpreter %s not found\n", path); + goto fail; + } + } + + uprintf("Executing %s binary\n", elf_brand_list[i]->brand); /* * Construct auxargs table (used by the fixup routine) diff --git a/sys/modules/linux/linux.c b/sys/modules/linux/linux.c index dc0d522cc54d..23787758efa7 100644 --- a/sys/modules/linux/linux.c +++ b/sys/modules/linux/linux.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux.c,v 1.6 1996/03/10 22:43:37 peter Exp $ + * $Id: linux.c,v 1.7 1996/09/03 22:52:07 bde Exp $ */ #include @@ -41,12 +41,12 @@ extern const struct execsw linux_execsw; MOD_EXEC(linux, -1, &linux_execsw); -extern Elf32_Interp_info linux_interp; +extern Elf32_Brandinfo linux_brand; static int linux_load(struct lkm_table *lkmtp, int cmd) { - if (elf_insert_interp(&linux_interp)) + if (elf_insert_brand_entry(&linux_brand)) uprintf("Could not install ELF interpreter entry\n"); uprintf("Linux emulator installed\n"); return 0; @@ -55,7 +55,7 @@ linux_load(struct lkm_table *lkmtp, int cmd) static int linux_unload(struct lkm_table *lkmtp, int cmd) { - if (elf_remove_interp(&linux_interp)) + if (elf_remove_brand_entry(&linux_brand)) uprintf("Could not deinstall ELF interpreter entry\n"); uprintf("Linux emulator removed\n"); return 0; diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index d24a725237b7..cc0b7e22acae 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: imgact_elf.h,v 1.1 1996/03/10 08:42:52 sos Exp $ */ #ifndef _IMGACT_ELF_H_ @@ -67,6 +67,8 @@ typedef struct { #define EI_CLASS 4 #define EI_DATA 5 #define EI_VERSION 6 +#define EI_SPARE 8 +#define EI_BRAND 8 #define ELFMAG0 '\177' @@ -200,14 +202,15 @@ typedef struct { } Elf32_Auxargs; typedef struct { - struct sysentvec *sysvec; - char *path; + char *brand; char *emul_path; -} Elf32_Interp_info; + char *interp_path; + struct sysentvec *sysvec; +} Elf32_Brandinfo; -#define MAX_INTERP 8 +#define MAX_BRANDS 8 -int elf_insert_interp __P((Elf32_Interp_info *entry)); -int elf_remove_interp __P((Elf32_Interp_info *entry)); +int elf_insert_brand_entry __P((Elf32_Brandinfo *entry)); +int elf_remove_brand_entry __P((Elf32_Brandinfo *entry)); #endif /* _IMGACT_ELF_H_ */