Home | History | Annotate | Line # | Download | only in common
linux_exec_elf32.c revision 1.71
      1  1.71      manu /*	$NetBSD: linux_exec_elf32.c,v 1.71 2006/02/09 19:18:56 manu Exp $	*/
      2  1.29  christos 
      3  1.29  christos /*-
      4  1.51      manu  * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
      5  1.29  christos  * All rights reserved.
      6  1.29  christos  *
      7  1.29  christos  * This code is derived from software contributed to The NetBSD Foundation
      8  1.51      manu  * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and
      9  1.51      manu  * Emmanuel Dreyfus.
     10  1.29  christos  *
     11  1.29  christos  * Redistribution and use in source and binary forms, with or without
     12  1.29  christos  * modification, are permitted provided that the following conditions
     13  1.29  christos  * are met:
     14  1.29  christos  * 1. Redistributions of source code must retain the above copyright
     15  1.29  christos  *    notice, this list of conditions and the following disclaimer.
     16  1.29  christos  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.29  christos  *    notice, this list of conditions and the following disclaimer in the
     18  1.29  christos  *    documentation and/or other materials provided with the distribution.
     19  1.29  christos  * 3. All advertising materials mentioning features or use of this software
     20  1.29  christos  *    must display the following acknowledgement:
     21  1.31       erh  *	This product includes software developed by the NetBSD
     22  1.31       erh  *	Foundation, Inc. and its contributors.
     23  1.29  christos  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.29  christos  *    contributors may be used to endorse or promote products derived
     25  1.29  christos  *    from this software without specific prior written permission.
     26  1.29  christos  *
     27  1.29  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.29  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.29  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.29  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.29  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.29  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.29  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.29  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.29  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.29  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.29  christos  * POSSIBILITY OF SUCH DAMAGE.
     38  1.29  christos  */
     39   1.1      fvdl 
     40   1.1      fvdl /*
     41   1.7      fvdl  * based on exec_aout.c, sunos_exec.c and svr4_exec.c
     42   1.1      fvdl  */
     43  1.54     lukem 
     44  1.54     lukem #include <sys/cdefs.h>
     45  1.71      manu __KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.71 2006/02/09 19:18:56 manu Exp $");
     46   1.1      fvdl 
     47  1.31       erh #ifndef ELFSIZE
     48  1.58  christos /* XXX should die */
     49  1.58  christos #define	ELFSIZE		32
     50  1.31       erh #endif
     51  1.17       cgd 
     52   1.1      fvdl #include <sys/param.h>
     53   1.1      fvdl #include <sys/systm.h>
     54   1.1      fvdl #include <sys/kernel.h>
     55   1.1      fvdl #include <sys/proc.h>
     56   1.1      fvdl #include <sys/malloc.h>
     57   1.1      fvdl #include <sys/namei.h>
     58   1.1      fvdl #include <sys/vnode.h>
     59  1.13  christos #include <sys/mount.h>
     60  1.25  christos #include <sys/exec.h>
     61   1.8      fvdl #include <sys/exec_elf.h>
     62  1.59  jdolecek #include <sys/stat.h>
     63   1.1      fvdl 
     64   1.1      fvdl #include <sys/mman.h>
     65  1.61   thorpej #include <sys/sa.h>
     66  1.13  christos #include <sys/syscallargs.h>
     67   1.1      fvdl 
     68   1.1      fvdl #include <machine/cpu.h>
     69   1.1      fvdl #include <machine/reg.h>
     70   1.1      fvdl 
     71  1.32  christos #include <compat/linux/common/linux_types.h>
     72  1.32  christos #include <compat/linux/common/linux_signal.h>
     73  1.32  christos #include <compat/linux/common/linux_util.h>
     74  1.32  christos #include <compat/linux/common/linux_exec.h>
     75  1.32  christos #include <compat/linux/common/linux_machdep.h>
     76  1.32  christos 
     77  1.32  christos #include <compat/linux/linux_syscallargs.h>
     78   1.4  christos #include <compat/linux/linux_syscall.h>
     79  1.31       erh 
     80  1.56  christos #ifdef DEBUG_LINUX
     81  1.56  christos #define DPRINTF(a)	uprintf a
     82  1.56  christos #else
     83  1.56  christos #define DPRINTF(a)
     84  1.56  christos #endif
     85  1.56  christos 
     86  1.51      manu #ifdef LINUX_ATEXIT_SIGNATURE
     87  1.51      manu /*
     88  1.51      manu  * On the PowerPC, statically linked Linux binaries are not recognized
     89  1.51      manu  * by linux_signature nor by linux_gcc_signature. Fortunately, thoses
     90  1.51      manu  * binaries features a __libc_atexit ELF section. We therefore assume we
     91  1.51      manu  * have a Linux binary if we find this section.
     92  1.51      manu  */
     93  1.71      manu int
     94  1.70  christos ELFNAME2(linux,atexit_signature)(l, epp, eh)
     95  1.70  christos 	struct lwp *l;
     96  1.51      manu 	struct exec_package *epp;
     97  1.51      manu 	Elf_Ehdr *eh;
     98  1.51      manu {
     99  1.51      manu 	size_t shsize;
    100  1.65       chs 	int strndx;
    101  1.51      manu 	size_t i;
    102  1.51      manu 	static const char signature[] = "__libc_atexit";
    103  1.65       chs 	char *strtable = NULL;
    104  1.51      manu 	Elf_Shdr *sh;
    105  1.67     perry 
    106  1.51      manu 	int error;
    107  1.51      manu 
    108  1.52  christos 	/*
    109  1.67     perry 	 * load the section header table
    110  1.52  christos 	 */
    111  1.51      manu 	shsize = eh->e_shnum * sizeof(Elf_Shdr);
    112  1.51      manu 	sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
    113  1.70  christos 	error = exec_read_from(l, epp->ep_vp, eh->e_shoff, sh, shsize);
    114  1.51      manu 	if (error)
    115  1.51      manu 		goto out;
    116  1.51      manu 
    117  1.67     perry 	/*
    118  1.52  christos 	 * Now let's find the string table. If it does not exists, give up.
    119  1.52  christos 	 */
    120  1.51      manu 	strndx = (int)(eh->e_shstrndx);
    121  1.52  christos 	if (strndx == SHN_UNDEF) {
    122  1.51      manu 		error = ENOEXEC;
    123  1.51      manu 		goto out;
    124  1.51      manu 	}
    125  1.51      manu 
    126  1.52  christos 	/*
    127  1.52  christos 	 * strndx is the index in section header table of the string table
    128  1.52  christos 	 * section get the whole string table in strtable, and then we get access to the names
    129  1.52  christos 	 * s->sh_name is the offset of the section name in strtable.
    130  1.52  christos 	 */
    131  1.51      manu 	strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
    132  1.70  christos 	error = exec_read_from(l, epp->ep_vp, sh[strndx].sh_offset, strtable,
    133  1.52  christos 	    sh[strndx].sh_size);
    134  1.51      manu 	if (error)
    135  1.51      manu 		goto out;
    136  1.51      manu 
    137  1.51      manu 	for (i = 0; i < eh->e_shnum; i++) {
    138  1.51      manu 		Elf_Shdr *s = &sh[i];
    139  1.67     perry 		if (!memcmp((void*)(&(strtable[s->sh_name])), signature,
    140  1.51      manu 				sizeof(signature))) {
    141  1.56  christos 			DPRINTF(("linux_atexit_sig=%s\n",
    142  1.56  christos 			    &(strtable[s->sh_name])));
    143  1.51      manu 			error = 0;
    144  1.51      manu 			goto out;
    145  1.51      manu 		}
    146  1.51      manu 	}
    147  1.51      manu 	error = ENOEXEC;
    148  1.51      manu 
    149  1.51      manu out:
    150  1.51      manu 	free(sh, M_TEMP);
    151  1.65       chs 	if (strtable)
    152  1.65       chs 		free(strtable, M_TEMP);
    153  1.51      manu 	return (error);
    154  1.51      manu }
    155  1.51      manu #endif
    156   1.4  christos 
    157  1.31       erh #ifdef LINUX_GCC_SIGNATURE
    158  1.14  christos /*
    159  1.14  christos  * Take advantage of the fact that all the linux binaries are compiled
    160  1.14  christos  * with gcc, and gcc sticks in the comment field a signature. Note that
    161  1.14  christos  * on SVR4 binaries, the gcc signature will follow the OS name signature,
    162  1.14  christos  * that will not be a problem. We don't bother to read in the string table,
    163  1.14  christos  * but we check all the progbits headers.
    164  1.31       erh  *
    165  1.31       erh  * XXX This only works in the i386.  On the alpha (at least)
    166  1.31       erh  * XXX we have the same gcc signature which incorrectly identifies
    167  1.31       erh  * XXX NetBSD binaries as Linux.
    168  1.14  christos  */
    169  1.71      manu int
    170  1.70  christos ELFNAME2(linux,gcc_signature)(l, epp, eh)
    171  1.70  christos 	struct lwp *l;
    172  1.14  christos 	struct exec_package *epp;
    173  1.31       erh 	Elf_Ehdr *eh;
    174  1.14  christos {
    175  1.50   mycroft 	size_t shsize;
    176  1.14  christos 	size_t i;
    177  1.14  christos 	static const char signature[] = "\0GCC: (GNU) ";
    178  1.69  christos 	char tbuf[sizeof(signature) - 1];
    179  1.31       erh 	Elf_Shdr *sh;
    180  1.14  christos 	int error;
    181  1.14  christos 
    182  1.50   mycroft 	shsize = eh->e_shnum * sizeof(Elf_Shdr);
    183  1.31       erh 	sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
    184  1.70  christos 	error = exec_read_from(l, epp->ep_vp, eh->e_shoff, sh, shsize);
    185  1.50   mycroft 	if (error)
    186  1.14  christos 		goto out;
    187  1.14  christos 
    188  1.14  christos 	for (i = 0; i < eh->e_shnum; i++) {
    189  1.31       erh 		Elf_Shdr *s = &sh[i];
    190  1.14  christos 
    191  1.14  christos 		/*
    192  1.14  christos 		 * Identify candidates for the comment header;
    193  1.15  christos 		 * Header cannot have a load address, or flags and
    194  1.14  christos 		 * it must be large enough.
    195  1.14  christos 		 */
    196  1.43    kleink 		if (s->sh_type != SHT_PROGBITS ||
    197  1.14  christos 		    s->sh_addr != 0 ||
    198  1.14  christos 		    s->sh_flags != 0 ||
    199  1.14  christos 		    s->sh_size < sizeof(signature) - 1)
    200  1.14  christos 			continue;
    201  1.14  christos 
    202  1.70  christos 		error = exec_read_from(l, epp->ep_vp, s->sh_offset, tbuf,
    203  1.52  christos 		    sizeof(signature) - 1);
    204  1.50   mycroft 		if (error)
    205  1.50   mycroft 			continue;
    206  1.14  christos 
    207  1.15  christos 		/*
    208  1.15  christos 		 * error is 0, if the signatures match we are done.
    209  1.15  christos 		 */
    210  1.69  christos 		DPRINTF(("linux_gcc_sig: sig=%s\n", tbuf));
    211  1.69  christos 		if (!memcmp(tbuf, signature, sizeof(signature) - 1)) {
    212  1.50   mycroft 			error = 0;
    213  1.14  christos 			goto out;
    214  1.50   mycroft 		}
    215  1.14  christos 	}
    216  1.50   mycroft 	error = ENOEXEC;
    217  1.14  christos 
    218  1.14  christos out:
    219  1.14  christos 	free(sh, M_TEMP);
    220  1.50   mycroft 	return (error);
    221  1.14  christos }
    222  1.31       erh #endif
    223  1.31       erh 
    224  1.71      manu int
    225  1.70  christos ELFNAME2(linux,signature)(l, epp, eh, itp)
    226  1.70  christos 	struct lwp *l;
    227  1.31       erh 	struct exec_package *epp;
    228  1.31       erh 	Elf_Ehdr *eh;
    229  1.50   mycroft 	char *itp;
    230  1.31       erh {
    231  1.31       erh 	size_t i;
    232  1.31       erh 	Elf_Phdr *ph;
    233  1.31       erh 	size_t phsize;
    234  1.50   mycroft 	int error;
    235  1.57  christos 	static const char linux[] = "Linux";
    236  1.57  christos 
    237  1.57  christos 	if (eh->e_ident[EI_OSABI] == 3 ||
    238  1.57  christos 	    memcmp(&eh->e_ident[EI_ABIVERSION], linux, sizeof(linux)) == 0)
    239  1.57  christos 		return 0;
    240  1.31       erh 
    241  1.31       erh 	phsize = eh->e_phnum * sizeof(Elf_Phdr);
    242  1.31       erh 	ph = (Elf_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);
    243  1.70  christos 	error = exec_read_from(l, epp->ep_vp, eh->e_phoff, ph, phsize);
    244  1.50   mycroft 	if (error)
    245  1.50   mycroft 		goto out;
    246  1.31       erh 
    247  1.31       erh 	for (i = 0; i < eh->e_phnum; i++) {
    248  1.31       erh 		Elf_Phdr *ephp = &ph[i];
    249  1.50   mycroft 		Elf_Nhdr *np;
    250  1.50   mycroft 		u_int32_t *abi;
    251  1.31       erh 
    252  1.50   mycroft 		if (ephp->p_type != PT_NOTE ||
    253  1.50   mycroft 		    ephp->p_filesz > 1024 ||
    254  1.50   mycroft 		    ephp->p_filesz < sizeof(Elf_Nhdr) + 20)
    255  1.31       erh 			continue;
    256  1.31       erh 
    257  1.50   mycroft 		np = (Elf_Nhdr *)malloc(ephp->p_filesz, M_TEMP, M_WAITOK);
    258  1.70  christos 		error = exec_read_from(l, epp->ep_vp, ephp->p_offset, np,
    259  1.52  christos 		    ephp->p_filesz);
    260  1.50   mycroft 		if (error)
    261  1.50   mycroft 			goto next;
    262  1.50   mycroft 
    263  1.50   mycroft 		if (np->n_type != ELF_NOTE_TYPE_ABI_TAG ||
    264  1.50   mycroft 		    np->n_namesz != ELF_NOTE_ABI_NAMESZ ||
    265  1.50   mycroft 		    np->n_descsz != ELF_NOTE_ABI_DESCSZ ||
    266  1.50   mycroft 		    memcmp((caddr_t)(np + 1), ELF_NOTE_ABI_NAME,
    267  1.50   mycroft 		    ELF_NOTE_ABI_NAMESZ))
    268  1.50   mycroft 			goto next;
    269  1.50   mycroft 
    270  1.50   mycroft 		/* Make sure the OS is Linux. */
    271  1.50   mycroft 		abi = (u_int32_t *)((caddr_t)np + sizeof(Elf_Nhdr) +
    272  1.50   mycroft 		    np->n_namesz);
    273  1.50   mycroft 		if (abi[0] == ELF_NOTE_ABI_OS_LINUX)
    274  1.50   mycroft 			error = 0;
    275  1.50   mycroft 		else
    276  1.40       erh 			error = ENOEXEC;
    277  1.50   mycroft 		free(np, M_TEMP);
    278  1.50   mycroft 		goto out;
    279  1.31       erh 
    280  1.50   mycroft 	next:
    281  1.50   mycroft 		free(np, M_TEMP);
    282  1.50   mycroft 		continue;
    283  1.50   mycroft 	}
    284  1.31       erh 
    285  1.50   mycroft 	/* Check for certain intepreter names. */
    286  1.66  drochner 	if (itp) {
    287  1.50   mycroft 		if (!strncmp(itp, "/lib/ld-linux", 13) ||
    288  1.68      manu #if (ELFSIZE == 64)
    289  1.68      manu 		    !strncmp(itp, "/lib64/ld-linux", 15) ||
    290  1.68      manu #endif
    291  1.50   mycroft 		    !strncmp(itp, "/lib/ld.so.", 11))
    292  1.50   mycroft 			error = 0;
    293  1.50   mycroft 		else
    294  1.50   mycroft 			error = ENOEXEC;
    295  1.50   mycroft 		goto out;
    296  1.31       erh 	}
    297  1.31       erh 
    298  1.31       erh 	error = ENOEXEC;
    299  1.50   mycroft out:
    300  1.31       erh 	free(ph, M_TEMP);
    301  1.50   mycroft 	return (error);
    302  1.31       erh }
    303  1.14  christos 
    304   1.8      fvdl int
    305  1.70  christos ELFNAME2(linux,probe)(l, epp, eh, itp, pos)
    306  1.70  christos 	struct lwp *l;
    307   1.8      fvdl 	struct exec_package *epp;
    308  1.48  jdolecek 	void *eh;
    309   1.8      fvdl 	char *itp;
    310  1.48  jdolecek 	vaddr_t *pos;
    311   1.6      fvdl {
    312   1.8      fvdl 	int error;
    313  1.14  christos 
    314  1.70  christos 	if (((error = ELFNAME2(linux,signature)(l, epp, eh, itp)) != 0) &&
    315  1.51      manu #ifdef LINUX_GCC_SIGNATURE
    316  1.70  christos 	    ((error = ELFNAME2(linux,gcc_signature)(l, epp, eh)) != 0) &&
    317  1.53      manu #endif
    318  1.51      manu #ifdef LINUX_ATEXIT_SIGNATURE
    319  1.70  christos 	    ((error = ELFNAME2(linux,atexit_signature)(l, epp, eh)) != 0) &&
    320  1.53      manu #endif
    321  1.67     perry 	    1)
    322  1.51      manu 			return error;
    323   1.6      fvdl 
    324  1.66  drochner 	if (itp) {
    325  1.70  christos 		if ((error = emul_find_interp(l, epp->ep_esch->es_emul->e_path,
    326  1.60  jdolecek 		    itp)))
    327  1.60  jdolecek 			return (error);
    328   1.6      fvdl 	}
    329  1.56  christos 	DPRINTF(("linux_probe: returning 0\n"));
    330   1.6      fvdl 	return 0;
    331   1.6      fvdl }
    332   1.6      fvdl 
    333  1.59  jdolecek #ifndef LINUX_MACHDEP_ELF_COPYARGS
    334  1.59  jdolecek /*
    335  1.59  jdolecek  * Copy arguments onto the stack in the normal way, but add some
    336  1.59  jdolecek  * extra information in case of dynamic binding.
    337  1.59  jdolecek  */
    338  1.59  jdolecek int
    339  1.70  christos ELFNAME2(linux,copyargs)(struct lwp *l, struct exec_package *pack,
    340  1.59  jdolecek     struct ps_strings *arginfo, char **stackp, void *argp)
    341  1.59  jdolecek {
    342  1.70  christos 	struct proc *p = l->l_proc;
    343  1.59  jdolecek 	size_t len;
    344  1.59  jdolecek 	AuxInfo ai[LINUX_ELF_AUX_ENTRIES], *a;
    345  1.59  jdolecek 	struct elf_args *ap;
    346  1.59  jdolecek 	int error;
    347  1.59  jdolecek 	struct vattr *vap;
    348  1.59  jdolecek 
    349  1.70  christos 	if ((error = copyargs(l, pack, arginfo, stackp, argp)) != 0)
    350  1.59  jdolecek 		return error;
    351  1.59  jdolecek 
    352  1.59  jdolecek 	a = ai;
    353  1.59  jdolecek 
    354  1.59  jdolecek 	/*
    355  1.59  jdolecek 	 * Push extra arguments used by glibc on the stack.
    356  1.59  jdolecek 	 */
    357  1.59  jdolecek 
    358  1.59  jdolecek 	a->a_type = AT_PAGESZ;
    359  1.59  jdolecek 	a->a_v = PAGE_SIZE;
    360  1.59  jdolecek 	a++;
    361  1.59  jdolecek 
    362  1.59  jdolecek 	if ((ap = (struct elf_args *)pack->ep_emul_arg)) {
    363  1.59  jdolecek 
    364  1.59  jdolecek 		a->a_type = AT_PHDR;
    365  1.59  jdolecek 		a->a_v = ap->arg_phaddr;
    366  1.59  jdolecek 		a++;
    367  1.59  jdolecek 
    368  1.59  jdolecek 		a->a_type = AT_PHENT;
    369  1.59  jdolecek 		a->a_v = ap->arg_phentsize;
    370  1.59  jdolecek 		a++;
    371  1.59  jdolecek 
    372  1.59  jdolecek 		a->a_type = AT_PHNUM;
    373  1.59  jdolecek 		a->a_v = ap->arg_phnum;
    374  1.59  jdolecek 		a++;
    375  1.59  jdolecek 
    376  1.59  jdolecek 		a->a_type = AT_BASE;
    377  1.59  jdolecek 		a->a_v = ap->arg_interp;
    378  1.59  jdolecek 		a++;
    379  1.59  jdolecek 
    380  1.59  jdolecek 		a->a_type = AT_FLAGS;
    381  1.59  jdolecek 		a->a_v = 0;
    382  1.59  jdolecek 		a++;
    383  1.59  jdolecek 
    384  1.59  jdolecek 		a->a_type = AT_ENTRY;
    385  1.59  jdolecek 		a->a_v = ap->arg_entry;
    386  1.59  jdolecek 		a++;
    387  1.59  jdolecek 
    388  1.59  jdolecek 		free(pack->ep_emul_arg, M_TEMP);
    389  1.59  jdolecek 		pack->ep_emul_arg = NULL;
    390  1.59  jdolecek 	}
    391  1.59  jdolecek 
    392  1.59  jdolecek 	/* Linux-specific items */
    393  1.59  jdolecek 	a->a_type = LINUX_AT_CLKTCK;
    394  1.59  jdolecek 	a->a_v = hz;
    395  1.59  jdolecek 	a++;
    396  1.59  jdolecek 
    397  1.59  jdolecek 	vap = pack->ep_vap;
    398  1.59  jdolecek 
    399  1.59  jdolecek 	a->a_type = LINUX_AT_UID;
    400  1.59  jdolecek 	a->a_v = p->p_cred->p_ruid;
    401  1.59  jdolecek 	a++;
    402  1.59  jdolecek 
    403  1.59  jdolecek 	a->a_type = LINUX_AT_EUID;
    404  1.59  jdolecek 	if (vap->va_mode & S_ISUID)
    405  1.59  jdolecek 		a->a_v = vap->va_uid;
    406  1.59  jdolecek 	else
    407  1.59  jdolecek 		a->a_v = p->p_ucred->cr_uid;
    408  1.59  jdolecek 	a++;
    409  1.59  jdolecek 
    410  1.59  jdolecek 	a->a_type = LINUX_AT_GID;
    411  1.59  jdolecek 	a->a_v = p->p_cred->p_rgid;
    412  1.59  jdolecek 	a++;
    413  1.59  jdolecek 
    414  1.59  jdolecek 	a->a_type = LINUX_AT_EGID;
    415  1.59  jdolecek 	if (vap->va_mode & S_ISGID)
    416  1.59  jdolecek 		a->a_v = vap->va_gid;
    417  1.59  jdolecek 	else
    418  1.59  jdolecek 		a->a_v = p->p_ucred->cr_gid;
    419  1.59  jdolecek 	a++;
    420  1.59  jdolecek 
    421  1.59  jdolecek 	a->a_type = AT_NULL;
    422  1.59  jdolecek 	a->a_v = 0;
    423  1.59  jdolecek 	a++;
    424  1.59  jdolecek 
    425  1.59  jdolecek 	len = (a - ai) * sizeof(AuxInfo);
    426  1.59  jdolecek 	if ((error = copyout(ai, *stackp, len)) != 0)
    427  1.59  jdolecek 		return error;
    428  1.59  jdolecek 	*stackp += len;
    429  1.59  jdolecek 
    430  1.59  jdolecek 	return 0;
    431  1.59  jdolecek }
    432  1.59  jdolecek #endif /* !LINUX_MACHDEP_ELF_COPYARGS */
    433