作者final01 (牛顿运动定律)
看板LinuxDev
标题Re: [问题] bootloader 不需要 OS 也能用 C header?
时间Fri Oct 21 13:13:16 2011
※ 引述《SweepingMonk ((((((((((()))))))))))》之铭言:
: 最近在 trace 一个 bootloader (x-loader)的 source code
: 原以为在没有 OS 的环境下就不能呼叫 standard C library
: 但是 source code 里面还是有不少档案有 include standard C library 像是
: #include <stdio.h>
: #include <errno.h>
: #include <stdlib.h>
: #include <string.h>
: 另外还有 include 到 linux 的 header files
: #include <malloc.h>
: #include <linux/types.h>
: #include <sys/stat.h>
: #include <fcntl.h>
: 这跟我想像的差很多...是我的观念有问题吗?
: 还是只要 static link 成一个不依赖外部 library 的程式,一样可以在没有 OS 的环境
: 下面执行?
: 请帮小的解惑 <(_._)>
: 谢谢~
我刚去看了下x-loader的code
你说有include这些glibc的是一个叫signGP.c吧
它不算是x-loader binary的一部分,只是一个工具用来转成x-load.bin.ift的
所以没问题阿
还有include那些linux header你去看他的inculde它都有
define所以include也没问题的
你把它包成static没有OS中的loader你也没办法执行的
所以不是你讲的那样
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 60.250.164.201
1F:→ clampsakura:可以参考一下 ap or kernel bin & bl 的memory map... 10/22 03:34
2F:推 SweepingMonk:谢谢! 10/24 10:24