摘要: 对于c的可重定位文件中的.symtab..symtab存放的是 全局变量/函数名字. --- 给连接器来使用symtab中每个条目都有自己的属性.所以static与非static的全局变量和函数名字都在.symtab中,在重定位之后才会被去除,不过static类型的定义,连接器不会把它往外部.链接但是虽然不往外部链接,用到函数名或者全局变量的地方,无论是否为static,都需要在链接时候进行重定位.!!!!!!!!!!!!!! 阅读全文
posted @ 2011-10-31 23:56 Jack204 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 首先必须明确,module生成的.ko文件中的全局变量,函数名在insmod之前还没有被重定位,也就是在加载的时候,才被分配了地址,进行了重定位。1 insmod rmmod时候,调用init, exit.使用宏module_init(init), module_exit(exit).导出,在加载模块的时候,重定位之后,kernel内模块的control block内就有这么2个函数指针变量*p_init, *p_exit分别用于存放init和exit的地址。这是动态生成的。 阅读全文
posted @ 2011-10-31 22:57 Jack204 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 主要的Makefile内容如下,非常的绕。 1 ifneq ($(KERNELRELEASE),) 2 # call from kernel build system 3 4 scull-objs := main.o pipe.o access.o 6 obj-m := scull.o 7 8 else 9 10 KERNELDIR ?= /lib/modules/$(shell uname -r)/build11 PWD := $(shell pwd)12 13 modules:14 $(MAKE) -C $(KERNELDIR) M=$(PWD) LDD... 阅读全文
posted @ 2011-10-31 19:42 Jack204 阅读(3440) 评论(0) 推荐(0) 编辑
摘要: DescriptionFor the purpose of performing permission checks, traditional Unix implementations distinguish two categories of processes: privileged processes (whose effective user ID is 0, referred to as superuser or root), and unprivileged processes (whose effective UID is non-zero). Privileged proces 阅读全文
posted @ 2011-10-31 14:51 Jack204 阅读(1002) 评论(0) 推荐(0) 编辑
摘要: 要理解,当然要从数据结构去理解以下代码来自<linux/sched.h> <asm-generic/signal.h> <linux/signal.h>。每一个process的task descriptor task_struct中跟signal有关的field:task_struct{ .... struct signal_struct *signal; struct sighand_struct *sighand; struct sigpending pending; //private pending signal for every LWP sigs 阅读全文
posted @ 2011-10-31 10:30 Jack204 阅读(2922) 评论(0) 推荐(0) 编辑