Mercurial > illumos > git > illumos-omnios
changeset 18388:3bf807361b9b
backout OS-4141: needs more work
backout OS-4128: needs more work
author | Joshua M. Clulow <jmc@joyent.com> |
---|---|
date | Thu, 02 Apr 2015 00:31:33 +0000 |
parents | 2d100a5d81e4 |
children | 84c602712586 |
files | usr/src/uts/common/exec/elf/elf.c |
diffstat | 1 files changed, 7 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/exec/elf/elf.c Tue Mar 31 20:40:46 2015 +0000 +++ b/usr/src/uts/common/exec/elf/elf.c Thu Apr 02 00:31:33 2015 +0000 @@ -216,8 +216,6 @@ &junk, &dtrphdr, NULL, bssbase, brkbase, voffset, &minaddr, len, &execsz, brksize)) { uprintf("%s: Cannot map %s\n", exec_file, args->pathname); - if (uphdr != NULL && uphdr->p_flags == 0) - kmem_free(uphdr, sizeof (Phdr)); kmem_free(phdrbase, phdrsize); return (error); } @@ -272,9 +270,6 @@ if (uphdr != NULL) { *uphdr_vaddr = uphdr->p_vaddr; - - if (uphdr->p_flags == 0) - kmem_free(uphdr, sizeof (Phdr)); } else { *uphdr_vaddr = (Addr)-1; } @@ -745,13 +740,8 @@ /* * Now obtain the ELF header along with the entire program - * header contained in "nvp". Before we free our program - * headers, we need to be sure to let go of the uphdr if it - * wasn't dynamically allocated. + * header contained in "nvp". */ - if (uphdr != NULL && uphdr->p_flags != 0) - uphdr = NULL; - kmem_free(phdrbase, phdrsize); phdrbase = NULL; if ((error = getelfhead(nvp, CRED(), ehdrp, &nshdrs, @@ -777,10 +767,9 @@ dtrphdr = NULL; - error = mapelfexec(nvp, ehdrp, nphdrs, phdrbase, NULL, &junk, + error = mapelfexec(nvp, ehdrp, nphdrs, phdrbase, &junk, &junk, &junk, &dtrphdr, NULL, NULL, NULL, &voffset, NULL, len, execsz, NULL); - if (error || junk != NULL) { VN_RELE(nvp); uprintf("%s: Cannot map %s\n", exec_file, dlnp); @@ -987,8 +976,6 @@ if (error == 0) error = ENOEXEC; out: - if (uphdr != NULL && uphdr->p_flags == 0) - kmem_free(uphdr, sizeof (Phdr)); if (phdrbase != NULL) kmem_free(phdrbase, phdrsize); if (cap != NULL) @@ -1319,6 +1306,9 @@ for (i = nphdrs; i > 0; i--) { switch (phdr->p_type) { case PT_LOAD: + if ((*dyphdr != NULL) && (*uphdr == NULL)) + return (0); + ptload = 1; prot = PROT_USER; if (phdr->p_flags & PF_R) @@ -1330,34 +1320,6 @@ addr = (caddr_t)((uintptr_t)phdr->p_vaddr + *voffset); - if ((*dyphdr != NULL) && uphdr != NULL && - (*uphdr == NULL)) { - /* - * The PT_PHDR program header is, strictly - * speaking, optional. If we find that this - * is missing, we will determine the location - * of the program headers based on the address - * of the lowest PT_LOAD segment (namely, this - * one): we subtract the p_offset to get to - * the ELF header and then add back the program - * header offset to get to the program headers. - * We then cons up a Phdr that corresponds to - * the (missing) PT_PHDR, setting the flags - * to 0 to denote that this is artificial and - * should (must) be freed by the caller. - */ - Phdr *cons; - - cons = kmem_zalloc(sizeof (Phdr), KM_SLEEP); - - cons->p_flags = 0; - cons->p_type = PT_PHDR; - cons->p_vaddr = ((uintptr_t)addr - - phdr->p_offset) + ehdr->e_phoff; - - *uphdr = cons; - } - /* * Keep track of the segment with the lowest starting * address. @@ -1474,12 +1436,9 @@ break; case PT_PHDR: - if (ptload || phdr->p_flags == 0) + if (ptload) goto bad; - - if (uphdr != NULL) - *uphdr = phdr; - + *uphdr = phdr; break; case PT_NULL: