update related_info::lab0
This commit is contained in:
@@ -7,6 +7,4 @@ If you get gcc's error, try to read make.log and fix the bugs.
|
||||
|
||||
If gcc successed, then you will get a.out.
|
||||
|
||||
Try to answer below question.
|
||||
|
||||
|
||||
|
||||
12
related_info/lab0/lab0_ex5.c
Normal file
12
related_info/lab0/lab0_ex5.c
Normal file
@@ -0,0 +1,12 @@
|
||||
void X(int b) {
|
||||
if (b==1){
|
||||
printf("X:: b is 1!\n");
|
||||
}else{
|
||||
printf("X:: b is not 1!\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv){
|
||||
int a=2;
|
||||
X(a);
|
||||
}
|
||||
19
related_info/lab0/lab0_ex5.md
Normal file
19
related_info/lab0/lab0_ex5.md
Normal file
@@ -0,0 +1,19 @@
|
||||
#README
|
||||
analysis lab0_ex5
|
||||
```
|
||||
echo "compile and analysis lab0_ex5"
|
||||
echo "====================================="
|
||||
gcc -m32 -g -o lab0_ex5.exe lab0_ex5.c
|
||||
echo "====================================="
|
||||
echo "using objdump to decompile lab0_ex5"
|
||||
echo "====================================="
|
||||
objdump -S lab0_ex5.exe
|
||||
echo "====================================="
|
||||
echo "using readelf to analyze lab0_ex5"
|
||||
echo "====================================="
|
||||
readelf -a lab0_ex5.exe
|
||||
echo "====================================="
|
||||
echo "using nm to analyze lab0_ex5"
|
||||
echo "====================================="
|
||||
nm lab0_ex5.exe
|
||||
```
|
||||
15
related_info/lab0/lab0_ex6.c
Normal file
15
related_info/lab0/lab0_ex6.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
void main(void){
|
||||
int child_status, exec_status;
|
||||
int pid = fork(); //create a child
|
||||
if (pid==0) { // child continues here
|
||||
printf("Child: EXEC lec7_1\n");
|
||||
exec_status=execve("lec7_1",NULL,NULL);
|
||||
printf("Child: Why would I execute?\n");
|
||||
} else { // parent continues here
|
||||
printf("Parent: Whose your daddy?\n");
|
||||
child_status=wait(pid);
|
||||
printf("Parent: the child %d exit with %d\n",pid, child_status);
|
||||
}
|
||||
}
|
||||
9
related_info/lab0/lab0_ex6.md
Normal file
9
related_info/lab0/lab0_ex6.md
Normal file
@@ -0,0 +1,9 @@
|
||||
#README
|
||||
analysis lab0_ex6
|
||||
```
|
||||
echo "====================================="
|
||||
echo "compile and analysis lab0_ex6"
|
||||
echo "====================================="
|
||||
gcc -g -m32 -o lab0_ex6.exe lab0_ex6.c
|
||||
./lab0_ex6
|
||||
```
|
||||
Reference in New Issue
Block a user