- 博客(9)
- 资源 (1)
- 收藏
- 关注
原创 CSAPP学习日志之系统IO举例分析
有关系统IO的举例分析说明首先是一个关于IO重定向和只读的例子#include "csapp.h"int main(int argc, char *argv[]){ int fd1, fd2, fd3; char c1, c2, c3; char *fname = argv[1]; fd1 = Open(fname, O_RDONLY, 0); ...
2019-12-08 14:22:37 204
原创 CSAPP学习日志之部分fork函数
有关fork函数的举例说明先来看一个简单的例子/* * fork2 - Two consecutive forks * Both parent and child can continue forking * Ordering undetermined */void fork2(){ printf("L0\n"); fork(); printf("L1\...
2019-12-08 11:50:30 158
原创 CSAPP学习日志之链接
首先,我们来看一个经典例子hello.c的可执行文件的生成过程。hello.c是通过一系列处理过程才得到最终可被机器执行的程序文件,其中的链接过程就是这次学习的重点。链接链接过程将多个可重定位目标文件合并以生成可执行目标文件。在Linux中使用ELF格式描述目标文件。在这里我想通过一个例子来帮助理解链接过程的目标文件ELF格式:在此先附上可重定位目标文件和可执行目标文件的ELF格式图...
2019-11-30 11:48:06 184
原创 CSAPP实验之bufdemo.c
bufdemo代码/* Demonstration of buffer overflow */#include <stdio.h>#include <stdlib.h>/* Implementation of library function gets() */char *gets(char *dest){ int c = getchar(); char...
2019-05-31 15:56:48 171
原创 CSAPP实验之runaway.c
runaway代码/* Example of deep recursion */#include <stdio.h>#include <stdlib.h>int recurse(int x) { int a[1<<15]; /* 4 * 2^15 = 64 KiB */ printf("x = %d. a at %p\n", x,...
2019-05-30 00:49:40 244
原创 CSAPP实验之fsum.c
fsum代码#include <stdio.h>#include <stdlib.h>#include <string.h>#define BUFSIZE 256int main(int argc, char *argv[]) { char prefix[BUFSIZE]; char next[BUFSIZE]; int i; ...
2019-05-29 15:22:08 273
原创 CSAPP实验之show-bytes.c
show-bytes代码/* show-bytes - prints byte representation of data *//* $begin show-bytes */#include <stdio.h>/* $end show-bytes */#include <stdlib.h>#include <string.h>/* $begin ...
2019-05-28 22:02:00 571
原创 CSAPP实验之sq.c
sq代码#include <stdio.h>#include <stdlib.h>int sq(int x) { return x*x;}int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { int x = atoi(argv[i]); int...
2019-05-28 13:24:40 198
原创 CSAPP实验之struct.c
struct代码#include <stdio.h>#include <stdlib.h>typedef struct { int a[2]; double d;} struct_t;double fun(int i) { volatile struct_t s; s.d = 3.14; s.a[i] = 107374182...
2019-05-27 23:56:19 166
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人