diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2023-07-27 12:06:17 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2023-07-27 12:06:17 -0700 |
commit | 578531395ecbabd8179e31520c2832ac7d6d3765 (patch) | |
tree | a19666928bb0d8aa47c9c9135cd80268b124ec82 /python/examples/zero_init | |
parent | e29b2b00691b12ae70e97a072664bad073d81c4f (diff) |
add dynamic typing example
Diffstat (limited to 'python/examples/zero_init')
-rw-r--r-- | python/examples/zero_init/.gitignore | 2 | ||||
-rw-r--r-- | python/examples/zero_init/Makefile | 10 | ||||
l--------- | python/examples/zero_init/dietc.py | 1 | ||||
-rwxr-xr-x | python/examples/zero_init/dietpass (renamed from python/examples/zero_init) | 1 | ||||
-rw-r--r-- | python/examples/zero_init/test.c | 20 |
5 files changed, 33 insertions, 1 deletions
diff --git a/python/examples/zero_init/.gitignore b/python/examples/zero_init/.gitignore new file mode 100644 index 0000000..b74bd7f --- /dev/null +++ b/python/examples/zero_init/.gitignore @@ -0,0 +1,2 @@ +default +instrumented diff --git a/python/examples/zero_init/Makefile b/python/examples/zero_init/Makefile new file mode 100644 index 0000000..92f29b7 --- /dev/null +++ b/python/examples/zero_init/Makefile @@ -0,0 +1,10 @@ +all: default instrumented + +default: test.c + gcc -O0 $^ -o $@ + +instrumented: test.c + dietcc -O0 $^ -o $@ --dietc-pass $(PWD)/dietpass + +clean: + rm -f default instrumented diff --git a/python/examples/zero_init/dietc.py b/python/examples/zero_init/dietc.py new file mode 120000 index 0000000..8cb9097 --- /dev/null +++ b/python/examples/zero_init/dietc.py @@ -0,0 +1 @@ +../../dietc.py
\ No newline at end of file diff --git a/python/examples/zero_init b/python/examples/zero_init/dietpass index e2ab92e..1984d81 100755 --- a/python/examples/zero_init +++ b/python/examples/zero_init/dietpass @@ -1,7 +1,6 @@ #!/bin/python3 import os import sys -sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) import dietc prog = dietc.Program(open(sys.argv[1], "rb").read()) diff --git a/python/examples/zero_init/test.c b/python/examples/zero_init/test.c new file mode 100644 index 0000000..5db109a --- /dev/null +++ b/python/examples/zero_init/test.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +int set_xyz() { + int xyz = 1; + return xyz; +} + +int foo() { + int xyz; + return xyz; +} + +int main() { + printf("Foo return value: %d\n", foo()); + set_xyz(); + printf("Foo return value: %d\n", foo()); + set_xyz(); + printf("Foo return value: %d\n", foo()); + return 0; +} |