Skip to content

Commit

Permalink
feat: add exercise 3-1 & 3-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ludics committed Aug 27, 2023
1 parent 457713c commit dd7e928
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.o
*.bin
*.elf

*.o.*
9 changes: 9 additions & 0 deletions code/exercises/ex_3_1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all:
gcc -c hello.c -o hello.o
readelf -h hello.o > hello.o.header
readelf -SW hello.o > hello.o.section
gcc -c hello.c -o hello.o -g
objdump -S hello.o > hello.o.disassembly

clean:
rm -rf *.o *.header *.section *.disassembly
7 changes: 7 additions & 0 deletions code/exercises/ex_3_1/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "stdio.h"

int main()
{
printf("Hello World!\n");
return 0;
}
6 changes: 6 additions & 0 deletions code/exercises/ex_3_2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all:
gcc -c code.c -o code.o
objdump -t code.o > code.o.symbol

clean:
rm -rf *.o *.symbol
15 changes: 15 additions & 0 deletions code/exercises/ex_3_2/code.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>

int global_init = 0x11111111;
const int global_const = 0x22222222;

void main()
{
static int static_var = 0x33333333;
static int static_var_uninit;

int auto_var = 0x44444444;

printf("hello world!\n");
return;
}

0 comments on commit dd7e928

Please sign in to comment.