Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rcore-os
RCore Tutorial V3
提交
4b01ff7c
R
RCore Tutorial V3
项目概览
rcore-os
/
RCore Tutorial V3
上一次同步 1 年多
通知
15
Star
793
Fork
260
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RCore Tutorial V3
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4b01ff7c
编写于
12月 02, 2020
作者:
Y
Yifan Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Build application at 0x0 in release mode.
上级
63aaa9d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
3 addition
and
40 deletion
+3
-40
user/Makefile
user/Makefile
+2
-2
user/build.py
user/build.py
+0
-25
user/src/lib.rs
user/src/lib.rs
+0
-10
user/src/linker.ld
user/src/linker.ld
+1
-3
未找到文件。
user/Makefile
浏览文件 @
4b01ff7c
TARGET
:=
riscv64gc-unknown-none-elf
MODE
:=
debug
MODE
:=
release
APP_DIR
:=
src/bin
TARGET_DIR
:=
target/
$(TARGET)
/
$(MODE)
APPS
:=
$(
wildcard
$(APP_DIR)
/
*
.rs
)
...
...
@@ -10,7 +10,7 @@ OBJDUMP := rust-objdump --arch-name=riscv64
OBJCOPY
:=
rust-objcopy
--binary-architecture
=
riscv64
elf
:
$(APPS)
@
python3 build.py
@
cargo build
--release
binary
:
elf
$(
foreach
elf,
$(ELFS)
,
$(OBJCOPY)
$(elf)
--strip-all
-O
binary
$(
patsubst
$(TARGET_DIR)
/%,
$(TARGET_DIR)
/%.bin,
$(elf)
)
;
)
...
...
user/build.py
已删除
100644 → 0
浏览文件 @
63aaa9d0
import
os
base_address
=
0x80100000
step
=
0x20000
linker
=
'src/linker.ld'
app_id
=
0
apps
=
os
.
listdir
(
'src/bin'
)
apps
.
sort
()
for
app
in
apps
:
app
=
app
[:
app
.
find
(
'.'
)]
lines
=
[]
lines_before
=
[]
with
open
(
linker
,
'r'
)
as
f
:
for
line
in
f
.
readlines
():
lines_before
.
append
(
line
)
line
=
line
.
replace
(
hex
(
base_address
),
hex
(
base_address
+
step
*
app_id
))
lines
.
append
(
line
)
with
open
(
linker
,
'w+'
)
as
f
:
f
.
writelines
(
lines
)
os
.
system
(
'cargo build --bin %s'
%
app
)
print
(
'[build.py] application %s start with address %s'
%
(
app
,
hex
(
base_address
+
step
*
app_id
)))
with
open
(
linker
,
'w+'
)
as
f
:
f
.
writelines
(
lines_before
)
app_id
=
app_id
+
1
user/src/lib.rs
浏览文件 @
4b01ff7c
...
...
@@ -11,7 +11,6 @@ mod lang_items;
#[no_mangle]
#[link_section
=
".text.entry"
]
pub
extern
"C"
fn
_
start
()
->
!
{
clear_bss
();
syscall
::
sys_exit
(
main
());
panic!
(
"unreachable after sys_exit!"
);
}
...
...
@@ -22,14 +21,5 @@ fn main() -> i32 {
panic!
(
"Cannot find main!"
);
}
fn
clear_bss
()
{
extern
"C"
{
fn
start_bss
();
fn
end_bss
();
}
(
start_bss
as
usize
..
end_bss
as
usize
)
.for_each
(|
addr
|
{
unsafe
{
(
addr
as
*
mut
u8
)
.write_volatile
(
0
);
}
});
}
pub
use
syscall
::
*
;
\ No newline at end of file
user/src/linker.ld
浏览文件 @
4b01ff7c
...
...
@@ -2,7 +2,7 @@
OUTPUT_ARCH(riscv)
ENTRY(_start)
BASE_ADDRESS = 0x
8010000
0;
BASE_ADDRESS = 0x0;
SECTIONS
{
...
...
@@ -18,9 +18,7 @@ SECTIONS
*(.data .data.*)
}
.bss : {
start_bss = .;
*(.bss .bss.*)
end_bss = .;
}
/DISCARD/ : {
*(.eh_frame)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录