The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/powerpc/powerpc/elf_common.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 2019 Justin Hibbits
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer
   11  *    in this position and unchanged.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. The name of the author may not be used to endorse or promote products
   16  *    derived from this software without specific prior written permission
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  *
   29  * $FreeBSD$
   30  */
   31 
   32 static int
   33 __elfN(powerpc_copyout_auxargs)(struct image_params *imgp, uintptr_t base)
   34 {
   35         Elf_Auxargs *args;
   36         Elf_Auxinfo *argarray, *pos;
   37         int error;
   38 
   39         /*
   40          * XXX If we can't find image's OSREL, assume it uses the new auxv
   41          * format.
   42          *
   43          * This is specially important for rtld, that is not tagged. Using
   44          * direct exec mode with new (ELFv2) binaries that expect the new auxv
   45          * format would result in crashes otherwise.
   46          *
   47          * Unfortunately, this may break direct exec'ing old binaries,
   48          * but it seems better to correctly support new binaries by default,
   49          * considering the transition to ELFv2 happened quite some time
   50          * ago. If needed, a sysctl may be added to allow old auxv format to
   51          * be used when OSREL is not found.
   52          */
   53         if (imgp->proc->p_osrel >= P_OSREL_POWERPC_NEW_AUX_ARGS ||
   54             imgp->proc->p_osrel == 0)
   55                 return (__elfN(freebsd_copyout_auxargs)(imgp, base));
   56 
   57         args = (Elf_Auxargs *)imgp->auxargs;
   58         argarray = pos = malloc(AT_OLD_COUNT * sizeof(*pos), M_TEMP,
   59             M_WAITOK | M_ZERO);
   60 
   61         if (args->execfd != -1)
   62                 AUXARGS_ENTRY(pos, AT_OLD_EXECFD, args->execfd);
   63         AUXARGS_ENTRY(pos, AT_OLD_PHDR, args->phdr);
   64         AUXARGS_ENTRY(pos, AT_OLD_PHENT, args->phent);
   65         AUXARGS_ENTRY(pos, AT_OLD_PHNUM, args->phnum);
   66         AUXARGS_ENTRY(pos, AT_OLD_PAGESZ, args->pagesz);
   67         AUXARGS_ENTRY(pos, AT_OLD_FLAGS, args->flags);
   68         AUXARGS_ENTRY(pos, AT_OLD_ENTRY, args->entry);
   69         AUXARGS_ENTRY(pos, AT_OLD_BASE, args->base);
   70         AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags);
   71         if (imgp->execpathp != 0)
   72                 AUXARGS_ENTRY_PTR(pos, AT_OLD_EXECPATH, imgp->execpathp);
   73         AUXARGS_ENTRY(pos, AT_OLD_OSRELDATE,
   74             imgp->proc->p_ucred->cr_prison->pr_osreldate);
   75         if (imgp->canary != 0) {
   76                 AUXARGS_ENTRY_PTR(pos, AT_OLD_CANARY, imgp->canary);
   77                 AUXARGS_ENTRY(pos, AT_OLD_CANARYLEN, imgp->canarylen);
   78         }
   79         AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus);
   80         if (imgp->pagesizes != 0) {
   81                 AUXARGS_ENTRY_PTR(pos, AT_OLD_PAGESIZES, imgp->pagesizes);
   82                 AUXARGS_ENTRY(pos, AT_OLD_PAGESIZESLEN, imgp->pagesizeslen);
   83         }
   84         if (imgp->sysent->sv_timekeep_base != 0) {
   85                 AUXARGS_ENTRY(pos, AT_OLD_TIMEKEEP,
   86                     imgp->sysent->sv_timekeep_base);
   87         }
   88         AUXARGS_ENTRY(pos, AT_OLD_STACKPROT, imgp->sysent->sv_shared_page_obj
   89             != NULL && imgp->stack_prot != 0 ? imgp->stack_prot :
   90             imgp->sysent->sv_stackprot);
   91         if (imgp->sysent->sv_hwcap != NULL)
   92                 AUXARGS_ENTRY(pos, AT_OLD_HWCAP, *imgp->sysent->sv_hwcap);
   93         if (imgp->sysent->sv_hwcap2 != NULL)
   94                 AUXARGS_ENTRY(pos, AT_OLD_HWCAP2, *imgp->sysent->sv_hwcap2);
   95         AUXARGS_ENTRY(pos, AT_OLD_NULL, 0);
   96 
   97         free(imgp->auxargs, M_TEMP);
   98         imgp->auxargs = NULL;
   99         KASSERT(pos - argarray <= AT_OLD_COUNT, ("Too many auxargs"));
  100 
  101         error = copyout(argarray, (void *)base, sizeof(*argarray) * AT_OLD_COUNT);
  102         free(argarray, M_TEMP);
  103         return (error);
  104 }

Cache object: 3000948242000029e853cc7037eb8025


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.