Skip to content

Commit 3ad0a76

Browse files
pm215vivier
authored andcommitted
linux-user: Split loader-related prototypes into loader.h
Split guest-binary loader prototypes out into a new header loader.h which we include only where required. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent 2113aed commit 3ad0a76

File tree

8 files changed

+65
-40
lines changed

8 files changed

+65
-40
lines changed

linux-user/elfload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <sys/shm.h>
77

88
#include "qemu.h"
9+
#include "loader.h"
910
#include "disas/disas.h"
1011
#include "qemu/bitops.h"
1112
#include "qemu/path.h"

linux-user/flatload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "qemu/osdep.h"
3737

3838
#include "qemu.h"
39+
#include "loader.h"
3940
#include "flat.h"
4041
#include "target_flat.h"
4142

linux-user/linuxload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "qemu/osdep.h"
44
#include "qemu.h"
5+
#include "loader.h"
56

67
#define NGROUPS 32
78

linux-user/loader.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 */

linux-user/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "crypto/init.h"
5151
#include "fd-trans.h"
5252
#include "signal-common.h"
53+
#include "loader.h"
5354

5455
#ifndef AT_FLAGS_PRESERVE_ARGV0
5556
#define AT_FLAGS_PRESERVE_ARGV0_BIT 0

linux-user/qemu.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -173,30 +173,6 @@ void stop_all_tasks(void);
173173
extern const char *qemu_uname_release;
174174
extern unsigned long mmap_min_addr;
175175

176-
/* ??? See if we can avoid exposing so much of the loader internals. */
177-
178-
/*
179-
* Read a good amount of data initially, to hopefully get all the
180-
* program headers loaded.
181-
*/
182-
#define BPRM_BUF_SIZE 1024
183-
184-
/*
185-
* This structure is used to hold the arguments that are
186-
* used when loading binaries.
187-
*/
188-
struct linux_binprm {
189-
char buf[BPRM_BUF_SIZE] __attribute__((aligned));
190-
abi_ulong p;
191-
int fd;
192-
int e_uid, e_gid;
193-
int argc, envc;
194-
char **argv;
195-
char **envp;
196-
char *filename; /* Name of binary */
197-
int (*core_dump)(int, const CPUArchState *); /* coredump routine */
198-
};
199-
200176
typedef struct IOCTLEntry IOCTLEntry;
201177

202178
typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp,
@@ -217,13 +193,6 @@ extern IOCTLEntry ioctl_entries[];
217193
#define IOC_W 0x0002
218194
#define IOC_RW (IOC_R | IOC_W)
219195

220-
void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
221-
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
222-
abi_ulong stringp, int push_ptr);
223-
int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
224-
struct target_pt_regs *regs, struct image_info *infop,
225-
struct linux_binprm *);
226-
227196
/*
228197
* Returns true if the image uses the FDPIC ABI. If this is the case,
229198
* we have to provide some information (loadmap, pt_dynamic_info) such
@@ -232,12 +201,6 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
232201
*/
233202
int info_is_fdpic(struct image_info *info);
234203

235-
uint32_t get_elf_eflags(int fd);
236-
int load_elf_binary(struct linux_binprm *bprm, struct image_info *info);
237-
int load_flt_binary(struct linux_binprm *bprm, struct image_info *info);
238-
239-
abi_long memcpy_to_target(abi_ulong dest, const void *src,
240-
unsigned long len);
241204
void target_set_brk(abi_ulong new_brk);
242205
abi_long do_brk(abi_ulong new_brk);
243206
void syscall_init(void);
@@ -440,9 +403,6 @@ abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong);
440403
void mmap_fork_start(void);
441404
void mmap_fork_end(int child);
442405

443-
/* main.c */
444-
extern unsigned long guest_stack_size;
445-
446406
/* user access */
447407

448408
#define VERIFY_READ PAGE_READ

linux-user/signal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "qemu.h"
2525
#include "strace.h"
26+
#include "loader.h"
2627
#include "trace.h"
2728
#include "signal-common.h"
2829

linux-user/syscall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
#include "qemu.h"
130130
#include "strace.h"
131131
#include "signal-common.h"
132+
#include "loader.h"
132133
#include "qemu/guest-random.h"
133134
#include "qemu/selfmap.h"
134135
#include "user/syscall-trace.h"

0 commit comments

Comments
 (0)