Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
2fa5d9ba
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2fa5d9ba
编写于
9月 27, 2009
作者:
B
Blue Swirl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BSD user: implement GUEST_BASE
Based on
379f6698
. Signed-off-by:
N
Blue Swirl
<
blauwirbel@gmail.com
>
上级
17cf428f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
0 deletion
+70
-0
bsd-user/elfload.c
bsd-user/elfload.c
+23
-0
bsd-user/main.c
bsd-user/main.c
+44
-0
bsd-user/qemu.h
bsd-user/qemu.h
+3
-0
未找到文件。
bsd-user/elfload.c
浏览文件 @
2fa5d9ba
...
...
@@ -1337,6 +1337,29 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
info
->
mmap
=
0
;
elf_entry
=
(
abi_ulong
)
elf_ex
.
e_entry
;
#if defined(CONFIG_USE_GUEST_BASE)
/*
* In case where user has not explicitly set the guest_base, we
* probe here that should we set it automatically.
*/
if
(
!
have_guest_base
)
{
/*
* Go through ELF program header table and find out whether
* any of the segments drop below our current mmap_min_addr and
* in that case set guest_base to corresponding address.
*/
for
(
i
=
0
,
elf_ppnt
=
elf_phdata
;
i
<
elf_ex
.
e_phnum
;
i
++
,
elf_ppnt
++
)
{
if
(
elf_ppnt
->
p_type
!=
PT_LOAD
)
continue
;
if
(
HOST_PAGE_ALIGN
(
elf_ppnt
->
p_vaddr
)
<
mmap_min_addr
)
{
guest_base
=
HOST_PAGE_ALIGN
(
mmap_min_addr
);
break
;
}
}
}
#endif
/* CONFIG_USE_GUEST_BASE */
/* Do this so that we can load the interpreter, if need be. We will
change some of these later */
info
->
rss
=
0
;
...
...
bsd-user/main.c
浏览文件 @
2fa5d9ba
...
...
@@ -37,6 +37,11 @@
#define DEBUG_LOGFILE "/tmp/qemu.log"
int
singlestep
;
#if defined(CONFIG_USE_GUEST_BASE)
unsigned
long
mmap_min_addr
;
unsigned
long
guest_base
;
int
have_guest_base
;
#endif
static
const
char
*
interp_prefix
=
CONFIG_QEMU_PREFIX
;
const
char
*
qemu_uname_release
=
CONFIG_UNAME_RELEASE
;
...
...
@@ -607,6 +612,9 @@ static void usage(void)
"-drop-ld-preload drop LD_PRELOAD for target process
\n
"
"-E var=value sets/modifies targets environment variable(s)
\n
"
"-U var unsets targets environment variable(s)
\n
"
#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address
\n
"
#endif
"-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)
\n
"
"
\n
"
"Debug options:
\n
"
...
...
@@ -746,6 +754,11 @@ int main(int argc, char **argv)
#endif
exit
(
1
);
}
#if defined(CONFIG_USE_GUEST_BASE)
}
else
if
(
!
strcmp
(
r
,
"B"
))
{
guest_base
=
strtol
(
argv
[
optind
++
],
NULL
,
0
);
have_guest_base
=
1
;
#endif
}
else
if
(
!
strcmp
(
r
,
"drop-ld-preload"
))
{
(
void
)
envlist_unsetenv
(
envlist
,
"LD_PRELOAD"
);
}
else
if
(
!
strcmp
(
r
,
"bsd"
))
{
...
...
@@ -815,6 +828,34 @@ int main(int argc, char **argv)
target_environ
=
envlist_to_environ
(
envlist
,
NULL
);
envlist_free
(
envlist
);
#if defined(CONFIG_USE_GUEST_BASE)
/*
* Now that page sizes are configured in cpu_init() we can do
* proper page alignment for guest_base.
*/
guest_base
=
HOST_PAGE_ALIGN
(
guest_base
);
/*
* Read in mmap_min_addr kernel parameter. This value is used
* When loading the ELF image to determine whether guest_base
* is needed.
*
* When user has explicitly set the quest base, we skip this
* test.
*/
if
(
!
have_guest_base
)
{
FILE
*
fp
;
if
((
fp
=
fopen
(
"/proc/sys/vm/mmap_min_addr"
,
"r"
))
!=
NULL
)
{
unsigned
long
tmp
;
if
(
fscanf
(
fp
,
"%lu"
,
&
tmp
)
==
1
)
{
mmap_min_addr
=
tmp
;
qemu_log
(
"host mmap_min_addr=0x%lx
\n
"
,
mmap_min_addr
);
}
fclose
(
fp
);
}
}
#endif
/* CONFIG_USE_GUEST_BASE */
if
(
loader_exec
(
filename
,
argv
+
optind
,
target_environ
,
regs
,
info
)
!=
0
)
{
printf
(
"Error loading %s
\n
"
,
filename
);
...
...
@@ -828,6 +869,9 @@ int main(int argc, char **argv)
free
(
target_environ
);
if
(
qemu_log_enabled
())
{
#if defined(CONFIG_USE_GUEST_BASE)
qemu_log
(
"guest_base 0x%lx
\n
"
,
guest_base
);
#endif
log_page_dump
();
qemu_log
(
"start_brk 0x"
TARGET_ABI_FMT_lx
"
\n
"
,
info
->
start_brk
);
...
...
bsd-user/qemu.h
浏览文件 @
2fa5d9ba
...
...
@@ -84,6 +84,9 @@ typedef struct TaskState {
void
init_task_state
(
TaskState
*
ts
);
extern
const
char
*
qemu_uname_release
;
#if defined(CONFIG_USE_GUEST_BASE)
extern
unsigned
long
mmap_min_addr
;
#endif
/* ??? See if we can avoid exposing so much of the loader internals. */
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录