flaneur2020 / fleurix Goto Github PK
View Code? Open in Web Editor NEWan unix-like toy os kernel
License: BSD 3-Clause "New" or "Revised" License
an unix-like toy os kernel
License: BSD 3-Clause "New" or "Revised" License
after having added one printn() in init.c, a seg fault was triggered.
int main(int argc, char **argv){
uint ret, pid;
if (fork()==0) {
exec("/bin/sh", NULL);
}
printn(1, 10); //seg fault
while(1) {
pid = wait(&ret);
//printf("exited - pid %d => %d\n", pid, ret);
}
}
比如
#define _SYS1(T0, FN, T1) \
T0 FN(T1 p1){ \
register int r; \
asm volatile( \
"int $0x80" \
:"=a"(r), \
"=b"(errno) \
:"a"(NR_##FN), \
"b"((int)p1) \
); \
if (r<0){ \
errno = -r; \
return -1; \
} \
return r; \
}
这是个不统一的地方,而且没必要通过ebx
来设置errno
。errno放在负数里返回就行了
感觉好NB啊,不知道王猫猫有这种才能
RT
对于问题2.可能的修复方法:
a. 我发现linux 0.11是没有做安全检测就直接访问path的 0_0
b. linux 2.6.11里面是 使用strncpy_from_user(page, pathname, PATH_MAX_LEN) 这里PATH_MAX_LEN默认是4KB,
并且strncpy_from_user兼具检测和拷贝的功能.
出错信息:
ld bin/libsys/entry.o bin/libsys/libsys.o bin/libsys/string.o bin/libsys/printf.o bin/usr/test_fork.o -o bin/usr/test_fork -e c -T tool/user.ld
tool/user.ld:28: undefined symbol `_start' referenced in expression
删除 user.ld中这句: c = _start;
可以链接通过.
c = _start; 这个是什么特殊作用? c符号是?
I am doubt that the initialization of the BIOS is not the part of kernel's work, and the former is taken by QEMU/Bochs these emulator, right?
Here is the ruby code to create abundant and repeating NASM code from src/kern/entry.S
:
NINT = 128
0.upto(NINT) do |i|
puts %{
_hwint#{i}:
#{'push dword 0' if i!=17 and (i<8 or i>14)}
push dword #{i}
jmp _hwint_common_stub
}
end
# generate the vector table
puts %{
; vector table
[section .data]
[global _hwint]
_hwint:
}
0.upto(NINT) do |i|
puts " dd _hwint#{i}"
end
Is it difficult to implement this with nasm macro?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.