View | Details | Raw Unified | Return to bug 1102
Collapse All | Expand All

(-)/usr/src/sys/i386/linux/linux_sysvec.c (+1 lines)
Lines 405-410 Link Here
405
Elf32_Interp_info linux_interp = {
405
Elf32_Interp_info linux_interp = {
406
					&elf_linux_sysvec,
406
					&elf_linux_sysvec,
407
					"/lib/ld-linux.so.1",
407
					"/lib/ld-linux.so.1",
408
					"linux",
408
					"/compat/linux"
409
					"/compat/linux"
409
				 };
410
				 };
410
411
(-)/usr/src/sys/kern/imgact_elf.c (-15 / +54 lines)
Lines 92-97 Link Here
92
static Elf32_Interp_info freebsd_interp = {
92
static Elf32_Interp_info freebsd_interp = {
93
						&elf_freebsd_sysvec,
93
						&elf_freebsd_sysvec,
94
						"/usr/libexec/ld-elf.so.1",
94
						"/usr/libexec/ld-elf.so.1",
95
						"freebsd",
95
						""
96
						""
96
					  };
97
					  };
97
static Elf32_Interp_info *interp_list[MAX_INTERP] = {
98
static Elf32_Interp_info *interp_list[MAX_INTERP] = {
Lines 475-480 Link Here
475
	u_long addr, entry = 0, proghdr = 0;
476
	u_long addr, entry = 0, proghdr = 0;
476
	int error, i, header_size = 0, interp_len = 0;
477
	int error, i, header_size = 0, interp_len = 0;
477
	char *interp = NULL;
478
	char *interp = NULL;
479
	char path[MAXPATHLEN];
480
	char *sp;
478
481
479
	/*
482
	/*
480
	 * Do we have a valid ELF header ?
483
	 * Do we have a valid ELF header ?
Lines 608-638 Link Here
608
611
609
	addr = 2*MAXDSIZ; /* May depend on OS type XXX */
612
	addr = 2*MAXDSIZ; /* May depend on OS type XXX */
610
613
611
	if (interp) {
614
	/*
612
		char path[MAXPATHLEN];
615
	 * See if the user wants to override the sysvec with the sysvec
616
	 * in the COMPAT_SYSVEC environment variable
617
	 */
618
	sp = imgp->stringbase;
619
620
	for (i = 0; i < imgp->argc; i++) {
621
		while (*sp++); /* Constructed by kernel, should be valid */
622
	}
623
624
	for (i = 0; i < imgp->envc; i++) {
625
		while (*sp++); /* Constructed by kernel, should be valid */
626
627
		if (bcmp (sp, "COMPAT_SYSVEC=", 13) == 0) {
628
			sp += 14; /* sp points to the osname */
629
			break;
630
		}
631
	}
632
633
	if (*sp == NULL)
634
		sp = NULL;
635
	else
636
		UPRINTF ("sysvec %s requested by user\n", sp);
637
638
	if (interp || sp) {
613
		/* 
639
		/* 
614
		 * So which kind of ELF binary do we have at hand
640
		 * So which kind of ELF binary do we have at hand
615
		 * FreeBSD, SVR4 or Linux ??
641
		 * FreeBSD, SVR4 or Linux ??
616
		 */
642
		 */
617
		for (i=0; i<MAX_INTERP; i++) {
643
		for (i=0; i<MAX_INTERP; i++) {
618
			if (interp_list[i] != NULL) {
644
			if (interp_list[i] == NULL)
619
				if (!strcmp(interp, interp_list[i]->path)) {
645
				continue;
620
					imgp->proc->p_sysent = 
646
621
						interp_list[i]->sysvec;
647
			/* User's sysvec always overrides the interp section */
622
					strcpy(path, interp_list[i]->emul_path);
648
			if (sp && (strcmp(sp, interp_list[i]->osname)))
623
					strcat(path, interp_list[i]->path);
649
				continue;
624
					UPRINTF("interpreter=<%s> %s\n",
650
625
						interp_list[i]->path,
651
			if (interp && (strcmp(interp, interp_list[i]->path)))
626
						interp_list[i]->emul_path);
652
				continue;
627
					break;
653
628
				}
654
			imgp->proc->p_sysent = interp_list[i]->sysvec;
629
			}
655
			strcpy(path, interp_list[i]->emul_path);
656
			strcat(path, interp_list[i]->path);
657
			UPRINTF("interpreter=<%s> %s\n", interp_list[i]->path,
658
				interp_list[i]->emul_path);
659
			break;
630
		}
660
		}
631
		if (i == MAX_INTERP) {
661
		if (i == MAX_INTERP) {
632
			uprintf("ELF interpreter %s not known\n", interp);
662
			if (sp == 0) {
663
				uprintf("ELF interpreter %s not known\n",
664
					interp);
665
			} else {
666
				uprintf("COMPAT_SYSVEC %s not known\n",
667
					sp);
668
			}
633
			error = ENOEXEC;
669
			error = ENOEXEC;
634
			goto fail;
670
			goto fail;
635
		}
671
		}
672
	}
673
674
	if (interp) {
636
		if (error = elf_load_file(imgp->proc,
675
		if (error = elf_load_file(imgp->proc,
637
					  path,
676
					  path,
638
				          &addr, 	/* XXX */
677
				          &addr, 	/* XXX */
(-)/usr/src/sys/sys/imgact_elf.h (+1 lines)
Lines 202-207 Link Here
202
typedef struct {
202
typedef struct {
203
        struct sysentvec *sysvec;
203
        struct sysentvec *sysvec;
204
	char *path;
204
	char *path;
205
	char *osname;		/* OS name for user specified override */
205
	char *emul_path;
206
	char *emul_path;
206
} Elf32_Interp_info;
207
} Elf32_Interp_info;

Return to bug 1102