- 博客(44)
- 资源 (50)
- 收藏
- 关注
原创 gcc源代码分析的方法【总结】
看gcc-1.40有段时间了,14年左右看了一段时间,15年左右看了一段时间。现在可以说基本上明白了gcc的大部分代码。如果说能快速的明白其中的原理,总结我看代码的方法捷径我列举以下几条。第一,gcc版本低,这是成功的前提,也是一条捷径。第二,分析最基本的hello.c文件,就一条函数调用,但是已经足够。第三,发现了debug_rtx ()函数和debug_tree ()函数。
2015-01-09 19:35:38 3626 1
原创 加速内核编译速度的几个方法
1,.config文件最好是最近的官方内核的.config文件,因为有些config_xxx选项可能会变化。2,make 加上 -j4选项,现在的机器基本上都是双核四核。3,make localmodconfig是个很好的方法,我的模块才53个,5m左右。而官方的4000多个,100多m。能显著的减少模块编译的速度,我的也就是5分钟,而官方的编译要4个小时左右。4,为了减少编译
2015-01-31 23:45:29 4987
原创 CONFIG_DEBUG_INFO 能显著增加ko文件的大小
CONFIG_DEBUG_INFO以调试方式编译内核(gcc -g).仅供内核开发者使用Debug VMmy-video.ko: 文件格式 elf32-i386节:Idx Name Size VMA LMA File off Algn 0 .note.gnu.build-id 00000024 0000000
2015-01-31 22:07:38 3594
原创 linux下如何看我的显卡驱动是否装好了
看configurure字段有木有driver字样,若有内容,则显卡驱动装好了。sudo lshw -c videoWARNING: you should run this program as super-user.^CI (sysfs) chenghao@chenghao-Lenovo-Product:~$ sudo lshw -c video[sudo] passwor
2015-01-30 16:33:45 15077 5
原创 acpi package has zero elements错误的解决
下面的是我的配置文件的ACPI部分:# CONFIG_PM_WAKELOCKS is not setCONFIG_PM_TEST_SUSPEND=y# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set# CONFIG_ACPI_PROCFS is not setCONFIG_ACPI_PROCESSOR_AGG
2015-01-30 10:05:55 2794
原创 initramfs-tools套件,wait-for-root代码分析
initramfs-tools_0.103下载#include #include #include #include #include #include #include #include #include #include #include static int device_queued (struct udev *ude
2015-01-29 22:55:05 2471
原创 initrd/bin/run-init源代码来源与klibc-2.0.4/usr/kinit目录
#include #include #include #include #include #include "run-init.h"static const char *program;static void __attribute__ ((noreturn)) usage(void){ fprintf(stderr, "Usag
2015-01-29 17:03:31 2499 1
转载 Initrd启动及功能分析
Initrd启动及功能分析Initrd这个设计的初衷是用来加载额外内核模块供启动的。可以参考 内核文档 Documentation/initrd.txt。在加载完内核后,如果存在initrd,则会执行 initrd 里的 /init。(文档里说的是/linuxrc,在 init/do_mounts_initrd.c 里也是这个,在 init/main.c 里是 /init,具体待考。)
2015-01-29 15:44:55 1771
原创 内核编译init脚本调用mountroot()函数分析
mountroot(){ pre_mountroot # Get the root filesystem type if not set if [ -z "${ROOTFSTYPE}" ]; then [ -n "${FSTYPE}" ] || FSTYPE=$(blkid -s TYPE -o value "${ROOT}")
2015-01-29 07:59:55 1673 1
转载 initrd 中init 脚本的分析
initrd 中init 脚本的分析 由前面 cpio-initrd的处理流程可以看到,内核在将其解开并放入 rootfs 后,将要执 行 /init文件,所以我们分析的重点就是这个文件。其它的文件请结合具体的源码与本文的内容进行理解。 #!/bin/sh该行说明该init文件是一个由sh解释并执行的脚本文件,内核通过文件头来确定应该怎样执行(即是直接执行还
2015-01-28 22:35:47 3651 1
原创 initrd.img中的init脚本分析,load_modules()分析
定义在scripts/functions中。# Don't do log messages here to avoid confusing graphical bootsrun_scripts /scripts/init-top在init脚本中被调用:maybe_break modules[ "$quiet" != "y" ] && log_begin_msg "Loadi
2015-01-28 20:36:43 2022 1
原创 scripts/local脚本mount_root脚本文件分析
# Local filesystem mounting -*- shell-script -*-pre_mountroot(){ [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top" run_scripts /scripts/local-top [ "$qu
2015-01-28 14:02:16 3594 1
原创 mkinitramfs命令详解
#!/bin/shumask 0022export PATH='/usr/bin:/sbin:/bin'# Defaultskeep="n"CONFDIR="/etc/initramfs-tools"verbose="n"test -e /bin/busybox && BUSYBOXDIR=/bintest -e /usr/lib/initramfs-too
2015-01-28 13:19:11 13756 1
原创 acpi_init什么时候调用的?定义在哪个位置?
static int __init acpi_init(void){ int result; if (acpi_disabled) { printk(KERN_INFO PREFIX "Interpreter disabled.\n"); return -ENODEV; } acpi_kobj = kobjec
2015-01-27 23:28:17 1748
原创 subsys_initcall宏定义的一个例子,acpi/bus.c里面。
static int __init acpi_init(void){ int result; if (acpi_disabled) { printk(KERN_INFO PREFIX "Interpreter disabled.\n"); return -ENODEV; } acpi_kobj = kobjec
2015-01-27 22:43:41 1148
原创 init文件调试结果
grub.conf 里面的quiet去掉,加上debug可以看出调用了//script/local-premountscript/local-boottomscript/init-boottom
2015-01-26 21:54:44 1061
原创 initramfs对应的init脚本文件,解压后可见
#!/bin/sh[ -d /dev ] || mkdir -m 0755 /dev[ -d /root ] || mkdir -m 0700 /root[ -d /sys ] || mkdir /sys[ -d /proc ] || mkdir /proc[ -d /tmp ] || mkdir /tmpmkdir -p /var/lockmount -t sys
2015-01-26 21:27:31 3413 1
转载 initrd.img的解压和修改后再压缩
内核中的initrd.img采用cpio压缩,不再是2.4内核使用的ext2格式,无法使用mount -o loop 挂载。需要使用gunzip解压缩,然后再使用cpio解包cp /boot/initrd-***.img initrd.img.gzgunzip initrd.img.gzmkdir initrdmv initrd.img initrdcd initrdc
2015-01-26 18:06:49 2018
原创 内核重新编译之make install和生成initramfs的过程分析
$ sudo make installsh /home/ch/下载/linux-3.13/arch/x86/boot/install.sh 3.13.0 arch/x86/boot/bzImage \ System.map "/boot"run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0
2015-01-26 14:21:34 8740
原创 mkinitramfs脚本文件分析,位置/usr/sbin/mkinitramfs
#!/bin/shumask 0022export PATH='/usr/bin:/sbin:/bin'# Defaultskeep="n"CONFDIR="/etc/initramfs-tools"verbose="n"test -e /bin/busybox && BUSYBOXDIR=/bintest -e /usr/lib/initramfs-too
2015-01-26 07:37:29 2346
原创 gcc源代码分析,grokparms ()函数分析
arg_types = grokparms (TREE_OPERAND (declarator, 1), funcdef_flag /* Say it's a definition only for the CALL_EXPR closest
2015-01-17 15:28:43 1380 1
原创 gcc源代码分析,函数声明的类型<tree_list 95608产生的过程
int printf (const char * , ... ) ;typed_declspecs: typespec reserved_declspecs { $$ = tree_cons (NULL_TREE, $1, $2); }printf value
2015-01-17 12:05:59 1094
原创 gcc源代码分析,grokdeclarator()函数分析 ,第二部分
函数声明的类型tree是如何生成的?grokdeclarator()函数的第二个参数为: value global 824d0* int> permanent VOID file (null) line 0 align 1 size_unit 1 offset 0
2015-01-16 22:36:51 1242
原创 gcc源代码分析,grokdeclarator()函数分析
grokdeclarator部分代码: if (initialized) error ("parameter `%s' is initialized", name); decl = build_decl (PARM_DECL, declarator, type);调试结果:build_decl type
2015-01-15 18:42:51 1592
原创 gcc源代码分析,get_parm_info ()函数分析
/* Return a tree_list node with info on a parameter list just parsed. The TREE_PURPOSE is a chain of decls of those parms. The TREE_VALUE is a list of structure, union and enum tags defined.
2015-01-15 13:33:02 1630
原创 gcc源代码分析,finish_decl ()函数和push_parm_decl ()函数分析
parms: parm { push_parm_decl ($1); }/* This is what appears inside the parens in a function declarator. Is value is represented in the format that grokdeclarator expects. */pa
2015-01-14 21:56:22 1204
原创 gcc源代码分析,finish_decl ()函数和rest_of_decl_compilation ()函数分析
int printf (const char * , ... ) ; 本文探讨函数声明到tree到rtx的生成过程。c-parse.y文件中有下面的一条规则,会调用start_decl ()函数和finish_decl ()函数。initdcl: declarator maybeasm maybe_attribute '='
2015-01-14 20:19:04 1226
原创 gcc源代码分析,default_conversion ()函数分析
/* Perform default promotions for C data used in expressions. Arrays and functions are converted to pointers; enumeral types or short or char, to int. In addition, manifest constants symbo
2015-01-11 15:42:48 1364
原创 gcc源代码分析,actualparameterlist ()函数分析
/* Build a function call to function FUNCTION with parameters PARAMS. PARAMS is a list--a chain of TREE_LIST nodes--in which the TREE_VALUE of each node is a parameter-expression. FUNCTION
2015-01-11 13:05:14 1182
原创 gcc源代码分析,build_pointer_type ()函数分析
function = build (ADDR_EXPR, build_pointer_type (TREE_TYPE (function)), function);继续分析上篇文章的这句。/* Constructors for pointer, array and function types. (RECORD_TYPE, UNION_TY
2015-01-11 09:23:06 1297
原创 gcc源代码分析,build_function_call ()函数分析
在文件c-typeck.c中c-parse.tab.y文件中这个地方调用!primary: | primary '(' exprlist ')' %prec '.' { $$ = build_function_call ($1, $3); }/* Build a function call to function FUNCTION w
2015-01-09 19:02:55 1894
原创 gcc源代码分析,get_identifier ()函数分析,printf 产生标识符的过程
if (value == IDENTIFIER) { yylval.ttype = get_identifier (token_buffer); lastiddecl = lookup_name (yylval.ttype); if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_
2015-01-09 11:31:09 1274
原创 gcc源代码分析,build_string ()函数分析
本文说明如何从源程序到一个tree节点的产生过程。以"Hello,world!\n"字符串为例。c-parse.tab.c文件中的yylex()函数是gcc编译器的词法分析部分。这里的一段代码: else { *p = 0; yylval.ttype = build_string (p - token_buffer, toke
2015-01-09 10:11:41 1180
原创 gcc源代码分析,在expand_call ()函数 和expand_expr_stmt ()函数的开始处加入debug_tree ()函数
对于expand_call函数来说最主要的参数就是exp这个tree树,打印出来之后我们终于看到了printf和Hello,world!expand_call type size align 32 size_unit 8 sep_unit 32 symtab 0 sep max
2015-01-08 21:38:15 1424
原创 gcc源代码分析,print_node()函数分析第一部分
type type size align 8 size_unit 8 sep_unit 8 symtab 0 sep max pointer_to_this permanent unsigned SI
2015-01-08 18:02:22 1371
原创 gcc源代码分析,expand_call ()函数分析第五部分,store_one_arg ()函数
本文主要是分析store_one_arg ()函数和expand_expr ()的关系来说明如何处理函数的参数。printf("Hello, world!\n");中的"Hello, world!\n"这个字符串常量的!expand_call () 函数中的相关代码: if (args[i].reg == 0 && TYPE_SIZE (TREE_TYPE
2015-01-06 11:07:17 1208
原创 gcc源代码分析,expand_call ()函数第四部分,emit_call_1 ()函数
本文是为了解释下面这4个rtx是如何产生的,和emit_call_1 ()函数有关。(const_int 4)(mem:QI (symbol_ref/v:SI ("printf")))(call (mem:QI (symbol_ref/v:SI ("printf"))) (const_int 4))(set (reg:SI 0) (call (m
2015-01-06 08:48:16 1279
原创 gcc源代码分析,expand_call()函数第三部分
(insn_list 6 (nil))(insn_list 2 (insn_list 6 (nil)))(sequence[ ] )(reg:SI 0)(const_int 4)这次是解释这5条rtx的产生过程 相关的代码片段:/* Mark all register-parms as living through the call
2015-01-06 08:13:31 1273
原创 gcc源代码分析gen_push_operand ()函数和emit_move_insn ()函数
如何生成下面红色的3个指令?和gen_push_operand ()函数和emit_move_insn ()函数有关,他们都在expand_call()函数中被调用。具体位置: rtx addr;#ifdef PUSH_ROUNDING if (args_addr == 0) addr = gen_push_operand ();
2015-01-05 18:32:01 1555
原创 gcc源代码分析,expand_call()函数和printf("Hello, world!\n");的关系
expand_call()函数在expr.c文件中。下面是expand_call()函数的主要调试结果,记录之。主要是加入了debug_tree()函数和debug_rtx()函数。debug_tree()函数加入到了expand_expr()函数的开始。debug_rtx()函数加入到了gen_rtx()函数的结束处。emit_call_1()函数是何时调用的也能看出。e
2015-01-05 10:58:47 1545
netcat 1.15-2 by chenghao0511
2013-05-14
netcat 1.142 by chenghao0511
2013-05-05
netcat 1.14 by chenghao0511
2013-05-03
samba rpm包 for centos-5.5
2013-03-25
bash 1.05 by gcc-1.40 in minix-386 第二版
2013-02-23
fdisk-by-chenghao0511 for linux-0.11
2013-02-16
readinode for linux-0.11 by chenghao0511
2013-02-15
readblock for linux-0.11 by chenghao0511
2013-02-15
fileino-chenghao0511
2013-02-14
isbn十位转13位.xlsx
2020-05-09
cute http file server 开发API
2018-11-01
Prime numbers and the Riemann zeta function.by Jørgen Veisdal
2018-03-27
initramfs-tools_0.103
2015-01-29
linux-0.11硬盘集成盘14年1月9日by chenghao0511
2014-01-09
调试shoelace的winiboot所需的img文件
2014-01-08
readline used in linux-0.11 made in minix
2014-01-04
linux-0.11内核文件备份
2014-01-03
TUTORIAL FOR INSTALLING MINIX-386
2013-12-14
netcat.dll(UDP版) by chenghao0511
2013-05-20
netcat 1.15-3 by chenghao0511
2013-05-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人