xref: /openbmc/qemu/linux-user/loader.h (revision 0347c4c4)
1 /*
2  * loader.h: prototypes for linux-user guest binary loader
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LINUX_USER_LOADER_H
19 #define LINUX_USER_LOADER_H
20 
21 /*
22  * Read a good amount of data initially, to hopefully get all the
23  * program headers loaded.
24  */
25 #define BPRM_BUF_SIZE  1024
26 
27 /*
28  * This structure is used to hold the arguments that are
29  * used when loading binaries.
30  */
31 struct linux_binprm {
32         char buf[BPRM_BUF_SIZE] __attribute__((aligned));
33         abi_ulong p;
34         int fd;
35         int e_uid, e_gid;
36         int argc, envc;
37         char **argv;
38         char **envp;
39         char *filename;        /* Name of binary */
40         int (*core_dump)(int, const CPUArchState *); /* coredump routine */
41 };
42 
43 void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
44 abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
45                               abi_ulong stringp, int push_ptr);
46 int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
47              struct target_pt_regs *regs, struct image_info *infop,
48              struct linux_binprm *);
49 
50 uint32_t get_elf_eflags(int fd);
51 int load_elf_binary(struct linux_binprm *bprm, struct image_info *info);
52 int load_flt_binary(struct linux_binprm *bprm, struct image_info *info);
53 
54 abi_long memcpy_to_target(abi_ulong dest, const void *src,
55                           unsigned long len);
56 
57 extern unsigned long guest_stack_size;
58 
59 #endif /* LINUX_USER_LOADER_H */
60