From 998b79089fba1b775a2a89f2c6d325d97dd21ead Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 23 Dec 2003 02:42:39 +0000 Subject: Add an additional field to the elf brandinfo structure to support quicker exec-time replacement of the elf interpreter on an emulation environment where an entire /compat/* tree isn't really warranted. --- sys/kern/imgact_elf.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 330437a..ff11078 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -708,6 +708,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) goto fail; } sv = brand_info->sysvec; + if (interp != NULL && brand_info->interp_newpath != NULL) + interp = brand_info->interp_newpath; if ((error = exec_extract_strings(imgp)) != 0) goto fail; @@ -818,21 +820,24 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) imgp->entry_addr = entry; imgp->proc->p_sysent = sv; - if (interp != NULL) { + if (interp != NULL && brand_info->emul_path != NULL && + brand_info->emul_path[0] != '\0') { path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); snprintf(path, MAXPATHLEN, "%s%s", brand_info->emul_path, interp); - if ((error = __elfN(load_file)(imgp->proc, path, &addr, - &imgp->entry_addr, sv->sv_pagesize)) != 0) { - if ((error = __elfN(load_file)(imgp->proc, interp, - &addr, &imgp->entry_addr, sv->sv_pagesize)) != 0) { - uprintf("ELF interpreter %s not found\n", - path); - free(path, M_TEMP); - goto fail; - } - } + error = __elfN(load_file)(imgp->proc, path, &addr, + &imgp->entry_addr, sv->sv_pagesize); free(path, M_TEMP); + if (error == 0) + interp = NULL; + } + if (interp != NULL) { + error = __elfN(load_file)(imgp->proc, interp, &addr, + &imgp->entry_addr, sv->sv_pagesize); + if (error != 0) { + uprintf("ELF interpreter %s not found\n", interp); + goto fail; + } } /* -- cgit v1.1